Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions sale_order_lot_selection/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
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",
Expand All @@ -20,6 +29,11 @@ def _prepare_procurement_values(self, group_id=False):
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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# © 2015 Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.fields import Command
from odoo.tests import TransactionCase

from odoo.addons.base.tests.common import BaseCommon

class TestSaleOrderLotSelection(TransactionCase):

class TestSaleOrderLotSelection(BaseCommon):
@classmethod
def setUpClass(cls):
"""
Expand Down
3 changes: 3 additions & 0 deletions sale_order_lot_selection/views/sale_order_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
<field
name="lot_id"
domain="[('product_id','=', product_id)]"
invisible="not product_id or product_tracking=='none'"
context="{'default_product_id': product_id}"
groups="stock.group_production_lot"
optional="show"
/>
</xpath>
<xpath
Expand All @@ -22,6 +24,7 @@
<field
name="lot_id"
domain="[('product_id','=', product_id)]"
invisible="not product_id or product_tracking=='none'"
context="{'default_product_id': product_id}"
groups="stock.group_production_lot"
/>
Expand Down