Skip to content

Commit 3205d5e

Browse files
committed
[IMP] sale_order_lot_selection: Hide the lot_id field if the product does not have tracking defined
1 parent 6397576 commit 3205d5e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

sale_order_lot_selection/models/sale_order_line.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
class SaleOrderLine(models.Model):
55
_inherit = "sale.order.line"
66

7+
product_tracking = fields.Selection(
8+
selection=lambda self: self.env["product.product"]
9+
._fields["tracking"]
10+
.selection,
11+
compute="_compute_product_tracking",
12+
)
713
lot_id = fields.Many2one(
814
"stock.lot",
915
"Lot",
@@ -20,6 +26,11 @@ def _prepare_procurement_values(self, group_id=False):
2026
vals["restrict_lot_id"] = self.lot_id.id
2127
return vals
2228

29+
@api.depends("product_id")
30+
def _compute_product_tracking(self):
31+
for sol in self:
32+
sol.product_tracking = sol.product_id.tracking or sol.product_tracking
33+
2334
@api.depends("product_id")
2435
def _compute_lot_id(self):
2536
for sol in self:

sale_order_lot_selection/views/sale_order_views.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<field
1212
name="lot_id"
1313
domain="[('product_id','=', product_id)]"
14+
invisible="not product_id or product_tracking=='none'"
1415
context="{'default_product_id': product_id}"
1516
groups="stock.group_production_lot"
1617
/>
@@ -22,6 +23,7 @@
2223
<field
2324
name="lot_id"
2425
domain="[('product_id','=', product_id)]"
26+
invisible="not product_id or product_tracking=='none'"
2527
context="{'default_product_id': product_id}"
2628
groups="stock.group_production_lot"
2729
/>

0 commit comments

Comments
 (0)