From 664514567a1e501a353beb90137e7676e725a634 Mon Sep 17 00:00:00 2001 From: Raimon Esteve Date: Tue, 17 Oct 2023 16:36:51 +0200 Subject: [PATCH] Product Cost Plan Line rename products_tree to all_products 162382 --- locale/ca.po | 168 ++------------------------ locale/es.po | 170 ++------------------------- messages.xml | 3 + plan.py | 77 +++++++----- tests/scenario_product_cost_plan.rst | 23 ++-- view/cost_plan_form.xml | 2 +- 6 files changed, 83 insertions(+), 360 deletions(-) diff --git a/locale/ca.po b/locale/ca.po index 0baa253..1ee1753 100644 --- a/locale/ca.po +++ b/locale/ca.po @@ -2,9 +2,9 @@ msgid "" msgstr "Content-Type: text/plain; charset=utf-8\n" -msgctxt "field:product.cost.plan,active:" -msgid "Active" -msgstr "Actiu" +msgctxt "field:product.cost.plan,all_products:" +msgid "All Products" +msgstr "Tots els productes" msgctxt "field:product.cost.plan,bom:" msgid "BOM" @@ -22,18 +22,6 @@ msgctxt "field:product.cost.plan,costs:" msgid "Costs" msgstr "Costos" -msgctxt "field:product.cost.plan,create_date:" -msgid "Create Date" -msgstr "Data de creació" - -msgctxt "field:product.cost.plan,create_uid:" -msgid "Create User" -msgstr "Usuari de creació" - -msgctxt "field:product.cost.plan,id:" -msgid "ID" -msgstr "ID" - msgctxt "field:product.cost.plan,name:" msgid "Name" msgstr "Nom" @@ -66,18 +54,10 @@ msgctxt "field:product.cost.plan,products_cost:" msgid "Products Cost" msgstr "Cost dels materials" -msgctxt "field:product.cost.plan,products_tree:" -msgid "Products" -msgstr "Productes" - msgctxt "field:product.cost.plan,quantity:" msgid "Quantity" msgstr "Quantitat" -msgctxt "field:product.cost.plan,rec_name:" -msgid "Record Name" -msgstr "Nom del registre" - msgctxt "field:product.cost.plan,uom:" msgid "UoM" msgstr "UdM" @@ -86,30 +66,10 @@ msgctxt "field:product.cost.plan,uom_digits:" msgid "UoM Digits" msgstr "Digits UdM" -msgctxt "field:product.cost.plan,write_date:" -msgid "Write Date" -msgstr "Data de modificació" - -msgctxt "field:product.cost.plan,write_uid:" -msgid "Write User" -msgstr "Usuari de modificació" - msgctxt "field:product.cost.plan.bom_line,bom:" msgid "BOM" msgstr "Llista de materials" -msgctxt "field:product.cost.plan.bom_line,create_date:" -msgid "Create Date" -msgstr "Data de creació" - -msgctxt "field:product.cost.plan.bom_line,create_uid:" -msgid "Create User" -msgstr "Usuari de creació" - -msgctxt "field:product.cost.plan.bom_line,id:" -msgid "ID" -msgstr "ID" - msgctxt "field:product.cost.plan.bom_line,plan:" msgid "Plan" msgstr "Pla" @@ -118,34 +78,10 @@ msgctxt "field:product.cost.plan.bom_line,product:" msgid "Product" msgstr "Producte" -msgctxt "field:product.cost.plan.bom_line,rec_name:" -msgid "Record Name" -msgstr "Nom del registre" - -msgctxt "field:product.cost.plan.bom_line,write_date:" -msgid "Write Date" -msgstr "Data de modificació" - -msgctxt "field:product.cost.plan.bom_line,write_uid:" -msgid "Write User" -msgstr "Usuari de modificació" - msgctxt "field:product.cost.plan.cost,cost:" msgid "Cost" msgstr "Cost" -msgctxt "field:product.cost.plan.cost,create_date:" -msgid "Create Date" -msgstr "Data de creació" - -msgctxt "field:product.cost.plan.cost,create_uid:" -msgid "Create User" -msgstr "Usuari de creació" - -msgctxt "field:product.cost.plan.cost,id:" -msgid "ID" -msgstr "ID" - msgctxt "field:product.cost.plan.cost,internal_cost:" msgid "Cost (Internal Use)" msgstr "Cost (ús intern)" @@ -154,10 +90,6 @@ msgctxt "field:product.cost.plan.cost,plan:" msgid "Plan" msgstr "Pla" -msgctxt "field:product.cost.plan.cost,rec_name:" -msgid "Record Name" -msgstr "Nom del registre" - msgctxt "field:product.cost.plan.cost,sequence:" msgid "Sequence" msgstr "Seqüència" @@ -170,26 +102,6 @@ msgctxt "field:product.cost.plan.cost,type:" msgid "Type" msgstr "Tipus" -msgctxt "field:product.cost.plan.cost,write_date:" -msgid "Write Date" -msgstr "Data de modificació" - -msgctxt "field:product.cost.plan.cost,write_uid:" -msgid "Write User" -msgstr "Usuari de modificació" - -msgctxt "field:product.cost.plan.cost.type,create_date:" -msgid "Create Date" -msgstr "Data de creació" - -msgctxt "field:product.cost.plan.cost.type,create_uid:" -msgid "Create User" -msgstr "Usuari de creació" - -msgctxt "field:product.cost.plan.cost.type,id:" -msgid "ID" -msgstr "ID" - msgctxt "field:product.cost.plan.cost.type,name:" msgid "Name" msgstr "Nom" @@ -198,26 +110,10 @@ msgctxt "field:product.cost.plan.cost.type,plan_field_name:" msgid "Plan Field Name" msgstr "Nom camp del pla" -msgctxt "field:product.cost.plan.cost.type,rec_name:" -msgid "Record Name" -msgstr "Nom del registre" - msgctxt "field:product.cost.plan.cost.type,system:" msgid "System Managed" msgstr "Gestionat pel sistema" -msgctxt "field:product.cost.plan.cost.type,write_date:" -msgid "Write Date" -msgstr "Data de modificació" - -msgctxt "field:product.cost.plan.cost.type,write_uid:" -msgid "Write User" -msgstr "Usuari de modificació" - -msgctxt "field:product.cost.plan.create_bom.start,id:" -msgid "ID" -msgstr "ID" - msgctxt "field:product.cost.plan.create_bom.start,name:" msgid "Name" msgstr "Nom" @@ -230,18 +126,6 @@ msgctxt "field:product.cost.plan.product_line,cost_price:" msgid "Cost Price" msgstr "Preu de cost" -msgctxt "field:product.cost.plan.product_line,create_date:" -msgid "Create Date" -msgstr "Data de creació" - -msgctxt "field:product.cost.plan.product_line,create_uid:" -msgid "Create User" -msgstr "Usuari de creació" - -msgctxt "field:product.cost.plan.product_line,id:" -msgid "ID" -msgstr "ID" - msgctxt "field:product.cost.plan.product_line,name:" msgid "Name" msgstr "Nom" @@ -270,10 +154,6 @@ msgctxt "field:product.cost.plan.product_line,quantity:" msgid "Quantity" msgstr "Quantitat" -msgctxt "field:product.cost.plan.product_line,rec_name:" -msgid "Record Name" -msgstr "Nom del registre" - msgctxt "field:product.cost.plan.product_line,sequence:" msgid "Sequence" msgstr "Seqüència" @@ -298,14 +178,6 @@ msgctxt "field:product.cost.plan.product_line,uom_digits:" msgid "UoM Digits" msgstr "Digits UdM" -msgctxt "field:product.cost.plan.product_line,write_date:" -msgid "Write Date" -msgstr "Data de modificació" - -msgctxt "field:product.cost.plan.product_line,write_uid:" -msgid "Write User" -msgstr "Usuari de modificació" - msgctxt "field:production.configuration,product_cost_plan_sequence:" msgid "Product Cost Plan Sequence" msgstr "Seqüencia pla de costsos de producte" @@ -314,34 +186,10 @@ msgctxt "field:production.configuration.cost_plan,company:" msgid "Company" msgstr "Empresa" -msgctxt "field:production.configuration.cost_plan,create_date:" -msgid "Create Date" -msgstr "Data de creació" - -msgctxt "field:production.configuration.cost_plan,create_uid:" -msgid "Create User" -msgstr "Usuari de creació" - -msgctxt "field:production.configuration.cost_plan,id:" -msgid "ID" -msgstr "ID" - msgctxt "field:production.configuration.cost_plan,product_cost_plan_sequence:" msgid "Product Cost Plan Sequence" msgstr "Seqüencia pla de costsos de producte" -msgctxt "field:production.configuration.cost_plan,rec_name:" -msgid "Record Name" -msgstr "Nom del registre" - -msgctxt "field:production.configuration.cost_plan,write_date:" -msgid "Write Date" -msgstr "Data de modificació" - -msgctxt "field:production.configuration.cost_plan,write_uid:" -msgid "Write User" -msgstr "Usuari de modificació" - msgctxt "help:product.cost.plan.product_line,party_stock:" msgid "Use stock owned by party instead of company stock." msgstr "" @@ -396,6 +244,12 @@ msgctxt "model:ir.message,text:lacks_the_product" msgid "The Cost Plan \"%(cost_plan)s\" lacks the product." msgstr "El pla de costos \"%(cost_plan)s\" no té producte." +msgctxt "model:ir.message,text:msg_product_line_plan_parent" +msgid "The line \"%(line)s\" can only set plan or parent, not both options." +msgstr "" +"La línia \"%(line)s\" només es pot relacionar amb un pla de cost o un pare, " +"no les dues opcions." + msgctxt "model:ir.message,text:product_already_has_bom" msgid "Product \"%(product)s\" already has a BOM assigned." msgstr "El producte \"%(product)s\" ja té una llista de materials assignada." @@ -492,10 +346,6 @@ msgctxt "view:product.cost.plan:" msgid "Costs" msgstr "Costos" -msgctxt "view:product.cost.plan:" -msgid "Initialize Cost Plan" -msgstr "Inicialitza el pla de costos" - msgctxt "view:product.cost.plan:" msgid "" "It will modify the product's field loosing the current value. Are you sure?" diff --git a/locale/es.po b/locale/es.po index 86d8f7f..fd20d06 100644 --- a/locale/es.po +++ b/locale/es.po @@ -2,9 +2,9 @@ msgid "" msgstr "Content-Type: text/plain; charset=utf-8\n" -msgctxt "field:product.cost.plan,active:" -msgid "Active" -msgstr "Activo" +msgctxt "field:product.cost.plan,all_products:" +msgid "All Products" +msgstr "Todos los productos" msgctxt "field:product.cost.plan,bom:" msgid "BOM" @@ -22,18 +22,6 @@ msgctxt "field:product.cost.plan,costs:" msgid "Costs" msgstr "Costes" -msgctxt "field:product.cost.plan,create_date:" -msgid "Create Date" -msgstr "Fecha de creación" - -msgctxt "field:product.cost.plan,create_uid:" -msgid "Create User" -msgstr "Usuario de creación" - -msgctxt "field:product.cost.plan,id:" -msgid "ID" -msgstr "ID" - msgctxt "field:product.cost.plan,name:" msgid "Name" msgstr "Nombre" @@ -66,18 +54,10 @@ msgctxt "field:product.cost.plan,products_cost:" msgid "Products Cost" msgstr "Coste materiales" -msgctxt "field:product.cost.plan,products_tree:" -msgid "Products" -msgstr "Productos" - msgctxt "field:product.cost.plan,quantity:" msgid "Quantity" msgstr "Cantidad" -msgctxt "field:product.cost.plan,rec_name:" -msgid "Record Name" -msgstr "Nombre del registro" - msgctxt "field:product.cost.plan,uom:" msgid "UoM" msgstr "UdM" @@ -86,30 +66,10 @@ msgctxt "field:product.cost.plan,uom_digits:" msgid "UoM Digits" msgstr "Dígitos UdM" -msgctxt "field:product.cost.plan,write_date:" -msgid "Write Date" -msgstr "Fecha de modificación" - -msgctxt "field:product.cost.plan,write_uid:" -msgid "Write User" -msgstr "Usuario de modificación" - msgctxt "field:product.cost.plan.bom_line,bom:" msgid "BOM" msgstr "Lista de material" -msgctxt "field:product.cost.plan.bom_line,create_date:" -msgid "Create Date" -msgstr "Fecha de creación" - -msgctxt "field:product.cost.plan.bom_line,create_uid:" -msgid "Create User" -msgstr "Usuario de creación" - -msgctxt "field:product.cost.plan.bom_line,id:" -msgid "ID" -msgstr "ID" - msgctxt "field:product.cost.plan.bom_line,plan:" msgid "Plan" msgstr "Plan" @@ -118,34 +78,10 @@ msgctxt "field:product.cost.plan.bom_line,product:" msgid "Product" msgstr "Producto" -msgctxt "field:product.cost.plan.bom_line,rec_name:" -msgid "Record Name" -msgstr "Nombre del registro" - -msgctxt "field:product.cost.plan.bom_line,write_date:" -msgid "Write Date" -msgstr "Fecha de modificación" - -msgctxt "field:product.cost.plan.bom_line,write_uid:" -msgid "Write User" -msgstr "Usuario de modificación" - msgctxt "field:product.cost.plan.cost,cost:" msgid "Cost" msgstr "Coste" -msgctxt "field:product.cost.plan.cost,create_date:" -msgid "Create Date" -msgstr "Fecha de creación" - -msgctxt "field:product.cost.plan.cost,create_uid:" -msgid "Create User" -msgstr "Usuario de creación" - -msgctxt "field:product.cost.plan.cost,id:" -msgid "ID" -msgstr "ID" - msgctxt "field:product.cost.plan.cost,internal_cost:" msgid "Cost (Internal Use)" msgstr "Coste (uso interno)" @@ -154,10 +90,6 @@ msgctxt "field:product.cost.plan.cost,plan:" msgid "Plan" msgstr "Plan" -msgctxt "field:product.cost.plan.cost,rec_name:" -msgid "Record Name" -msgstr "Nombre del registro" - msgctxt "field:product.cost.plan.cost,sequence:" msgid "Sequence" msgstr "Secuencia" @@ -170,26 +102,6 @@ msgctxt "field:product.cost.plan.cost,type:" msgid "Type" msgstr "Tipo" -msgctxt "field:product.cost.plan.cost,write_date:" -msgid "Write Date" -msgstr "Fecha de modificación" - -msgctxt "field:product.cost.plan.cost,write_uid:" -msgid "Write User" -msgstr "Usuario de modificación" - -msgctxt "field:product.cost.plan.cost.type,create_date:" -msgid "Create Date" -msgstr "Fecha de creación" - -msgctxt "field:product.cost.plan.cost.type,create_uid:" -msgid "Create User" -msgstr "Usuario de creación" - -msgctxt "field:product.cost.plan.cost.type,id:" -msgid "ID" -msgstr "ID" - msgctxt "field:product.cost.plan.cost.type,name:" msgid "Name" msgstr "Nombre" @@ -198,26 +110,10 @@ msgctxt "field:product.cost.plan.cost.type,plan_field_name:" msgid "Plan Field Name" msgstr "Nombre campo del plan" -msgctxt "field:product.cost.plan.cost.type,rec_name:" -msgid "Record Name" -msgstr "Nombre del registro" - msgctxt "field:product.cost.plan.cost.type,system:" msgid "System Managed" msgstr "Gestinado por el sistema" -msgctxt "field:product.cost.plan.cost.type,write_date:" -msgid "Write Date" -msgstr "Fecha de modificación" - -msgctxt "field:product.cost.plan.cost.type,write_uid:" -msgid "Write User" -msgstr "Usuario de modificación" - -msgctxt "field:product.cost.plan.create_bom.start,id:" -msgid "ID" -msgstr "ID" - msgctxt "field:product.cost.plan.create_bom.start,name:" msgid "Name" msgstr "Nombre" @@ -230,18 +126,6 @@ msgctxt "field:product.cost.plan.product_line,cost_price:" msgid "Cost Price" msgstr "Precio de coste" -msgctxt "field:product.cost.plan.product_line,create_date:" -msgid "Create Date" -msgstr "Fecha de creación" - -msgctxt "field:product.cost.plan.product_line,create_uid:" -msgid "Create User" -msgstr "Usuario de creación" - -msgctxt "field:product.cost.plan.product_line,id:" -msgid "ID" -msgstr "ID" - msgctxt "field:product.cost.plan.product_line,name:" msgid "Name" msgstr "Nombre" @@ -270,10 +154,6 @@ msgctxt "field:product.cost.plan.product_line,quantity:" msgid "Quantity" msgstr "Cantidad" -msgctxt "field:product.cost.plan.product_line,rec_name:" -msgid "Record Name" -msgstr "Nombre del registro" - msgctxt "field:product.cost.plan.product_line,sequence:" msgid "Sequence" msgstr "Secuencia" @@ -298,14 +178,6 @@ msgctxt "field:product.cost.plan.product_line,uom_digits:" msgid "UoM Digits" msgstr "Dígitos UdM" -msgctxt "field:product.cost.plan.product_line,write_date:" -msgid "Write Date" -msgstr "Fecha de modificación" - -msgctxt "field:product.cost.plan.product_line,write_uid:" -msgid "Write User" -msgstr "Usuario de modificación" - msgctxt "field:production.configuration,product_cost_plan_sequence:" msgid "Product Cost Plan Sequence" msgstr "Sequencia plan de coste del producto" @@ -314,34 +186,10 @@ msgctxt "field:production.configuration.cost_plan,company:" msgid "Company" msgstr "Empresa" -msgctxt "field:production.configuration.cost_plan,create_date:" -msgid "Create Date" -msgstr "Fecha de creación" - -msgctxt "field:production.configuration.cost_plan,create_uid:" -msgid "Create User" -msgstr "Usuario de creación" - -msgctxt "field:production.configuration.cost_plan,id:" -msgid "ID" -msgstr "ID" - msgctxt "field:production.configuration.cost_plan,product_cost_plan_sequence:" msgid "Product Cost Plan Sequence" msgstr "Sequencia plan de coste del producto" -msgctxt "field:production.configuration.cost_plan,rec_name:" -msgid "Record Name" -msgstr "Nombre del registro" - -msgctxt "field:production.configuration.cost_plan,write_date:" -msgid "Write Date" -msgstr "Fecha de modificación" - -msgctxt "field:production.configuration.cost_plan,write_uid:" -msgid "Write User" -msgstr "Usuario de modificación" - msgctxt "help:product.cost.plan.product_line,party_stock:" msgid "Use stock owned by party instead of company stock." msgstr "" @@ -396,6 +244,14 @@ msgctxt "model:ir.message,text:lacks_the_product" msgid "The Cost Plan \"%(cost_plan)s\" lacks the product." msgstr "El plan de costes \"%(cost_plan)s\" carece de producto." +msgctxt "model:ir.message,text:msg_product_line_plan_parent" +msgid "" +"The line \"%(line)s\" can only set plan or parent in each line, not both " +"options." +msgstr "" +"La línea \"%(line)s\" sólo se puede relacionar con un plan de coste o un " +"padre, no las dos opciones." + msgctxt "model:ir.message,text:product_already_has_bom" msgid "Product \"%(product)s\" already has a BOM assigned." msgstr "El producto \"%(product)s\" ya tiene una lista de materiales asignada." @@ -492,10 +348,6 @@ msgctxt "view:product.cost.plan:" msgid "Costs" msgstr "Costes" -msgctxt "view:product.cost.plan:" -msgid "Initialize Cost Plan" -msgstr "Inicializar el plan de costes" - msgctxt "view:product.cost.plan:" msgid "" "It will modify the product's field loosing the current value. Are you sure?" diff --git a/messages.xml b/messages.xml index eed5db8..b0fb86d 100644 --- a/messages.xml +++ b/messages.xml @@ -18,5 +18,8 @@ this repository contains the full copyright notices and license terms. --> You can not delete cost "%(cost)s" from plan "%(plan)s" because it's managed by system. + + The line "%(line)s" can only set plan or parent, not both options. + diff --git a/plan.py b/plan.py index a3cd20b..3bfd2b1 100644 --- a/plan.py +++ b/plan.py @@ -1,7 +1,8 @@ # The COPYRIGHT file at the top level of this repository contains the full # copyright notices and license terms. from decimal import Decimal -from trytond.model import ModelSQL, ModelView, DeactivableMixin, fields, tree +# from sql import Null +from trytond.model import Check, ModelSQL, ModelView, DeactivableMixin, fields, tree from trytond.pool import Pool from trytond.pyson import Eval, Bool, If from trytond.transaction import Transaction @@ -9,6 +10,7 @@ from trytond.wizard import Wizard, StateView, StateAction, Button from trytond.i18n import gettext from trytond.exceptions import UserWarning from trytond.modules.product import price_digits, round_price +from trytond.exceptions import UserError __all__ = ['PlanCostType', 'Plan', 'PlanBOM', 'PlanProductLine', 'PlanCost', 'CreateBomStart', 'CreateBom'] @@ -51,16 +53,8 @@ class Plan(DeactivableMixin, ModelSQL, ModelView): boms = fields.One2Many('product.cost.plan.bom_line', 'plan', 'BOMs') products = fields.One2Many('product.cost.plan.product_line', 'plan', 'Products') - products_tree = fields.Function( - fields.One2Many('product.cost.plan.product_line', 'plan', 'Products', - domain=[ - ('parent', '=', None), - ], - states={ - 'readonly': ~Bool(Eval('costs', [0])), - }, - depends=['costs']), - 'get_products_tree', setter='set_products_tree') + all_products = fields.Function(fields.One2Many( + 'product.cost.plan.product_line', None, 'All Products'), 'get_all_products') products_cost = fields.Function(fields.Numeric('Products Cost', digits=price_digits), 'get_products_cost') @@ -163,14 +157,19 @@ class Plan(DeactivableMixin, ModelSQL, ModelView): )) return res - def get_products_tree(self, name): - return [x.id for x in self.products if not x.parent] + def get_all_products(self, name): + # return all lines in product cost plan (parent and children) + product_lines = [] - @classmethod - def set_products_tree(cls, lines, name, value): - cls.write(lines, { - 'products': value, - }) + def _get_children(line): + product_lines.append(line) + for child in line.children: + _get_children(child) + + for line in self.products: + _get_children(line) + + return [x.id for x in product_lines] def get_products_cost(self, name): if not self.quantity: @@ -455,11 +454,25 @@ class Plan(DeactivableMixin, ModelSQL, ModelView): def _copy_plan(self, default): ProductLine = Pool().get('product.cost.plan.product_line') + product_lines = [] + + def _get_children(line): + product_lines.append(line) + for child in line.children: + _get_children(child) + new_plan, = super(Plan, self).copy([self], default=default) - ProductLine.copy(self.products_tree, default={ + lines = ProductLine.copy(self.products, default={ 'plan': new_plan.id, - 'children': None, }) + + # sure product.cost_plan.product_line that has parent, set null the plan + for line in lines: + for child in line.children: + _get_children(child) + + ProductLine.write(product_lines, {'plan': None}) + return new_plan @classmethod @@ -494,8 +507,7 @@ class PlanProductLine(ModelSQL, ModelView, tree(separator='/')): parent = fields.Many2One('product.cost.plan.product_line', 'Parent') children = fields.One2Many('product.cost.plan.product_line', 'parent', 'Children') - plan = fields.Many2One('product.cost.plan', 'Plan', required=False, - ondelete='CASCADE') + plan = fields.Many2One('product.cost.plan', 'Plan', ondelete='CASCADE') product = fields.Many2One('product.product', 'Product', domain=[ ('type', '!=', 'service'), If(Bool(Eval('children')), @@ -561,15 +573,14 @@ class PlanProductLine(ModelSQL, ModelView, tree(separator='/')): self.uom = None self.product_cost_price = None - @fields.depends('children', '_parent_plan.uom', 'product', 'uom', 'plan') + @fields.depends('children', 'product', 'plan', '_parent_plan.uom') def on_change_with_uom_category(self, name=None): - if self.children: - # If product line has children, it must be have computable - # quantities of plan product - if self.plan and self.plan.uom: - return self.plan.uom.category.id - if self.product: + if self.children and self.children[0].uom: + return self.children[0].uom.category.id + elif self.product: return self.product.default_uom.category.id + elif self.plan and self.plan.uom: + return self.plan.uom.category.id @fields.depends('uom') def on_change_with_uom_digits(self, name=None): @@ -665,6 +676,14 @@ class PlanProductLine(ModelSQL, ModelView, tree(separator='/')): cls.copy(line.children, default=new_default) return new_lines + @classmethod + def validate(cls, lines): + super().validate(lines) + for line in lines: + if ((line.parent and line.plan) or (not line.parent and not line.plan)): + raise UserError(gettext( + 'product_cost_plan.msg_product_line_plan_parent', + line=line.rec_name)) STATES = { 'readonly': Eval('system', False), diff --git a/tests/scenario_product_cost_plan.rst b/tests/scenario_product_cost_plan.rst index 15d8606..96e7fc3 100644 --- a/tests/scenario_product_cost_plan.rst +++ b/tests/scenario_product_cost_plan.rst @@ -97,7 +97,7 @@ Create Components:: >>> template1 = ProductTemplate() >>> template1.name = 'component 1' - >>> template1.default_uom = unit + >>> template1.default_uom = meter >>> template1.producible = True >>> template1.type = 'goods' >>> template1.list_price = Decimal(5) @@ -139,7 +139,7 @@ Create Bill of Material:: >>> input1 = bom.inputs.new() >>> input1.product = component1 >>> input1.quantity = 5 - >>> input2 = bom.inputs.new() + >>> input2 = bom.inputs.new() >>> input2.product = component2 >>> input2.quantity = 150 >>> input2.unit = centimeter @@ -249,7 +249,7 @@ Create BoM from cost plan:: 2 >>> sorted([(i.quantity, i.product.rec_name, i.unit.symbol) ... for i in plan2.bom.inputs]) - [(5.0, 'component 1', 'u'), (150.0, 'component 2', 'cm')] + [(5.0, 'component 1', 'm'), (150.0, 'component 2', 'cm')] >>> len(plan2.bom.outputs) 1 >>> plan2.bom.outputs[0].product == product2 @@ -273,15 +273,14 @@ Create plan from scratch:: 0 >>> len(plan3.costs) 1 - >>> product_line = plan3.products_tree.new() + >>> product_line = plan3.products.new() >>> product_line.product = component1 >>> product_line.cost_price == Decimal('2') True >>> product_line.quantity = 14 >>> product_line.uom.symbol - 'u' + 'm' >>> product_line2 = product_line.children.new() - >>> product_line2.plan = plan3 >>> product_line2.product = component2 >>> product_line2.cost_price == Decimal('5') True @@ -295,11 +294,11 @@ Create plan from scratch:: >>> product_line2.uom.symbol 'cm' >>> plan3.save() - >>> product_line, = plan3.products_tree - >>> product_line.unit_cost == Decimal('14') - True - >>> product_line.total_cost == Decimal('28') - True + >>> product_line, = plan3.products + >>> product_line.unit_cost + Decimal('14.0000') + >>> product_line.total_cost + Decimal('28.0000') >>> product_line2, = product_line.children >>> product_line2.unit_cost == Decimal('1.26') True @@ -325,7 +324,7 @@ Create BoM from Cost Plan:: 2 >>> sorted([(i.quantity, i.product.rec_name, i.unit.symbol) ... for i in plan3.bom.inputs]) - [(14.0, 'component 1', 'u'), (56.0, 'component 2', 'cm')] + [(14.0, 'component 1', 'm'), (56.0, 'component 2', 'cm')] >>> len(plan3.bom.outputs) 1 >>> plan3.bom.outputs[0].product == product3 diff --git a/view/cost_plan_form.xml b/view/cost_plan_form.xml index f00ff8c..5e7d775 100644 --- a/view/cost_plan_form.xml +++ b/view/cost_plan_form.xml @@ -20,7 +20,7 @@