diff --git a/mrp_bom_product_price_margin/README.rst b/mrp_bom_product_price_margin/README.rst new file mode 100644 index 000000000..2a320e5a7 --- /dev/null +++ b/mrp_bom_product_price_margin/README.rst @@ -0,0 +1,93 @@ +============================ +MRP BoM Product Price Margin +============================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:aa37e05e4d2c66e364b2d427982b676b8f8dab4171dca239ab8a992ae5eeae62 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github + :target: https://github.com/OCA/manufacture/tree/16.0/mrp_bom_product_price_margin + :alt: OCA/manufacture +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_bom_product_price_margin + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/manufacture&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Help handling cost and sale price of product variant linked to bill of material. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Set Product Variant in your Bill of Material. +Change BoM quantity or BoM lines quantity or price in one component. +See new panel to change Product Variant Standard Price. + + .. figure:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_diff.png + + .. figure:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_no_diff.png + +In tree view, quickly see difference between Product standard price and BoM cost. +You can also change Product standard price here +Lines are red when Sale margin in negative. + +.. figure:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_tree.png + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* GRAP + +Contributors +~~~~~~~~~~~~ + +* Quentin Dupont (quentin.dupont@grap.coop) + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/manufacture `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mrp_bom_product_price_margin/__init__.py b/mrp_bom_product_price_margin/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/mrp_bom_product_price_margin/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mrp_bom_product_price_margin/__manifest__.py b/mrp_bom_product_price_margin/__manifest__.py new file mode 100644 index 000000000..569013fa2 --- /dev/null +++ b/mrp_bom_product_price_margin/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright (C) 2022 - Today: GRAP (http://www.grap.coop) +# @author: Quentin Dupont (quentin.dupont@grap.coop) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "MRP BoM Product Price Margin", + "summary": "Handle Product Standard, Sale Price and Margin with its BoM cost", + "version": "16.0.1.0.0", + "category": "GRAP - Custom", + "author": "GRAP, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/manufacture", + "license": "AGPL-3", + "depends": [ + "mrp", + # OCA modules + "product_standard_margin", + ], + "data": [ + "views/view_mrp_bom.xml", + ], + "installable": True, +} diff --git a/mrp_bom_product_price_margin/i18n/fr.po b/mrp_bom_product_price_margin/i18n/fr.po new file mode 100644 index 000000000..e8c614bb0 --- /dev/null +++ b/mrp_bom_product_price_margin/i18n/fr.po @@ -0,0 +1,206 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_bom_product_price_margin +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-03-11 15:59+0000\n" +"PO-Revision-Date: 2024-03-11 15:59+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: mrp_bom_product_price_margin +#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_sale_product_margin_form +msgid " (for 1x" +msgstr " (pour 1x" + +#. module: mrp_bom_product_price_margin +#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_sale_product_margin_form +msgid "(margin" +msgstr "(marge" + +#. module: mrp_bom_product_price_margin +#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_sale_product_margin_form +msgid "(margin:" +msgstr "(marge :" + +#. module: mrp_bom_product_price_margin +#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_sale_product_margin_form +msgid "" +"
\n" +" Product variant cost :" +msgstr "" +"
\n" +" Coût du produit :" + +#. module: mrp_bom_product_price_margin +#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_sale_product_margin_form +msgid "" +"
\n" +" Product variant sale price:" +msgstr "" +"
\n" +" Prix de vente du produit :" + +#. module: mrp_bom_product_price_margin +#: model:ir.model,name:mrp_bom_product_price_margin.model_mrp_bom +msgid "Bill of Material" +msgstr "Nomenclature" + +#. module: mrp_bom_product_price_margin +#: model:ir.model,name:mrp_bom_product_price_margin.model_mrp_bom_line +msgid "Bill of Material Line" +msgstr "Ligne de nomenclature" + +#. module: mrp_bom_product_price_margin +#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_sale_product_margin_form +msgid "Bill of Material cost:" +msgstr "Coût de la nomenclature :" + +#. module: mrp_bom_product_price_margin +#: model:ir.model.fields,field_description:mrp_bom_product_price_margin.field_mrp_bom__standard_price +#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_sale_product_margin_form +msgid "BoM Unit Cost" +msgstr "Coût unitaire" + +#. module: mrp_bom_product_price_margin +#: model:ir.model.fields,help:mrp_bom_product_price_margin.field_mrp_bom__standard_price +msgid "Calculated with raw components cost divided by the BoM quantity." +msgstr "" +"Calculé à partir du coût des composants divisé par la quantité de la " +"nomenclature." + +#. module: mrp_bom_product_price_margin +#: model:ir.model.fields,field_description:mrp_bom_product_price_margin.field_product_product__standard_price +msgid "Cost" +msgstr "Coût" + +#. module: mrp_bom_product_price_margin +#: model:ir.model.fields,field_description:mrp_bom_product_price_margin.field_mrp_bom__currency_id +#: model:ir.model.fields,field_description:mrp_bom_product_price_margin.field_mrp_bom_line__currency_id +msgid "Currency" +msgstr "" + +#. module: mrp_bom_product_price_margin +#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_tree +msgid "Diff BoM and Product" +msgstr "" + +#. module: mrp_bom_product_price_margin +#: model:ir.model.fields,field_description:mrp_bom_product_price_margin.field_mrp_bom__diff_product_bom_standard_price +msgid "Diff Product Bom Standard Price" +msgstr "" + +#. module: mrp_bom_product_price_margin +#: model:ir.model.fields,help:mrp_bom_product_price_margin.field_product_product__standard_price +msgid "" +"In Standard Price & AVCO: value of the product (automatically computed in AVCO).\n" +" In FIFO: value of the next unit that will leave the stock (automatically computed).\n" +" Used to value the product when the purchase cost is not known (e.g. inventory adjustment).\n" +" Used to compute margins on sale orders." +msgstr "" +"En prix standard en en coût moyen : valeur du produit (calculée automatiquement en coût moyen).\n" +" En FIFO : valeur de l'unité suivante qui quittera le stock (calculée automatiquement).\n" +" Utilisé pour évaluer le produit lorsque le coût d'achat n'est pas connu (par ex. ajustement de stock).\n" +" Utilisé pour calculer les marges sur les commandes." + +#. module: mrp_bom_product_price_margin +#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_sale_product_margin_form +#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_tree +msgid "It will set product variant's standard price with this price" +msgstr "Cela définira le coût du Produit avec ce total." + +#. module: mrp_bom_product_price_margin +#: model:ir.model.fields,help:mrp_bom_product_price_margin.field_mrp_bom__product_margin_rate +msgid "" +"Margin rate is [ Theorical Margin / sale price (Wo Tax) ] of the product " +"form (not based on historical values).Take care of tax include and exclude.." +" If no sale price set, will display 999.0" +msgstr "" + +#. module: mrp_bom_product_price_margin +#: model:ir.model.fields,field_description:mrp_bom_product_price_margin.field_mrp_bom__product_margin_rate_percentage +msgid "Product Margin" +msgstr "Produit - Marge" + +#. module: mrp_bom_product_price_margin +#: model:ir.model.fields,field_description:mrp_bom_product_price_margin.field_mrp_bom__product_sale_price +msgid "Product Sale Price" +msgstr "Produit - Prix de vente" + +#. module: mrp_bom_product_price_margin +#: model:ir.model.fields,field_description:mrp_bom_product_price_margin.field_mrp_bom__product_standard_price +msgid "Product Standard Price" +msgstr "Produit - Coût" + +#. module: mrp_bom_product_price_margin +#: model:ir.model,name:mrp_bom_product_price_margin.model_product_product +msgid "Product Variant" +msgstr "Variante de produit" + +#. module: mrp_bom_product_price_margin +#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_sale_product_margin_form +msgid "" +"Product cost is based on this Bill of Material.
\n" +" Product variant sale price:" +msgstr "" +"Le coût du Produit est basé sur cette Nomenclature.
\n" +" Prix de vente du produit :" + +#. module: mrp_bom_product_price_margin +#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_sale_product_margin_form +msgid "ST %" +msgstr "" + +#. module: mrp_bom_product_price_margin +#: model:ir.model.fields,field_description:mrp_bom_product_price_margin.field_mrp_bom_line__standard_price_unit +msgid "Standard Price Unit" +msgstr "Prix unitaire" + +#. module: mrp_bom_product_price_margin +#: model:ir.model.fields,field_description:mrp_bom_product_price_margin.field_mrp_bom_line__standard_price_subtotal +msgid "Subtotal price" +msgstr "Sous-total" + +#. module: mrp_bom_product_price_margin +#: model:ir.model.fields,field_description:mrp_bom_product_price_margin.field_mrp_bom_line__standard_price_subtotal_percentage +msgid "Subtotal price %" +msgstr "Sous-total %" + +#. module: mrp_bom_product_price_margin +#: model:ir.model.fields,help:mrp_bom_product_price_margin.field_mrp_bom__product_sale_price +msgid "" +"The sale price is managed from the product template. Click on the 'Configure" +" Variants' button to set the extra attribute prices." +msgstr "" + +#. module: mrp_bom_product_price_margin +#: model:ir.model.fields,field_description:mrp_bom_product_price_margin.field_mrp_bom__product_margin_rate +msgid "Theorical Margin (%)" +msgstr "Marge théorique (%)" + +#. module: mrp_bom_product_price_margin +#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_sale_product_margin_form +msgid "Total" +msgstr "" + +#. module: mrp_bom_product_price_margin +#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_tree +msgid "Update Product standard price" +msgstr "Mettre à jour le coût du Produit" + +#. module: mrp_bom_product_price_margin +#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_sale_product_margin_form +msgid "for 1x" +msgstr "pour 1x" + +#. module: mrp_bom_product_price_margin +#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_sale_product_margin_form +msgid "⇙ Apply this cost to Product variant standard price" +msgstr "⇙ Définir le coût du Produit avec ce prix." diff --git a/mrp_bom_product_price_margin/models/__init__.py b/mrp_bom_product_price_margin/models/__init__.py new file mode 100644 index 000000000..177a1fbc4 --- /dev/null +++ b/mrp_bom_product_price_margin/models/__init__.py @@ -0,0 +1,3 @@ +from . import mrp_bom +from . import mrp_bom_line +from . import product_product diff --git a/mrp_bom_product_price_margin/models/mrp_bom.py b/mrp_bom_product_price_margin/models/mrp_bom.py new file mode 100644 index 000000000..4d8717cf6 --- /dev/null +++ b/mrp_bom_product_price_margin/models/mrp_bom.py @@ -0,0 +1,69 @@ +# Copyright (C) 2022 - Today: GRAP (http://www.grap.coop) +# @author: Quentin DUPONT (quentin.dupont@grap.coop) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models +from odoo.tools.float_utils import float_round + + +class MrpBom(models.Model): + _inherit = "mrp.bom" + + currency_id = fields.Many2one(related="product_tmpl_id.currency_id") + + # Fields related to standard price + product_standard_price = fields.Float(compute="_compute_product_standard_price") + standard_price = fields.Float( + string="BoM Unit Cost", + tracking=True, + digits="Product Price", + compute="_compute_standard_price", + help="Calculated with raw components cost divided by the BoM quantity.", + ) + diff_product_bom_standard_price = fields.Boolean( + default=False, + compute="_compute_diff_product_bom_standard_price", + ) + + # Fields related to sale price + product_sale_price = fields.Float( + string="Product Sale Price", related="product_id.lst_price" + ) + product_margin_rate = fields.Float(related="product_id.standard_margin_rate") + product_margin_rate_percentage = fields.Float( + string="Product Margin", compute="_compute_product_margin_rate_percentage" + ) + + # Compute functions + @api.depends("product_id", "product_id.standard_price") + def _compute_product_standard_price(self): + for bom in self: + bom.product_standard_price = bom.product_id.standard_price + + @api.depends("product_id", "bom_line_ids", "product_qty") + def _compute_standard_price(self): + for bom in self: + qty_to_divide = bom.product_qty if bom.product_qty != 0 else 1 + bom.standard_price = ( + sum(x.standard_price_subtotal for x in bom.bom_line_ids) / qty_to_divide + ) + + @api.depends("product_id.standard_price", "standard_price") + def _compute_diff_product_bom_standard_price(self): + price_dp = self.env["decimal.precision"].precision_get("Product Price") + for bom in self: + if bom.product_id: + diff = bom.product_id.standard_price - bom.standard_price + bom.diff_product_bom_standard_price = float_round(diff, price_dp) + else: + bom.diff_product_bom_standard_price = False + + @api.depends("product_margin_rate") + def _compute_product_margin_rate_percentage(self): + for bom in self: + bom.product_margin_rate_percentage = bom.product_margin_rate / 100 + + # Functions to change product fields + def set_product_standard_price(self): + for bom in self.filtered(lambda x: x.product_id): + bom.product_id.standard_price = bom.standard_price diff --git a/mrp_bom_product_price_margin/models/mrp_bom_line.py b/mrp_bom_product_price_margin/models/mrp_bom_line.py new file mode 100644 index 000000000..af8741e5e --- /dev/null +++ b/mrp_bom_product_price_margin/models/mrp_bom_line.py @@ -0,0 +1,44 @@ +# Copyright (C) 2022 - Today: GRAP (http://www.grap.coop) +# @author: Quentin DUPONT (quentin.dupont@grap.coop) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class MrpBomLine(models.Model): + _inherit = "mrp.bom.line" + + # New fields + standard_price_unit = fields.Float(compute="_compute_standard_price_unit") + currency_id = fields.Many2one(related="product_id.currency_id") + + standard_price_subtotal = fields.Float( + string="Subtotal price", compute="_compute_standard_price_subtotal" + ) + # Percentage float, so 25% is 0,25. For one number behind decimal, needs 3 digits + standard_price_subtotal_percentage = fields.Float( + string="Subtotal price %", + compute="_compute_standard_price_subtotal_percentage", + digits=(16, 3), + ) + + @api.depends("standard_price_unit", "product_qty") + def _compute_standard_price_subtotal(self): + for line in self: + line.standard_price_subtotal = line.standard_price_unit * line.product_qty + + @api.depends("product_id") + def _compute_standard_price_unit(self): + for line in self: + line.standard_price_unit = line.product_id.standard_price + + @api.depends( + "standard_price_subtotal", "bom_id.bom_line_ids.standard_price_subtotal" + ) + def _compute_standard_price_subtotal_percentage(self): + for line in self: + bom = line.bom_id + total_price = sum(line.standard_price_subtotal for line in bom.bom_line_ids) + line.standard_price_subtotal_percentage = ( + line.standard_price_subtotal / total_price if total_price != 0 else 0 + ) diff --git a/mrp_bom_product_price_margin/models/product_product.py b/mrp_bom_product_price_margin/models/product_product.py new file mode 100644 index 000000000..2d184bfc5 --- /dev/null +++ b/mrp_bom_product_price_margin/models/product_product.py @@ -0,0 +1,13 @@ +# Copyright (C) 2022 - Today: GRAP (http://www.grap.coop) +# @author: Quentin DUPONT (quentin.dupont@grap.coop) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ProductProduct(models.Model): + _inherit = "product.product" + + standard_price = fields.Float( + tracking=True, + ) diff --git a/mrp_bom_product_price_margin/readme/CONTRIBUTORS.rst b/mrp_bom_product_price_margin/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..9ed470628 --- /dev/null +++ b/mrp_bom_product_price_margin/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Quentin Dupont (quentin.dupont@grap.coop) diff --git a/mrp_bom_product_price_margin/readme/DESCRIPTION.rst b/mrp_bom_product_price_margin/readme/DESCRIPTION.rst new file mode 100644 index 000000000..dec750e9a --- /dev/null +++ b/mrp_bom_product_price_margin/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Help handling cost and sale price of product variant linked to bill of material. diff --git a/mrp_bom_product_price_margin/readme/USAGE.rst b/mrp_bom_product_price_margin/readme/USAGE.rst new file mode 100644 index 000000000..baf6e8467 --- /dev/null +++ b/mrp_bom_product_price_margin/readme/USAGE.rst @@ -0,0 +1,13 @@ +Set Product Variant in your Bill of Material. +Change BoM quantity or BoM lines quantity or price in one component. +See new panel to change Product Variant Standard Price. + + .. figure:: ../static/mrp_bom_product_price_margin_diff.png + + .. figure:: ../static/mrp_bom_product_price_margin_no_diff.png + +In tree view, quickly see difference between Product standard price and BoM cost. +You can also change Product standard price here +Lines are red when Sale margin in negative. + +.. figure:: ../static/mrp_bom_product_price_margin_tree.png diff --git a/mrp_bom_product_price_margin/static/description/index.html b/mrp_bom_product_price_margin/static/description/index.html new file mode 100644 index 000000000..7ed53ba7b --- /dev/null +++ b/mrp_bom_product_price_margin/static/description/index.html @@ -0,0 +1,442 @@ + + + + + + +MRP BoM Product Price Margin + + + +
+

