[NEW] Addons creation - product_rental_delay_management
This commit is contained in:
4
product_rental_delay_management/models/__init__.py
Normal file
4
product_rental_delay_management/models/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import product_delay_lines
|
||||
from . import stock_picking
|
@@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class ProductDelayLines(models.Model):
|
||||
_name = "product.delayed.lines"
|
||||
_description = "Product Delayed Lines"
|
||||
|
||||
@api.depends("delayed_hours", "delay_cost_per_hour")
|
||||
def _get_subtotal(self):
|
||||
for each in self:
|
||||
each.sub_total = each.delayed_hours * each.delay_cost_per_hour
|
||||
|
||||
product_delay_id = fields.Many2one("stock.picking", string="Product Move")
|
||||
product_id = fields.Many2one("product.product", string="Product Name")
|
||||
delay_cost_per_hour = fields.Float(string="Cost/Hour")
|
||||
delayed_hours = fields.Float(string="Total Hours")
|
||||
sub_total = fields.Float(string="Sub Total", compute="_get_subtotal", store=True)
|
||||
products_checked = fields.Boolean(string="Select Products")
|
32
product_rental_delay_management/models/stock_picking.py
Normal file
32
product_rental_delay_management/models/stock_picking.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tests import Form
|
||||
|
||||
|
||||
class StockPicking(models.Model):
|
||||
_inherit = "stock.picking"
|
||||
|
||||
product_delay_line_ids = fields.One2many(
|
||||
"product.delayed.lines", "product_delay_id", string="Delayed Hours "
|
||||
)
|
||||
is_delayed = fields.Boolean(string="Is Delayed")
|
||||
|
||||
@api.depends("product_delay_line_ids")
|
||||
def _compute_total(self):
|
||||
for record in self:
|
||||
for line in record.product_delay_line_ids:
|
||||
record.total_amount += line.sub_total
|
||||
|
||||
def delivery(self):
|
||||
product_delay_line_ids = []
|
||||
if any([each.products_checked for each in self.move_ids_without_package]):
|
||||
deliver_move_id = super(StockPicking, self).delivery()
|
||||
deliver_move_id.write(
|
||||
{
|
||||
"product_delay_line_ids": product_delay_line_ids,
|
||||
}
|
||||
)
|
Reference in New Issue
Block a user