Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
1
sale_order_lot_selection/models/__init__.py
Executable file
1
sale_order_lot_selection/models/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from . import sale_order_line
|
||||
41
sale_order_lot_selection/models/sale_order_line.py
Executable file
41
sale_order_lot_selection/models/sale_order_line.py
Executable file
@@ -0,0 +1,41 @@
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class SaleOrderLine(models.Model):
|
||||
_inherit = "sale.order.line"
|
||||
|
||||
def _selection_product_tracking(self):
|
||||
return self.env["product.product"].fields_get(
|
||||
allfields=["tracking"],
|
||||
)["tracking"]["selection"]
|
||||
|
||||
product_tracking = fields.Selection(
|
||||
selection=_selection_product_tracking,
|
||||
compute="_compute_product_tracking",
|
||||
)
|
||||
lot_id = fields.Many2one(
|
||||
"stock.lot",
|
||||
"Lot",
|
||||
copy=False,
|
||||
compute="_compute_lot_id",
|
||||
store=True,
|
||||
readonly=False,
|
||||
precompute=True,
|
||||
)
|
||||
|
||||
def _prepare_procurement_values(self, group_id=False):
|
||||
vals = super()._prepare_procurement_values(group_id=group_id)
|
||||
if self.lot_id:
|
||||
vals["restrict_lot_id"] = self.lot_id.id
|
||||
return vals
|
||||
|
||||
@api.depends("product_id")
|
||||
def _compute_product_tracking(self):
|
||||
for sol in self:
|
||||
sol.product_tracking = sol.product_id.tracking or sol.product_tracking
|
||||
|
||||
@api.depends("product_id")
|
||||
def _compute_lot_id(self):
|
||||
for sol in self:
|
||||
if sol.product_id != sol.lot_id.product_id:
|
||||
sol.lot_id = False
|
||||
Reference in New Issue
Block a user