MRP BoM Product Price Margin

+ + +

Beta License: AGPL-3 OCA/manufacture Translate me on Weblate Try me on Runboat

+

Help handling cost and sale price of product variant linked to bill of material.

+

Table of contents

+ +
+

Usage

+

Set Product Variant in your Bill of Material. +Change BoM quantity or BoM lines quantity or price in one component. +See new panel to change Product Variant Standard Price.

+
+
+https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_diff.png +
+
+https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_no_diff.png +
+
+

In tree view, quickly see difference between Product standard price and BoM cost. +You can also change Product standard price here +Lines are red when Sale margin in negative.

+
+https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_tree.png +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • GRAP
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/manufacture project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_diff.png b/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_diff.png new file mode 100644 index 000000000..4686879cd Binary files /dev/null and b/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_diff.png differ diff --git a/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_no_diff.png b/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_no_diff.png new file mode 100644 index 000000000..747ddd97d Binary files /dev/null and b/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_no_diff.png differ diff --git a/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_tree.png b/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_tree.png new file mode 100644 index 000000000..29535fc94 Binary files /dev/null and b/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_tree.png differ diff --git a/mrp_bom_product_price_margin/tests/__init__.py b/mrp_bom_product_price_margin/tests/__init__.py new file mode 100644 index 000000000..16ebe0ef8 --- /dev/null +++ b/mrp_bom_product_price_margin/tests/__init__.py @@ -0,0 +1 @@ +from . import test_mrp_bom_sale_margin diff --git a/mrp_bom_product_price_margin/tests/test_mrp_bom_sale_margin.py b/mrp_bom_product_price_margin/tests/test_mrp_bom_sale_margin.py new file mode 100644 index 000000000..b74bdb7e4 --- /dev/null +++ b/mrp_bom_product_price_margin/tests/test_mrp_bom_sale_margin.py @@ -0,0 +1,34 @@ +# Copyright (C) 2022 - Today: GRAP (http://www.grap.coop) +# @author: Quentin DUPONT (quentin.dupont@grap.coop) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests.common import TransactionCase + + +class TestMrpBomSaleMargin(TransactionCase): + def setUp(self): + super(TestMrpBomSaleMargin, self).setUp() + self.bom_desk = self.env.ref("mrp.mrp_bom_desk") + self.product_computer_desk = self.env.ref("mrp.product_product_computer_desk") + + def test_01_bom_product_product_set_cost(self): + # Set product product + self.bom_desk.product_id = self.product_computer_desk + self.assertNotEqual( + self.bom_desk.standard_price, + self.bom_desk.product_id.standard_price, + ) + self.assertNotEqual( + self.bom_desk.diff_product_bom_standard_price, + False, + ) + # Set product product standard price based on bom + self.bom_desk.set_product_standard_price() + self.assertEqual( + self.bom_desk.diff_product_bom_standard_price, + False, + ) + self.assertEqual( + self.bom_desk.standard_price, + self.bom_desk.product_id.standard_price, + ) diff --git a/mrp_bom_product_price_margin/views/view_mrp_bom.xml b/mrp_bom_product_price_margin/views/view_mrp_bom.xml new file mode 100644 index 000000000..bd70d3f98 --- /dev/null +++ b/mrp_bom_product_price_margin/views/view_mrp_bom.xml @@ -0,0 +1,148 @@ + + + + + + mrp.bom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + mrp.bom + + + + + + + diff_product_bom_standard_price != False + + + product_margin_rate_percentage < 0 + + + + +