Set a category domain on requisition line unit
The unit is used to create a purchase request which has such constraint. But as they are created by the process method which is queued, the user does not get any error message. issue8610 review267971003
This commit is contained in:
1 parent
0c4a696a78
commit
f43ce1a738
1 file changed
+21
+21
@@ -433,6 +433,9 @@ class PurchaseRequisitionLine(sequence_ordered(), ModelSQL, ModelView):
|
||||
('purchasable', '=', True),
|
||||
],
|
||||
states=_states, depends=_depends)
|
||||
product_uom_category = fields.Function(
|
||||
fields.Many2One('product.uom.category', "Product UOM Category"),
|
||||
'on_change_with_product_uom_category')
|
||||
description = fields.Text("Description", states=_states, depends=_depends)
|
||||
quantity = fields.Float(
|
||||
'Quantity', digits=(16, Eval('unit_digits', 2)), required=True,
|
||||
@@ -461,6 +464,24 @@ class PurchaseRequisitionLine(sequence_ordered(), ModelSQL, ModelView):
|
||||
|
||||
del _states
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super().__setup__()
|
||||
unit_categories = cls._unit_categories()
|
||||
cls.unit.domain = [
|
||||
('category', 'in', [Eval(c) for c in unit_categories]),
|
||||
]
|
||||
cls.unit.depends.extend(unit_categories)
|
||||
|
||||
@classmethod
|
||||
def _unit_categories(cls):
|
||||
return ['product_uom_category']
|
||||
|
||||
@fields.depends('product')
|
||||
def on_change_with_product_uom_category(self, name=None):
|
||||
if self.product:
|
||||
return self.product.default_uom_category.id
|
||||
|
||||
@fields.depends('requisition', '_parent_requisition.state')
|
||||
def on_change_with_purchase_requisition_state(self, name=None):
|
||||
if self.requisition:
|
||||
|
||||
Reference in new issue
Block a user