diff --git a/custom_mrp_line_cost/data/mrp_standar_price_decimal_precision.xml b/custom_mrp_line_cost/data/mrp_standar_price_decimal_precision.xml index 575fb9931..9352548f6 100644 --- a/custom_mrp_line_cost/data/mrp_standar_price_decimal_precision.xml +++ b/custom_mrp_line_cost/data/mrp_standar_price_decimal_precision.xml @@ -1,4 +1,3 @@ - MRP Price Decimal Precision diff --git a/custom_mrp_line_cost/i18n/custom_mrp_line_cost.pot b/custom_mrp_line_cost/i18n/custom_mrp_line_cost.pot index 2a8352496..fe224bf41 100644 --- a/custom_mrp_line_cost/i18n/custom_mrp_line_cost.pot +++ b/custom_mrp_line_cost/i18n/custom_mrp_line_cost.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-02-20 11:29+0000\n" -"PO-Revision-Date: 2024-02-20 11:29+0000\n" +"POT-Creation-Date: 2024-07-02 06:20+0000\n" +"PO-Revision-Date: 2024-07-02 06:20+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -87,6 +87,16 @@ msgstr "" msgid "Canal Cost" msgstr "" +#. module: custom_mrp_line_cost +#: model:ir.model.fields,field_description:custom_mrp_line_cost.field_stock_move_line__clean_qty +msgid "Clean" +msgstr "" + +#. module: custom_mrp_line_cost +#: model:ir.model.fields,field_description:custom_mrp_line_cost.field_stock_move_line__clean_performance +msgid "Clean Performance" +msgstr "" + #. module: custom_mrp_line_cost #: model:ir.model.fields,field_description:custom_mrp_line_cost.field_mrp_bom_byproduct__coefficient msgid "Coefficient" @@ -156,6 +166,7 @@ msgstr "" #. module: custom_mrp_line_cost #: code:addons/custom_mrp_line_cost/models/mrp_production.py:0 +#: code:addons/custom_mrp_line_cost/models/mrp_production.py:0 #: model_terms:ir.ui.view,arch_db:custom_mrp_line_cost.mrp_production_form_view #: model_terms:ir.ui.view,arch_db:custom_mrp_line_cost.production_move_line_ids_tree_view #, python-format @@ -297,6 +308,7 @@ msgstr "" #. module: custom_mrp_line_cost #: code:addons/custom_mrp_line_cost/models/mrp_production.py:0 +#: code:addons/custom_mrp_line_cost/models/mrp_production.py:0 #: model_terms:ir.ui.view,arch_db:custom_mrp_line_cost.mrp_production_form_view #: model_terms:ir.ui.view,arch_db:custom_mrp_line_cost.production_finished_move_line_ids_tree_view #, python-format @@ -335,12 +347,6 @@ msgstr "" msgid "Price Difference" msgstr "" -#. module: custom_mrp_line_cost -#: code:addons/custom_mrp_line_cost/models/mrp_production.py:0 -#, python-format -msgid "Produced Move Lines" -msgstr "" - #. module: custom_mrp_line_cost #: model:ir.model,name:custom_mrp_line_cost.model_stock_move_line msgid "Product Moves (Stock Move Line)" @@ -377,6 +383,11 @@ msgstr "" msgid "Purchase Unit Price" msgstr "" +#. module: custom_mrp_line_cost +#: model_terms:ir.ui.view,arch_db:custom_mrp_line_cost.mrp_production_form_view +msgid "Recalculate Costs" +msgstr "" + #. module: custom_mrp_line_cost #: model_terms:ir.ui.view,arch_db:custom_mrp_line_cost.mrp_production_form_view msgid "Rto. %" diff --git a/custom_mrp_line_cost/i18n/es.po b/custom_mrp_line_cost/i18n/es.po index 2975aabd6..b3f86bd93 100644 --- a/custom_mrp_line_cost/i18n/es.po +++ b/custom_mrp_line_cost/i18n/es.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-02-20 11:30+0000\n" -"PO-Revision-Date: 2024-02-20 11:30+0000\n" +"POT-Creation-Date: 2024-07-02 06:21+0000\n" +"PO-Revision-Date: 2024-07-02 06:21+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -87,6 +87,16 @@ msgstr "Peso medio canal" msgid "Canal Cost" msgstr "Coste canal" +#. module: custom_mrp_line_cost +#: model:ir.model.fields,field_description:custom_mrp_line_cost.field_stock_move_line__clean_qty +msgid "Clean" +msgstr "Limpio" + +#. module: custom_mrp_line_cost +#: model:ir.model.fields,field_description:custom_mrp_line_cost.field_stock_move_line__clean_performance +msgid "Clean Performance" +msgstr "Rendimiento limpio" + #. module: custom_mrp_line_cost #: model:ir.model.fields,field_description:custom_mrp_line_cost.field_mrp_bom_byproduct__coefficient msgid "Coefficient" @@ -156,6 +166,7 @@ msgstr "Nombre mostrado" #. module: custom_mrp_line_cost #: code:addons/custom_mrp_line_cost/models/mrp_production.py:0 +#: code:addons/custom_mrp_line_cost/models/mrp_production.py:0 #: model_terms:ir.ui.view,arch_db:custom_mrp_line_cost.mrp_production_form_view #: model_terms:ir.ui.view,arch_db:custom_mrp_line_cost.production_move_line_ids_tree_view #, python-format @@ -297,6 +308,7 @@ msgstr "Importe total de salidas" #. module: custom_mrp_line_cost #: code:addons/custom_mrp_line_cost/models/mrp_production.py:0 +#: code:addons/custom_mrp_line_cost/models/mrp_production.py:0 #: model_terms:ir.ui.view,arch_db:custom_mrp_line_cost.mrp_production_form_view #: model_terms:ir.ui.view,arch_db:custom_mrp_line_cost.production_finished_move_line_ids_tree_view #, python-format @@ -335,12 +347,6 @@ msgstr "Albaranes por hacer" msgid "Price Difference" msgstr "Diferencia" -#. module: custom_mrp_line_cost -#: code:addons/custom_mrp_line_cost/models/mrp_production.py:0 -#, python-format -msgid "Produced Move Lines" -msgstr "Operaciones creadas" - #. module: custom_mrp_line_cost #: model:ir.model,name:custom_mrp_line_cost.model_stock_move_line msgid "Product Moves (Stock Move Line)" @@ -377,6 +383,11 @@ msgstr "Importe de compra" msgid "Purchase Unit Price" msgstr "Precio unitario" +#. module: custom_mrp_line_cost +#: model_terms:ir.ui.view,arch_db:custom_mrp_line_cost.mrp_production_form_view +msgid "Recalculate Costs" +msgstr "Recalcular costes" + #. module: custom_mrp_line_cost #: model_terms:ir.ui.view,arch_db:custom_mrp_line_cost.mrp_production_form_view msgid "Rto. %" diff --git a/custom_mrp_line_cost/models/killing_cost.py b/custom_mrp_line_cost/models/killing_cost.py index 86be13755..7bfdb66a1 100644 --- a/custom_mrp_line_cost/models/killing_cost.py +++ b/custom_mrp_line_cost/models/killing_cost.py @@ -7,55 +7,18 @@ class KillingCost(models.Model): _name = "killing.cost" _description = "Workcenter Cost" - workcenter_id = fields.Many2one( - string="Workcenter", - comodel_name="mrp.workcenter", - ) - january = fields.Float( - string="January", - digits="Killing Cost Decimal Precision", - ) - february = fields.Float( - string="February", - digits="Killing Cost Decimal Precision", - ) - march = fields.Float( - string="March", - digits="Killing Cost Decimal Precision", - ) - april = fields.Float( - string="April", - digits="Killing Cost Decimal Precision", - ) - may = fields.Float( - string="May", - digits="Killing Cost Decimal Precision", - ) - june = fields.Float( - string="June", - digits="Killing Cost Decimal Precision", - ) - july = fields.Float( - string="July", - digits="Killing Cost Decimal Precision", - ) - august = fields.Float( - string="August", - digits="Killing Cost Decimal Precision", - ) + workcenter_id = fields.Many2one(string="Workcenter", comodel_name="mrp.workcenter") + january = fields.Float(string="January", digits="Killing Cost Decimal Precision") + february = fields.Float(string="February", digits="Killing Cost Decimal Precision") + march = fields.Float(string="March", digits="Killing Cost Decimal Precision") + april = fields.Float(string="April", digits="Killing Cost Decimal Precision") + may = fields.Float(string="May", digits="Killing Cost Decimal Precision") + june = fields.Float(string="June", digits="Killing Cost Decimal Precision") + july = fields.Float(string="July", digits="Killing Cost Decimal Precision") + august = fields.Float(string="August", digits="Killing Cost Decimal Precision") september = fields.Float( - string="September", - digits="Killing Cost Decimal Precision", - ) - october = fields.Float( - string="October", - digits="Killing Cost Decimal Precision", - ) - november = fields.Float( - string="November", - digits="Killing Cost Decimal Precision", - ) - december = fields.Float( - string="December", - digits="Killing Cost Decimal Precision", + string="September", digits="Killing Cost Decimal Precision" ) + october = fields.Float(string="October", digits="Killing Cost Decimal Precision") + november = fields.Float(string="November", digits="Killing Cost Decimal Precision") + december = fields.Float(string="December", digits="Killing Cost Decimal Precision") diff --git a/custom_mrp_line_cost/models/mrp_bom.py b/custom_mrp_line_cost/models/mrp_bom.py index 9ed0cd7f3..bedca2616 100644 --- a/custom_mrp_line_cost/models/mrp_bom.py +++ b/custom_mrp_line_cost/models/mrp_bom.py @@ -7,14 +7,9 @@ class MrpBom(models.Model): _inherit = "mrp.bom" pallet_id = fields.Many2one( - string="Pallet", - comodel_name="product.product", - domain="[('palet', '=', True)]", - ) - packaging_id = fields.Many2one( - string="Packaging", - comodel_name="product.product", + string="Pallet", comodel_name="product.product", domain="[('palet', '=', True)]" ) + packaging_id = fields.Many2one(string="Packaging", comodel_name="product.product") @api.model def name_search(self, name="", args=None, operator="ilike", limit=100): diff --git a/custom_mrp_line_cost/models/mrp_production.py b/custom_mrp_line_cost/models/mrp_production.py index 11cfa193b..c23371350 100644 --- a/custom_mrp_line_cost/models/mrp_production.py +++ b/custom_mrp_line_cost/models/mrp_production.py @@ -20,9 +20,7 @@ class MrpProduction(models.Model): digits="Killing Cost Decimal Precision", ) rto_canal = fields.Float( - string="Rto. Canal", - compute="_compute_rto_canal", - store=True, + string="Rto. Canal", compute="_compute_rto_canal", store=True ) canal_cost = fields.Float( string="Canal Cost", @@ -69,19 +67,11 @@ class MrpProduction(models.Model): store=True, ) average_cost = fields.Float( - string="Averga Cost", - compute="_compute_average_cost", - store=True, - ) - cost = fields.Float( - string="Cost", - compute="_compute_cost", - store=True, + string="Averga Cost", compute="_compute_average_cost", store=True ) + cost = fields.Float(string="Cost", compute="_compute_cost", store=True) entry_total_amount = fields.Float( - string="Entry Total Amount", - compute="_compute_entry_total_amount", - store=True, + string="Entry Total Amount", compute="_compute_entry_total_amount", store=True ) output_total_amount = fields.Float(string="Output Total Amount") consume_qty = fields.Float( @@ -136,11 +126,11 @@ def _compute_average_cost(self): ): average_cost = sum( line.move_line_ids.filtered( - lambda c: c.location_id == line.location_src_id + lambda c: c.location_id == (line.location_src_id) ).mapped("amount") ) / sum( line.move_line_ids.filtered( - lambda c: c.location_id == line.location_src_id + lambda c: c.location_id == (line.location_src_id) ).mapped("qty_done") ) line.average_cost = average_cost @@ -263,8 +253,8 @@ def button_calculate_costs(self): production._compute_entry_total_amount() elif ( not production.is_deconstruction - and production.average_cost - and production.finished_move_line_ids + and (production.average_cost) + and (production.finished_move_line_ids) ): for line in production.finished_move_line_ids: line.applied_price = line.base_price diff --git a/custom_mrp_line_cost/models/stock_move_line.py b/custom_mrp_line_cost/models/stock_move_line.py index a54ab0b4a..dd6717f78 100644 --- a/custom_mrp_line_cost/models/stock_move_line.py +++ b/custom_mrp_line_cost/models/stock_move_line.py @@ -21,13 +21,9 @@ def _default_pallet_id(self): container = fields.Integer(string="Containers") unit = fields.Integer(string="Unit") product_unit_container = fields.Integer( - string="Product Unit/Container", - related="product_id.unit_container", - store=True, - ) - unit_container = fields.Float( - string="Unit/Container", + string="Product Unit/Container", related="product_id.unit_container", store=True ) + unit_container = fields.Float(string="Unit/Container") weight = fields.Float( string="Weight", compute="_compute_weight", @@ -47,29 +43,16 @@ def _default_pallet_id(self): store=True, ) applied_price = fields.Float( - string="Applied Price", - digits="MRP Price Decimal Precision", + string="Applied Price", digits="MRP Price Decimal Precision" ) expense_kg = fields.Boolean( - string="Cost/Kgm", - compute="_compute_expense_kg", - store=True, - ) - canal = fields.Boolean( - string="Canal", - related="product_id.canal", - store=True, - ) - brut = fields.Float( - string="Brut", - ) - pallet = fields.Integer( - string="Pallet Qty", + string="Cost/Kgm", compute="_compute_expense_kg", store=True ) + canal = fields.Boolean(string="Canal", related="product_id.canal", store=True) + brut = fields.Float(string="Brut") + pallet = fields.Integer(string="Pallet Qty") month_cost = fields.Float( - string="Month Cost", - compute="_compute_month_cost", - store=True, + string="Month Cost", compute="_compute_month_cost", store=True ) pallet_id = fields.Many2one( string="Pallet", @@ -77,6 +60,30 @@ def _default_pallet_id(self): default=_default_pallet_id, domain="[('palet', '=', True)]", ) + clean_qty = fields.Float( + string="Clean", + ) + clean_performance = fields.Float( + string="Clean Performance", compute="_compute_clean_performance", store=True + ) + + @api.depends( + "production_id", + "production_id.move_line_ids", + "production_id.move_line_ids.clean_qty", + "qty_done", + ) + def _compute_clean_performance(self): + for line in self: + clean_performance = 0 + if ( + line.production_id + and sum(line.production_id.move_line_ids.mapped("clean_qty")) != 0 + ): + clean_performance = line.qty_done / sum( + line.production_id.move_line_ids.mapped("clean_qty") + ) + line.clean_performance = clean_performance @api.depends( "production_id", @@ -105,8 +112,8 @@ def _compute_month_cost(self): if ( line.production_id.date_planned_start and line.move_id - and line.move_id.byproduct_id - and line.move_id.byproduct_id.operation_id + and (line.move_id.byproduct_id) + and (line.move_id.byproduct_id.operation_id) ): month = line.production_id.date_planned_start.month if month == 1: @@ -189,15 +196,15 @@ def _compute_base_price(self): else: if ( line.production_id - and line.move_id.bom_line_id - and line.production_id.is_deconstruction + and (line.move_id.bom_line_id) + and (line.production_id.is_deconstruction) ): cost = line.move_id.bom_line_id.cost if line.expense_kg: cost = ( line.production_id.month_cost - + line.production_id.purchase_unit_price - ) * line.move_id.bom_line_id.coefficient + + (line.production_id.purchase_unit_price) + ) * (line.move_id.bom_line_id.coefficient) elif line.production_id and line.move_id.byproduct_id: cost = line.move_id.byproduct_id.cost if line.expense_kg: @@ -213,9 +220,8 @@ def _compute_base_price(self): entry_cost = sum(entry_same_lots.mapped("amount")) / sum( entry_same_lots.mapped("qty_done") ) - cost = ( - line.month_cost - + entry_cost * line.move_id.byproduct_id.coefficient + cost = (line.month_cost + entry_cost) * ( + line.move_id.byproduct_id.coefficient ) line.base_price = cost if not line.applied_price: diff --git a/custom_mrp_line_cost/views/mrp_production_view.xml b/custom_mrp_line_cost/views/mrp_production_view.xml index 3b6d78534..4fb4c69fa 100644 --- a/custom_mrp_line_cost/views/mrp_production_view.xml +++ b/custom_mrp_line_cost/views/mrp_production_view.xml @@ -126,6 +126,13 @@ attrs="{'readonly': [('state', 'in', ('cancel', 'done'))]}" /> + + + + + + @@ -52,6 +56,8 @@ /> + + + +