[IMP] Works for product template, update readme

This commit is contained in:
Quentin Dupont
2024-11-08 14:37:50 +01:00
parent dd2d4ab6ee
commit 7507026dd7
14 changed files with 96 additions and 88 deletions

View File

@@ -7,7 +7,7 @@ MRP BoM Product Price Margin
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:aa37e05e4d2c66e364b2d427982b676b8f8dab4171dca239ab8a992ae5eeae62
!! source digest: sha256:29d32daaf1104aac3d5d6277b0370d603872ee94f8cb9a9c8f5a2d185fb54cbf
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -28,7 +28,7 @@ MRP BoM Product Price Margin
|badge1| |badge2| |badge3| |badge4| |badge5|
Help handling cost and sale price of product variant linked to bill of material.
Help handling cost and sale price of product template linked to bill of material.
**Table of contents**
@@ -38,13 +38,12 @@ Help handling cost and sale price of product variant linked to bill of material.
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.
See new panel to change Product 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_diff.jpeg
.. figure:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_no_diff.png
.. figure:: https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_no_diff.jpeg
In tree view, quickly see difference between Product standard price and BoM cost.
You can also change Product standard price here

View File

@@ -6,8 +6,8 @@ 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"
"POT-Creation-Date: 2024-11-08 13:58+0000\n"
"PO-Revision-Date: 2024-11-08 13:58+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -17,8 +17,8 @@ msgstr ""
#. 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"
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
@@ -30,11 +30,20 @@ msgstr "(marge"
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 ""
").<br/>\n"
" Product sale price:"
msgstr ""
").<br/>\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 ""
"<br/>\n"
" Product variant cost :"
" Product cost :"
msgstr ""
"<br/>\n"
" Coût du produit :"
@@ -43,7 +52,7 @@ msgstr ""
#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_sale_product_margin_form
msgid ""
"<br/>\n"
" Product variant sale price:"
" Product sale price:"
msgstr ""
"<br/>\n"
" Prix de vente du produit :"
@@ -77,7 +86,7 @@ msgstr ""
"nomenclature."
#. module: mrp_bom_product_price_margin
#: model:ir.model.fields,field_description:mrp_bom_product_price_margin.field_product_product__standard_price
#: model:ir.model.fields,field_description:mrp_bom_product_price_margin.field_product_template__standard_price
msgid "Cost"
msgstr "Coût"
@@ -85,7 +94,7 @@ msgstr "Coût"
#: 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 ""
msgstr "Devise"
#. module: mrp_bom_product_price_margin
#: model_terms:ir.ui.view,arch_db:mrp_bom_product_price_margin.view_mrp_bom_tree
@@ -98,7 +107,7 @@ 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
#: model:ir.model.fields,help:mrp_bom_product_price_margin.field_product_template__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"
@@ -113,17 +122,32 @@ msgstr ""
#. 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"
msgid "It will set Product'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,field_description:mrp_bom_product_price_margin.field_mrp_bom__product_margin_rate
msgid "Margin (%)"
msgstr "Marge théorique (%)"
#. 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"
"Margin rate is [ 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,help:mrp_bom_product_price_margin.field_mrp_bom__product_sale_price
msgid "Price at which the product is sold to customers."
msgstr ""
#. module: mrp_bom_product_price_margin
#: model:ir.model,name:mrp_bom_product_price_margin.model_product_template
msgid "Product"
msgstr "Produit"
#. 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"
@@ -139,19 +163,10 @@ msgstr "Produit - Prix de vente"
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.<br/>\n"
" Product variant sale price:"
msgstr ""
"Le coût du Produit est basé sur cette Nomenclature.<br/>\n"
" Prix de vente du produit :"
msgid "Product cost is based on the cost of this Bill of Material ("
msgstr "Le coût du Produit est basé sur le coût de cette 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
@@ -173,18 +188,6 @@ msgstr "Sous-total"
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"
@@ -202,5 +205,5 @@ 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."
msgid "⇙ Apply this cost to Product standard price"
msgstr "⇙ Définir le coût du Produit avec ce prix."

View File

@@ -1,3 +1,3 @@
from . import mrp_bom
from . import mrp_bom_line
from . import product_product
from . import product_template

View File

