diff --git a/issue10363.diff b/issue10363.diff new file mode 100644 index 0000000..21c1231 --- /dev/null +++ b/issue10363.diff @@ -0,0 +1,96 @@ +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 +@@ -1,6 +1,6 @@ + # This file is part of Tryton. The COPYRIGHT file at the top level of + # this repository contains the full copyright notices and license terms. +-from trytond.model import ModelView, ModelSQL, DeactivableMixin, fields, Unique ++from trytond.model import ModelView, ModelSQL, DeactivableMixin, fields + from trytond.wizard import Wizard, StateView, Button + from trytond.pyson import Eval + from trytond.pool import Pool +@@ -21,13 +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 + + @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. +- + + diff --git a/series b/series index 7f04424..e30e484 100644 --- a/series +++ b/series @@ -53,3 +53,5 @@ issue11051.diff # [account_invoice_defer] Add default company to invoice deferre issue11049.diff # [account_invoice_defer] Raise user error message for account not configured (only 6.0) issue11240.diff # [account_invoice] Can't reconcile by wizard in multicompany - patch pendent de core + +issue10363.diff # [production] Remove unique product constraint on BOM