-
-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28db8a2
commit aa06320
Showing
19 changed files
with
831 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
========================= | ||
Product Pricelist Margins | ||
========================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:4e46bed8123996a1ad4caf70e45af07c1941e308a8104ee2f267fdd410fbe6e5 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Fproduct--attribute-lightgray.png?logo=github | ||
:target: https://github.com/OCA/product-attribute/tree/16.0/product_pricelist_margins | ||
:alt: OCA/product-attribute | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_pricelist_margins | ||
: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/product-attribute&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module shows the product's cost and margin from the pricelists. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
* Go to "Sale > Products > Pricelists" | ||
|
||
* Open a pricelist form | ||
|
||
* There are 3 new columns on the "Price rules" list. | ||
.. image:: https://raw.githubusercontent.com/OCA/product-attribute/16.0/product_pricelist_margins/static/description/pricelist_item.png | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/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 <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_pricelist_margins%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Camptocamp | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Nguyen Minh Chien <[email protected]> | ||
|
||
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/product-attribute <https://github.com/OCA/product-attribute/tree/16.0/product_pricelist_margins>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Product Pricelist Margins", | ||
"summary": "This module shows the product's cost and margin from the pricelists.", | ||
"version": "16.0.1.0.0", | ||
"category": "Product", | ||
"website": "https://github.com/OCA/product-attribute", | ||
"author": "Camptocamp, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"depends": ["account"], | ||
"data": [ | ||
"views/product_pricelist_views.xml", | ||
"views/product_pricelist_item_views.xml", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * product_pricelist_margins | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0+e\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-03-20 08:44+0000\n" | ||
"PO-Revision-Date: 2024-03-20 08:44+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: product_pricelist_margins | ||
#: model:ir.model.fields,field_description:product_pricelist_margins.field_product_pricelist_item__cost | ||
msgid "Cost" | ||
msgstr "Coût" | ||
|
||
#. module: product_pricelist_margins | ||
#: model:ir.model.fields,help:product_pricelist_margins.field_product_pricelist_item__cost | ||
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 "" | ||
|
||
#. module: product_pricelist_margins | ||
#: model:ir.model.fields,field_description:product_pricelist_margins.field_product_pricelist_item__margin | ||
msgid "Margin" | ||
msgstr "Marge" | ||
|
||
#. module: product_pricelist_margins | ||
#: model:ir.model.fields,field_description:product_pricelist_margins.field_product_pricelist_item__margin_percent | ||
msgid "Margin (%)" | ||
msgstr "Marge (%)" | ||
|
||
#. module: product_pricelist_margins | ||
#: model:ir.model,name:product_pricelist_margins.model_product_pricelist_item | ||
msgid "Pricelist Rule" | ||
msgstr "Règle des listes des prix" |
45 changes: 45 additions & 0 deletions
45
product_pricelist_margins/i18n/product_pricelist_margins.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * product_pricelist_margins | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0+e\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-03-20 08:44+0000\n" | ||
"PO-Revision-Date: 2024-03-20 08:44+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: product_pricelist_margins | ||
#: model:ir.model.fields,field_description:product_pricelist_margins.field_product_pricelist_item__cost | ||
msgid "Cost" | ||
msgstr "" | ||
|
||
#. module: product_pricelist_margins | ||
#: model:ir.model.fields,help:product_pricelist_margins.field_product_pricelist_item__cost | ||
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 "" | ||
|
||
#. module: product_pricelist_margins | ||
#: model:ir.model.fields,field_description:product_pricelist_margins.field_product_pricelist_item__margin | ||
msgid "Margin" | ||
msgstr "" | ||
|
||
#. module: product_pricelist_margins | ||
#: model:ir.model.fields,field_description:product_pricelist_margins.field_product_pricelist_item__margin_percent | ||
msgid "Margin (%)" | ||
msgstr "" | ||
|
||
#. module: product_pricelist_margins | ||
#: model:ir.model,name:product_pricelist_margins.model_product_pricelist_item | ||
msgid "Pricelist Rule" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import product_pricelist_item |
72 changes: 72 additions & 0 deletions
72
product_pricelist_margins/models/product_pricelist_item.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
from odoo.tools.float_utils import float_is_zero | ||
|
||
|
||
class ProductPricelistItem(models.Model): | ||
_inherit = "product.pricelist.item" | ||
|
||
cost = fields.Float( | ||
related="product_tmpl_id.standard_price", | ||
digits="Product Price", | ||
) | ||
margin = fields.Float( | ||
compute="_compute_margin", | ||
digits="Product Price", | ||
) | ||
margin_percent = fields.Float( | ||
string="Margin (%)", | ||
compute="_compute_margin", | ||
) | ||
|
||
@api.depends( | ||
"compute_price", | ||
"applied_on", | ||
"percent_price", | ||
"base", | ||
"price_discount", | ||
"price_surcharge", | ||
"price_round", | ||
"price_min_margin", | ||
"product_tmpl_id", | ||
"cost", | ||
"min_quantity", | ||
) | ||
def _compute_margin(self): | ||
for item in self.filtered( | ||
lambda x: x.applied_on in ("1_product", "0_product_variant") | ||
): | ||
margin = percentage = 0 | ||
|
||
price_rule = item.pricelist_id._compute_price_rule( | ||
item.product_tmpl_id, item.min_quantity | ||
) | ||
|
||
price = price_rule.get(item.product_tmpl_id.id, [0])[0] | ||
|
||
if not float_is_zero(price, precision_digits=item.currency_id.rounding): | ||
res = item.product_tmpl_id.taxes_id.compute_all( | ||
price, | ||
item.currency_id, | ||
product=item.product_tmpl_id, | ||
) | ||
|
||
price_vat_excl = res["total_excluded"] | ||
|
||
cost = self.env.user.company_id.currency_id.compute( | ||
item.cost, item.currency_id | ||
) | ||
|
||
margin = price_vat_excl - cost | ||
percentage = price_vat_excl and (margin / price_vat_excl) * 100 | ||
|
||
item.margin = margin | ||
item.margin_percent = percentage | ||
|
||
for item in self.filtered( | ||
lambda x: x.applied_on not in ("1_product", "0_product_variant") | ||
): | ||
item.margin = 0 | ||
item.margin_percent = 0 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Nguyen Minh Chien <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This module shows the product's cost and margin from the pricelists. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
* Go to "Sale > Products > Pricelists" | ||
|
||
* Open a pricelist form | ||
|
||
* There are 3 new columns on the "Price rules" list. | ||
.. image:: ../static/description/pricelist_item.png |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.