diff --git a/trytond/trytond/modules/production/bom.py b/trytond/trytond/modules/production/bom.py index dc3faeb..3f9c369 100644 --- a/trytond/trytond/modules/production/bom.py +++ b/trytond/trytond/modules/production/bom.py @@ -21,15 +21,15 @@ class BOM(DeactivableMixin, ModelSQL, ModelView): Compute factor for an output product ''' Uom = Pool().get('product.uom') + output_quantity = 0 for output in self.outputs: if output.product == product: - if not output.quantity: - return 0.0 - quantity = Uom.compute_qty(uom, quantity, - output.uom, round=False) - return quantity / output.quantity + output_quantity += Uom.compute_qty( + output.uom, output.quantity, uom, round=False) + if output_quantity: + return quantity / output_quantity else: - return 0.0 + return 0 @classmethod def copy(cls, records, default=None): @@ -67,11 +69,14 @@ class BOMInput(ModelSQL, ModelView): super(BOMInput, cls).__setup__() cls.product.domain = [('type', 'in', cls.get_product_types())] cls.__access__.add('bom') - t = cls.__table__() - cls._sql_constraints = [ - ('product_bom_uniq', Unique(t, t.product, t.bom), - 'production.msg_product_bom_unique'), - ] + + @classmethod + def __register__(cls, module): + super().__register__(module) + table_h = cls.__table_handler__(module) + + # Migration from 6.0: remove unique constraint + table_h.drop_constraint('product_bom_uniq') @classmethod def get_product_types(cls): diff --git a/trytond/trytond/modules/production/locale/ca.po b/trytond/trytond/modules/production/locale/ca.po index 1b5da12..b45e93c 100644 --- a/trytond/trytond/modules/production/locale/ca.po +++ b/trytond/trytond/modules/production/locale/ca.po @@ -376,10 +376,6 @@ msgctxt "" msgid "Waiting" msgstr "En espera" -msgctxt "model:ir.message,text:msg_product_bom_unique" -msgid "Products can only appear once on each BOM." -msgstr "Un producte només pot aparèixer una vegada a cada LdM." - msgctxt "model:ir.message,text:msg_recursive_bom" msgid "You cannot create a recursive BOM for product \"%(product)s\"." msgstr "No podeu crear una LdM recursiva pel producte \"%(product)s\"." diff --git a/trytond/trytond/modules/production/locale/es.po b/trytond/trytond/modules/production/locale/es.po index 7cbd0a9..923fa40 100644 --- a/trytond/trytond/modules/production/locale/es.po +++ b/trytond/trytond/modules/production/locale/es.po @@ -376,10 +376,6 @@ msgctxt "" msgid "Waiting" msgstr "En espera" -msgctxt "model:ir.message,text:msg_product_bom_unique" -msgid "Products can only appear once on each BOM." -msgstr "Los productos solo pueden aparecer una vez en cada LdM." - msgctxt "model:ir.message,text:msg_recursive_bom" msgid "You cannot create a recursive BOM for product \"%(product)s\"." msgstr "No puede crear una LdM recursiva para el producto \"%(product)s\"." diff --git a/trytond/trytond/modules/production/message.xml b/trytond/trytond/modules/production/message.xml index f97efb1..b12c6e4 100644 --- a/trytond/trytond/modules/production/message.xml +++ b/trytond/trytond/modules/production/message.xml @@ -6,8 +6,5 @@ this repository contains the full copyright notices and license terms. --> You cannot create a recursive BOM for product "%(product)s". - - Products can only appear once on each BOM. -