Change get_pallet_product for on_change_with_pallet_product

This commit refs #25023
This commit is contained in:
ramon.vidal 2022-12-12 13:55:30 +01:00 committed by Nicolás López Solano
parent 0017d8d994
commit 64c936ca62
1 changed files with 7 additions and 3 deletions

View File

@ -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',