diff --git a/unit_load.py b/unit_load.py index 87609c5..dae7db9 100644 --- a/unit_load.py +++ b/unit_load.py @@ -213,7 +213,7 @@ class UnitLoad(ModelSQL, ModelView): currency_digits = fields.Function(fields.Integer('Currency Digits'), 'get_currency_digits') pallet_product = fields.Function(fields.Many2One('product.product', - 'Pallet Product'), 'get_pallet_product') + 'Pallet Product'), 'on_change_with_pallet_product') case_product = fields.Function(fields.Many2One('product.product', 'Case Product'), 'get_case_product') _product_category_cache = Cache('stock.unit_load.product_category_cache', @@ -1169,11 +1169,13 @@ class UnitLoad(ModelSQL, ModelView): return product and product.id - def get_pallet_product(self, name=None): + @fields.depends(methods=['_get_product_by_category']) + def on_change_with_pallet_product(self, name=None): product = self._get_product_by_category('pallet_category') return product and product.id + @fields.depends('production_moves', 'production_moves') def _get_product_by_category(self, category_name): pool = Pool() Category = pool.get('product.category') @@ -1409,11 +1411,13 @@ class UnitLoad(ModelSQL, ModelView): return [m for m in self.production_moves if m.to_location.type == 'production'] - @fields.depends('product', methods=['explode_production_moves']) + @fields.depends('product', methods=['explode_production_moves', + 'on_change_with_pallet_product']) def on_change_product(self): if self.product: self.uom = self.product.default_uom self.uom_category = self.uom.category + self.pallet_product = self.on_change_with_pallet_product() self.explode_production_moves() @fields.depends(methods=['get_quantity_per_case',