changeset fd137f4b2551 in modules/purchase_secondary_unit:default
details: 
https://hg.tryton.org/modules/purchase_secondary_unit?cmd=changeset;node=fd137f4b2551
description:
        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
diffstat:

 purchase.py |  14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diffs (24 lines):

diff -r bf72762f710d -r fd137f4b2551 purchase.py
--- a/purchase.py       Sat Sep 07 23:45:08 2019 +0200
+++ b/purchase.py       Sat Sep 28 23:13:08 2019 +0200
@@ -190,6 +190,20 @@
 class RequisitionLine(metaclass=PoolMeta):
     __name__ = 'purchase.requisition.line'
 
+    product_secondary_uom_category = fields.Function(
+        fields.Many2One(
+            'product.uom.category', "Product Secondary UOM Category"),
+        'on_change_with_product_secondary_uom_category')
+
+    @classmethod
+    def _unit_categories(cls):
+        return super()._unit_categories() + ['product_secondary_uom_category']
+
+    @fields.depends('product')
+    def on_change_with_product_secondary_uom_category(self, name=None):
+        if self.product and self.product.purchase_secondary_uom:
+            return self.product.purchase_secondary_uom.category.id
+
     def compute_request(self):
         pool = Pool()
         Uom = pool.get('product.uom')

Reply via email to