@@ -27,20 +27,20 @@ class MrpBom(models.Model):
# Fields related to sale price
product_sale_price = fields.Float(
string="Product Sale Price", related="product_id.lst_price"
string="Product Sale Price", related="product_tmpl_id.list_price"
)
product_margin_rate = fields.Float(related="product_id.standard_margin_rate")
product_margin_rate = fields.Float(related="product_tmpl_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")
@api.depends("product_tmpl_id", "product_tmpl_id.standard_price")
def _compute_product_standard_price(self):
for bom in self:
bom.product_standard_price = bom.product_id.standard_price
bom.product_standard_price = bom.product_tmpl_id.standard_price
@api.depends("product_id", "bom_line_ids", "product_qty")
@api.depends("product_tmpl_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
@@ -48,12 +48,12 @@ class MrpBom(models.Model):
sum(x.standard_price_subtotal for x in bom.bom_line_ids) / qty_to_divide
)
@api.depends("product_id.standard_price", "standard_price")
@api.depends("product_tmpl_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
if bom.product_tmpl_id:
diff = bom.product_tmpl_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
@@ -65,5 +65,5 @@ class MrpBom(models.Model):
# 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
for bom in self.filtered(lambda x: x.product_tmpl_id):
bom.product_tmpl_id.standard_price = bom.standard_price

View File

@@ -1,12 +1,12 @@
# Copyright (C) 2022 - Today: GRAP (http://www.grap.coop)
# Copyright (C) 2024 - 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"
class ProductTemplate(models.Model):
_inherit = "product.template"
standard_price = fields.Float(
tracking=True,

View File

@@ -1 +1 @@
Help handling cost and sale price of product variant linked to bill of material.
Help handling cost and sale price of product template linked to bill of material.

View File

@@ -1,10 +1,9 @@
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.
See new panel to change Product Standard Price.
.. figure:: ../static/mrp_bom_product_price_margin_diff.png
.. figure:: ../static/mrp_bom_product_price_margin_diff.jpeg
.. figure:: ../static/mrp_bom_product_price_margin_no_diff.png
.. figure:: ../static/mrp_bom_product_price_margin_no_diff.jpeg
In tree view, quickly see difference between Product standard price and BoM cost.
You can also change Product standard price here

View File

@@ -9,10 +9,11 @@
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
@@ -275,7 +276,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +302,7 @@ span.option {
span.pre {
white-space: pre }
span.problematic {
span.problematic, pre.problematic {
color: red }
span.section-subtitle {
@@ -367,10 +368,10 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:aa37e05e4d2c66e364b2d427982b676b8f8dab4171dca239ab8a992ae5eeae62
!! source digest: sha256:29d32daaf1104aac3d5d6277b0370d603872ee94f8cb9a9c8f5a2d185fb54cbf
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/manufacture/tree/16.0/mrp_bom_product_price_margin"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/manufacture-16-0/manufacture-16-0-mrp_bom_product_price_margin"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/manufacture&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Help handling cost and sale price of product variant linked to bill of material.</p>
<p>Help handling cost and sale price of product template linked to bill of material.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
@@ -386,15 +387,14 @@ ul.auto-toc {
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>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.</p>
<p>Change BoM quantity or BoM lines quantity or price in one component.
See new panel to change Product Standard Price.</p>
<blockquote>
<div class="figure">
<img alt="https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_diff.png" src="https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_diff.png" />
<img alt="https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_diff.jpeg" src="https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_diff.jpeg" />
</div>
<div class="figure">
<img alt="https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_no_diff.png" src="https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_no_diff.png" />
<img alt="https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_no_diff.jpeg" src="https://raw.githubusercontent.com/OCA/manufacture/16.0/mrp_bom_product_price_margin/static/mrp_bom_product_price_margin_no_diff.jpeg" />
</div>
</blockquote>
<p>In tree view, quickly see difference between Product standard price and BoM cost.
@@ -429,7 +429,9 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -8,15 +8,17 @@ 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")
self.bom_desk = self.env.ref("mrp.mrp_bom_desk") # [FURN_9666] Table
self.product_computer_desk = self.env.ref(
"mrp.product_product_computer_desk_product_template"
)
def test_01_bom_product_product_set_cost(self):
# Set product product
self.bom_desk.product_id = self.product_computer_desk
self.bom_desk.product_tmpl_id = self.product_computer_desk
self.assertNotEqual(
self.bom_desk.standard_price,
self.bom_desk.product_id.standard_price,
self.bom_desk.product_tmpl_id.standard_price,
)
self.assertNotEqual(
self.bom_desk.diff_product_bom_standard_price,
@@ -30,5 +32,5 @@ class TestMrpBomSaleMargin(TransactionCase):
)
self.assertEqual(
self.bom_desk.standard_price,
self.bom_desk.product_id.standard_price,
self.bom_desk.product_tmpl_id.standard_price,
)

View File

@@ -31,18 +31,18 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
/>)</span>
<button
name="set_product_standard_price"
string="⇙ Apply this cost to Product variant standard price"
string="⇙ Apply this cost to Product standard price"
type="object"
class="oe_link"
help="It will set product variant's standard price with this price"
help="It will set Product's standard price with this price"
/>
<br />
Product variant cost : <b><field
Product cost : <b><field
name="product_standard_price"
widget="monetary"
/></b>
<br />
Product variant sale price:
Product sale price:
<b><field
name="product_sale_price"
widget="monetary"
@@ -53,10 +53,13 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<div
class="alert alert-info"
role="alert"
attrs="{'invisible': ['|', ('diff_product_bom_standard_price', '!=', False), ('product_id', '=', False)]}"
attrs="{'invisible': ['|', ('diff_product_bom_standard_price', '!=', False), ('product_tmpl_id', '=', False)]}"
>
Product cost is based on this Bill of Material.<br />
Product variant sale price:
Product cost is based on the cost of this Bill of Material (<b><field
name="standard_price"
widget="monetary"
/></b>).<br />
Product sale price:
<b><field
name="product_sale_price"
widget="monetary"
@@ -127,7 +130,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
name="decoration-danger"
>product_margin_rate_percentage &lt; 0</attribute>
</xpath>
<xpath expr="//field[@name='product_id']" position="after">
<xpath expr="//field[@name='product_tmpl_id']" position="after">
<field name="currency_id" invisible="1" />
<field name="standard_price" widget="monetary" />
<button
@@ -136,7 +139,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
string="Update Product standard price"
type="object"
attrs="{'invisible': [('diff_product_bom_standard_price', '=', False)]}"
help="It will set product variant's standard price with this price"
help="It will set Product's standard price with this price"
/>
<field name="product_standard_price" widget="monetary" />
<field name="product_sale_price" widget="monetary" />