odoo-addon-product-pricelist-margin 16.0.1.0.0.3__py3-none-any.whl → 18.0.1.0.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. odoo/addons/product_pricelist_margin/README.rst +26 -16
  2. odoo/addons/product_pricelist_margin/__manifest__.py +1 -1
  3. odoo/addons/product_pricelist_margin/i18n/product_pricelist_margin.pot +9 -10
  4. odoo/addons/product_pricelist_margin/models/product_pricelist_item.py +16 -12
  5. odoo/addons/product_pricelist_margin/readme/CONTRIBUTORS.md +2 -0
  6. odoo/addons/product_pricelist_margin/readme/DESCRIPTION.md +5 -0
  7. odoo/addons/product_pricelist_margin/readme/USAGE.md +5 -0
  8. odoo/addons/product_pricelist_margin/static/description/index.html +27 -17
  9. odoo/addons/product_pricelist_margin/tests/test_margin.py +13 -3
  10. odoo/addons/product_pricelist_margin/views/product_pricelist_item_views.xml +1 -5
  11. odoo/addons/product_pricelist_margin/views/product_pricelist_views.xml +3 -21
  12. {odoo_addon_product_pricelist_margin-16.0.1.0.0.3.dist-info → odoo_addon_product_pricelist_margin-18.0.1.0.0.2.dist-info}/METADATA +32 -21
  13. odoo_addon_product_pricelist_margin-18.0.1.0.0.2.dist-info/RECORD +23 -0
  14. {odoo_addon_product_pricelist_margin-16.0.1.0.0.3.dist-info → odoo_addon_product_pricelist_margin-18.0.1.0.0.2.dist-info}/WHEEL +1 -1
  15. odoo_addon_product_pricelist_margin-18.0.1.0.0.2.dist-info/top_level.txt +1 -0
  16. odoo/addons/product_pricelist_margin/readme/CONTRIBUTORS.rst +0 -1
  17. odoo/addons/product_pricelist_margin/readme/DESCRIPTION.rst +0 -1
  18. odoo/addons/product_pricelist_margin/readme/USAGE.rst +0 -6
  19. odoo_addon_product_pricelist_margin-16.0.1.0.0.3.dist-info/RECORD +0 -23
  20. odoo_addon_product_pricelist_margin-16.0.1.0.0.3.dist-info/top_level.txt +0 -1
@@ -1,3 +1,7 @@
1
+ .. image:: https://odoo-community.org/readme-banner-image
2
+ :target: https://odoo-community.org/get-involved?utm_source=readme
3
+ :alt: Odoo Community Association
4
+
1
5
  ========================
2
6
  Product Pricelist Margin
3
7
  ========================
@@ -7,28 +11,32 @@ Product Pricelist Margin
7
11
  !! This file is generated by oca-gen-addon-readme !!
8
12
  !! changes will be overwritten. !!
9
13
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10
- !! source digest: sha256:f7a304e2acd01b42ff2f6e9de3dfa6a6ee4519e2beeddba42b49fad5e8d7d0b6
14
+ !! source digest: sha256:79a956055af86d377ffcc3e50021ebe96dd499f591be9153ac3e0f938d0c5e36
11
15
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12
16
 
13
17
  .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14
18
  :target: https://odoo-community.org/page/development-status
15
19
  :alt: Beta
16
- .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
20
+ .. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
17
21
  :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18
22
  :alt: License: AGPL-3
19
23
  .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github
20
- :target: https://github.com/OCA/product-attribute/tree/16.0/product_pricelist_margin
24
+ :target: https://github.com/OCA/product-attribute/tree/18.0/product_pricelist_margin
21
25
  :alt: OCA/product-attribute
22
26
  .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23
- :target: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_pricelist_margin
27
+ :target: https://translation.odoo-community.org/projects/product-attribute-18-0/product-attribute-18-0-product_pricelist_margin
24
28
  :alt: Translate me on Weblate
25
29
  .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26
- :target: https://runboat.odoo-community.org/builds?repo=OCA/product-attribute&target_branch=16.0
30
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/product-attribute&target_branch=18.0
27
31
  :alt: Try me on Runboat
28
32
 
29
33
  |badge1| |badge2| |badge3| |badge4| |badge5|
30
34
 
31
- This module shows the product's cost and margin from the pricelists.
35
+ This module shows the product's cost and margin from the pricelists. The
36
+ margin is calculated as the difference between the price and the cost,
37
+ expressed as a percentage of the price. The price is based on the
38
+ computation applied from the current pricelist item. This allows the
39
+ user to make price simulations while editing the pricelist item.
32
40
 
33
41
  **Table of contents**
34
42
 
@@ -38,12 +46,13 @@ This module shows the product's cost and margin from the pricelists.
38
46
  Usage
39
47
  =====
40
48
 
41
- * Go to "Sale > Products > Pricelists"
49
+ - Go to "Sale > Products > Pricelists"
50
+ - Open a pricelist form
51
+ - There are 3 new columns on the "Price rules" list.
42
52
 
43
- * Open a pricelist form
53
+ |Pricelist Item|
44
54
 
45
- * There are 3 new columns on the "Price rules" list.
46
- .. image:: https://raw.githubusercontent.com/OCA/product-attribute/16.0/product_pricelist_margin/static/description/pricelist_item.png
55
+ .. |Pricelist Item| image:: https://raw.githubusercontent.com/OCA/product-attribute/18.0/product_pricelist_margin/static/description/pricelist_item.png
47
56
 
48
57
  Bug Tracker
49
58
  ===========
@@ -51,7 +60,7 @@ Bug Tracker
51
60
  Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/issues>`_.
52
61
  In case of trouble, please check there if your issue has already been reported.
53
62
  If you spotted it first, help us to smash it by providing a detailed and welcomed
54
- `feedback <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_pricelist_margin%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
63
+ `feedback <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_pricelist_margin%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
55
64
 
56
65
  Do not contact contributors directly about support or help with technical issues.
57
66
 
@@ -59,17 +68,18 @@ Credits
59
68
  =======
60
69
 
61
70
  Authors
62
- ~~~~~~~
71
+ -------
63
72
 
64
73
  * Camptocamp
65
74
 
66
75
  Contributors
67
- ~~~~~~~~~~~~
76
+ ------------
68
77
 
69
- * Nguyen Minh Chien <chien@trobz.com>
78
+ - Nguyen Minh Chien <chien@trobz.com>
79
+ - Telmo Santos <telmo.santos@camptocamp.com>
70
80
 
71
81
  Maintainers
72
- ~~~~~~~~~~~
82
+ -----------
73
83
 
74
84
  This module is maintained by the OCA.
75
85
 
@@ -81,6 +91,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
81
91
  mission is to support the collaborative development of Odoo features and
82
92
  promote its widespread use.
83
93
 
84
- This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/16.0/product_pricelist_margin>`_ project on GitHub.
94
+ This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/18.0/product_pricelist_margin>`_ project on GitHub.
85
95
 
86
96
  You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
@@ -3,7 +3,7 @@
3
3
  {
4
4
  "name": "Product Pricelist Margin",
5
5
  "summary": "This module shows the product's cost and margin from the pricelists.",
6
- "version": "16.0.1.0.0",
6
+ "version": "18.0.1.0.0",
7
7
  "category": "Product",
8
8
  "website": "https://github.com/OCA/product-attribute",
9
9
  "author": "Camptocamp, Odoo Community Association (OCA)",
@@ -4,7 +4,7 @@
4
4
  #
5
5
  msgid ""
6
6
  msgstr ""
7
- "Project-Id-Version: Odoo Server 16.0\n"
7
+ "Project-Id-Version: Odoo Server 18.0\n"
8
8
  "Report-Msgid-Bugs-To: \n"
9
9
  "Last-Translator: \n"
10
10
  "Language-Team: \n"
@@ -18,15 +18,6 @@ msgstr ""
18
18
  msgid "Cost"
19
19
  msgstr ""
20
20
 
21
- #. module: product_pricelist_margin
22
- #: model:ir.model.fields,help:product_pricelist_margin.field_product_pricelist_item__cost
23
- msgid ""
24
- "In Standard Price & AVCO: value of the product (automatically computed in AVCO).\n"
25
- " In FIFO: value of the next unit that will leave the stock (automatically computed).\n"
26
- " Used to value the product when the purchase cost is not known (e.g. inventory adjustment).\n"
27
- " Used to compute margins on sale orders."
28
- msgstr ""
29
-
30
21
  #. module: product_pricelist_margin
31
22
  #: model:ir.model.fields,field_description:product_pricelist_margin.field_product_pricelist_item__margin
32
23
  msgid "Margin"
@@ -41,3 +32,11 @@ msgstr ""
41
32
  #: model:ir.model,name:product_pricelist_margin.model_product_pricelist_item
42
33
  msgid "Pricelist Rule"
43
34
  msgstr ""
35
+
36
+ #. module: product_pricelist_margin
37
+ #: model:ir.model.fields,help:product_pricelist_margin.field_product_pricelist_item__cost
38
+ msgid ""
39
+ "Value of the product (automatically computed in AVCO).\n"
40
+ " Used to value the product when the purchase cost is not known (e.g. inventory adjustment).\n"
41
+ " Used to compute margins on sale orders."
42
+ msgstr ""
@@ -2,7 +2,7 @@
2
2
  # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3
3
 
4
4
  from odoo import api, fields, models
5
- from odoo.tools.float_utils import float_is_zero
5
+ from odoo.tools.float_utils import float_is_zero, float_round
6
6
 
7
7
 
8
8
  class ProductPricelistItem(models.Model):
@@ -36,25 +36,28 @@ class ProductPricelistItem(models.Model):
36
36
  "fixed_price",
37
37
  )
38
38
  def _compute_margin(self):
39
+ current_company = self.env.company
39
40
  for item in self:
40
- if item.applied_on not in ("1_product", "0_product_variant"):
41
+ if (
42
+ item.applied_on not in ("1_product", "0_product_variant")
43
+ or not item.product_tmpl_id
44
+ ):
41
45
  item.margin = 0
42
46
  item.margin_percent = 0
43
47
  continue
44
48
 
45
- price_rule = item.pricelist_id._compute_price_rule(
46
- item.product_tmpl_id, item.min_quantity
49
+ price = item._compute_price(
50
+ item.product_tmpl_id,
51
+ item.min_quantity,
52
+ item.product_tmpl_id.uom_id,
53
+ fields.Datetime.now(),
47
54
  )
48
55
 
49
- price = price_rule.get(item.product_tmpl_id.id, [0])[0]
50
-
51
- if float_is_zero(price, precision_digits=item.currency_id.rounding):
56
+ if float_is_zero(price, precision_rounding=item.currency_id.rounding):
52
57
  item.margin = 0
53
58
  item.margin_percent = 0
54
59
  continue
55
60
 
56
- current_company = self.env.company
57
-
58
61
  res = item.product_tmpl_id.taxes_id.filtered(
59
62
  lambda t: t.company_id and t.company_id == current_company
60
63
  ).compute_all(
@@ -65,11 +68,12 @@ class ProductPricelistItem(models.Model):
65
68
 
66
69
  price_vat_excl = res["total_excluded"]
67
70
 
68
- cost = self.env.user.company_id.currency_id.compute(
71
+ cost = self.env.user.company_id.currency_id._convert(
69
72
  item.cost, item.currency_id
70
73
  )
71
74
 
72
75
  item.margin = price_vat_excl - cost
73
- item.margin_percent = (
74
- price_vat_excl and (item.margin / price_vat_excl) * 100
76
+ item.margin_percent = float_round(
77
+ price_vat_excl and (item.margin / price_vat_excl) * 100,
78
+ self.env["decimal.precision"].precision_get("Product Unit of Measure"),
75
79
  )
@@ -0,0 +1,2 @@
1
+ - Nguyen Minh Chien \<<chien@trobz.com>\>
2
+ - Telmo Santos \<<telmo.santos@camptocamp.com>\>
@@ -0,0 +1,5 @@
1
+ This module shows the product's cost and margin from the pricelists. The
2
+ margin is calculated as the difference between the price and the cost,
3
+ expressed as a percentage of the price. The price is based on the
4
+ computation applied from the current pricelist item. This allows the
5
+ user to make price simulations while editing the pricelist item.
@@ -0,0 +1,5 @@
1
+ - Go to "Sale > Products > Pricelists"
2
+ - Open a pricelist form
3
+ - There are 3 new columns on the "Price rules" list.
4
+
5
+ ![Pricelist Item](../static/description/pricelist_item.png)
@@ -1,10 +1,9 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
1
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
2
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
3
  <head>
5
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
5
  <meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
7
- <title>Product Pricelist Margin</title>
6
+ <title>README.rst</title>
8
7
  <style type="text/css">
9
8
 
10
9
  /*
@@ -361,17 +360,26 @@ ul.auto-toc {
361
360
  </style>
362
361
  </head>
363
362
  <body>
364
- <div class="document" id="product-pricelist-margin">
365
- <h1 class="title">Product Pricelist Margin</h1>
363
+ <div class="document">
366
364
 
365
+
366
+ <a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367
+ <img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368
+ </a>
369
+ <div class="section" id="product-pricelist-margin">
370
+ <h1>Product Pricelist Margin</h1>
367
371
  <!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
368
372
  !! This file is generated by oca-gen-addon-readme !!
369
373
  !! changes will be overwritten. !!
370
374
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
371
- !! source digest: sha256:f7a304e2acd01b42ff2f6e9de3dfa6a6ee4519e2beeddba42b49fad5e8d7d0b6
375
+ !! source digest: sha256:79a956055af86d377ffcc3e50021ebe96dd499f591be9153ac3e0f938d0c5e36
372
376
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
373
- <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/product-attribute/tree/16.0/product_pricelist_margin"><img alt="OCA/product-attribute" src="https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_pricelist_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/product-attribute&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
374
- <p>This module shows the product’s cost and margin from the pricelists.</p>
377
+ <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/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/product-attribute/tree/18.0/product_pricelist_margin"><img alt="OCA/product-attribute" src="https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/product-attribute-18-0/product-attribute-18-0-product_pricelist_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/product-attribute&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378
+ <p>This module shows the product’s cost and margin from the pricelists. The
379
+ margin is calculated as the difference between the price and the cost,
380
+ expressed as a percentage of the price. The price is based on the
381
+ computation applied from the current pricelist item. This allows the
382
+ user to make price simulations while editing the pricelist item.</p>
375
383
  <p><strong>Table of contents</strong></p>
376
384
  <div class="contents local topic" id="contents">
377
385
  <ul class="simple">
@@ -386,38 +394,39 @@ ul.auto-toc {
386
394
  </ul>
387
395
  </div>
388
396
  <div class="section" id="usage">
389
- <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
397
+ <h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
390
398
  <ul class="simple">
391
399
  <li>Go to “Sale &gt; Products &gt; Pricelists”</li>
392
400
  <li>Open a pricelist form</li>
393
- <li>There are 3 new columns on the “Price rules” list.
394
- .. image:: <a class="reference external" href="https://raw.githubusercontent.com/OCA/product-attribute/16.0/product_pricelist_margin/static/description/pricelist_item.png">https://raw.githubusercontent.com/OCA/product-attribute/16.0/product_pricelist_margin/static/description/pricelist_item.png</a></li>
401
+ <li>There are 3 new columns on the “Price rules” list.</li>
395
402
  </ul>
403
+ <p><img alt="Pricelist Item" src="https://raw.githubusercontent.com/OCA/product-attribute/18.0/product_pricelist_margin/static/description/pricelist_item.png" /></p>
396
404
  </div>
397
405
  <div class="section" id="bug-tracker">
398
- <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
406
+ <h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
399
407
  <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/product-attribute/issues">GitHub Issues</a>.
400
408
  In case of trouble, please check there if your issue has already been reported.
401
409
  If you spotted it first, help us to smash it by providing a detailed and welcomed
402
- <a class="reference external" href="https://github.com/OCA/product-attribute/issues/new?body=module:%20product_pricelist_margin%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
410
+ <a class="reference external" href="https://github.com/OCA/product-attribute/issues/new?body=module:%20product_pricelist_margin%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
403
411
  <p>Do not contact contributors directly about support or help with technical issues.</p>
404
412
  </div>
405
413
  <div class="section" id="credits">
406
- <h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
414
+ <h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
407
415
  <div class="section" id="authors">
408
- <h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
416
+ <h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
409
417
  <ul class="simple">
410
418
  <li>Camptocamp</li>
411
419
  </ul>
412
420
  </div>
413
421
  <div class="section" id="contributors">
414
- <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
422
+ <h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
415
423
  <ul class="simple">
416
424
  <li>Nguyen Minh Chien &lt;<a class="reference external" href="mailto:chien&#64;trobz.com">chien&#64;trobz.com</a>&gt;</li>
425
+ <li>Telmo Santos &lt;<a class="reference external" href="mailto:telmo.santos&#64;camptocamp.com">telmo.santos&#64;camptocamp.com</a>&gt;</li>
417
426
  </ul>
418
427
  </div>
419
428
  <div class="section" id="maintainers">
420
- <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
429
+ <h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
421
430
  <p>This module is maintained by the OCA.</p>
422
431
  <a class="reference external image-reference" href="https://odoo-community.org">
423
432
  <img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -425,10 +434,11 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
425
434
  <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
426
435
  mission is to support the collaborative development of Odoo features and
427
436
  promote its widespread use.</p>
428
- <p>This module is part of the <a class="reference external" href="https://github.com/OCA/product-attribute/tree/16.0/product_pricelist_margin">OCA/product-attribute</a> project on GitHub.</p>
437
+ <p>This module is part of the <a class="reference external" href="https://github.com/OCA/product-attribute/tree/18.0/product_pricelist_margin">OCA/product-attribute</a> project on GitHub.</p>
429
438
  <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
430
439
  </div>
431
440
  </div>
432
441
  </div>
442
+ </div>
433
443
  </body>
434
444
  </html>
@@ -35,9 +35,19 @@ class TestMargin(BaseCommon):
35
35
  "min_quantity": 1,
36
36
  }
37
37
  )
38
- cls.env.ref("product.group_sale_pricelist").users |= cls.env.user
39
38
 
40
- def test_margin_computation_compute_price(self):
39
+ def test_margin_with_fixed_price_computation(self):
41
40
  self.assertEqual(self.line.cost, 20.0)
42
41
  self.assertEqual(self.line.margin, (35 - 20))
43
- self.assertEqual(self.line.margin_percent, ((35 - 20) / 35) * 100)
42
+ self.assertEqual(self.line.margin_percent, 42.86)
43
+
44
+ # Copy production and test that margin is computed based on current item
45
+ # => self.line should not impact margin of new_line
46
+ new_line = self.line.copy()
47
+ new_line.fixed_price = 40
48
+ self.assertEqual(new_line.margin, (40 - 20))
49
+ self.assertEqual(new_line.margin_percent, 50.00)
50
+
51
+ def test_margin_with_discount_computation(self):
52
+ self.line.write({"compute_price": "percentage", "percent_price": 0.5})
53
+ self.assertAlmostEqual(self.line.margin_percent, 49.75)
@@ -1,6 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8" ?>
2
2
  <odoo>
3
-
4
3
  <record id="product_pricelist_item_tree_view_inherit" model="ir.ui.view">
5
4
  <field name="model">product.pricelist.item</field>
6
5
  <field name="inherit_id" ref="product.product_pricelist_item_tree_view" />
@@ -35,9 +34,7 @@
35
34
  <field name="model">product.pricelist.item</field>
36
35
  <field name="arch" type="xml">
37
36
  <xpath expr="//group[@name='pricelist_rule_base']/div" position="after">
38
- <group
39
- attrs="{'invisible': [('applied_on', 'not in', ['1_product', '0_product_variant'])]}"
40
- >
37
+ <group invisible="applied_on not in ['1_product', '0_product_variant']">
41
38
  <field name="cost" invisible="1" />
42
39
  <field name="margin" />
43
40
  <field name="margin_percent" />
@@ -45,5 +42,4 @@
45
42
  </xpath>
46
43
  </field>
47
44
  </record>
48
-
49
45
  </odoo>
@@ -1,43 +1,25 @@
1
1
  <?xml version="1.0" encoding="UTF-8" ?>
2
2
  <odoo>
3
-
4
3
  <record id="product_pricelist_view_inherit" model="ir.ui.view">
5
4
  <field name="model">product.pricelist</field>
6
5
  <field name="inherit_id" ref="product.product_pricelist_view" />
7
6
  <field name="arch" type="xml">
8
7
  <xpath
9
- expr="//field[@name='item_ids']/tree[1]/field[@name='fixed_price']"
8
+ expr="//field[@name='item_ids']/list[1]/field[@name='price']"
10
9
  position="after"
11
10
  >
12
11
  <field name="cost" invisible="1" />
13
12
  <field
14
13
  name="margin"
15
14
  optional="show"
16
- attrs="{'invisible': [('applied_on', 'not in', ['1_product', '0_product_variant'])]}"
15
+ invisible="applied_on not in ['1_product', '0_product_variant']"
17
16
  />
18
17
  <field
19
18
  name="margin_percent"
20
19
  optional="show"
21
- attrs="{'invisible': [('applied_on', 'not in', ['1_product', '0_product_variant'])]}"
22
- />
23
- </xpath>
24
- <xpath
25
- expr="//field[@name='item_ids']/tree[2]/field[@name='price']"
26
- position="after"
27
- >
28
- <field name="cost" invisible="1" />
29
- <field
30
- name="margin"
31
- optional="show"
32
- attrs="{'invisible': [('applied_on', 'not in', ['1_product', '0_product_variant'])]}"
33
- />
34
- <field
35
- name="margin_percent"
36
- optional="show"
37
- attrs="{'invisible': [('applied_on', 'not in', ['1_product', '0_product_variant'])]}"
20
+ invisible="applied_on not in ['1_product', '0_product_variant']"
38
21
  />
39
22
  </xpath>
40
23
  </field>
41
24
  </record>
42
-
43
25
  </odoo>
@@ -1,17 +1,22 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: odoo-addon-product_pricelist_margin
3
- Version: 16.0.1.0.0.3
3
+ Version: 18.0.1.0.0.2
4
+ Requires-Python: >=3.10
5
+ Requires-Dist: odoo==18.0.*
4
6
  Summary: This module shows the product's cost and margin from the pricelists.
5
7
  Home-page: https://github.com/OCA/product-attribute
8
+ License: AGPL-3
6
9
  Author: Camptocamp, Odoo Community Association (OCA)
7
10
  Author-email: support@odoo-community.org
8
- License: AGPL-3
9
11
  Classifier: Programming Language :: Python
10
12
  Classifier: Framework :: Odoo
11
- Classifier: Framework :: Odoo :: 16.0
13
+ Classifier: Framework :: Odoo :: 18.0
12
14
  Classifier: License :: OSI Approved :: GNU Affero General Public License v3
13
- Requires-Python: >=3.10
14
- Requires-Dist: odoo<16.1dev,>=16.0a
15
+ Description-Content-Type: text/x-rst
16
+
17
+ .. image:: https://odoo-community.org/readme-banner-image
18
+ :target: https://odoo-community.org/get-involved?utm_source=readme
19
+ :alt: Odoo Community Association
15
20
 
16
21
  ========================
17
22
  Product Pricelist Margin
@@ -22,28 +27,32 @@ Product Pricelist Margin
22
27
  !! This file is generated by oca-gen-addon-readme !!
23
28
  !! changes will be overwritten. !!
24
29
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
25
- !! source digest: sha256:f7a304e2acd01b42ff2f6e9de3dfa6a6ee4519e2beeddba42b49fad5e8d7d0b6
30
+ !! source digest: sha256:79a956055af86d377ffcc3e50021ebe96dd499f591be9153ac3e0f938d0c5e36
26
31
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
27
32
 
28
33
  .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
29
34
  :target: https://odoo-community.org/page/development-status
30
35
  :alt: Beta
31
- .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
36
+ .. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
32
37
  :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
33
38
  :alt: License: AGPL-3
34
39
  .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github
35
- :target: https://github.com/OCA/product-attribute/tree/16.0/product_pricelist_margin
40
+ :target: https://github.com/OCA/product-attribute/tree/18.0/product_pricelist_margin
36
41
  :alt: OCA/product-attribute
37
42
  .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
38
- :target: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-product_pricelist_margin
43
+ :target: https://translation.odoo-community.org/projects/product-attribute-18-0/product-attribute-18-0-product_pricelist_margin
39
44
  :alt: Translate me on Weblate
40
45
  .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
41
- :target: https://runboat.odoo-community.org/builds?repo=OCA/product-attribute&target_branch=16.0
46
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/product-attribute&target_branch=18.0
42
47
  :alt: Try me on Runboat
43
48
 
44
49
  |badge1| |badge2| |badge3| |badge4| |badge5|
45
50
 
46
- This module shows the product's cost and margin from the pricelists.
51
+ This module shows the product's cost and margin from the pricelists. The
52
+ margin is calculated as the difference between the price and the cost,
53
+ expressed as a percentage of the price. The price is based on the
54
+ computation applied from the current pricelist item. This allows the
55
+ user to make price simulations while editing the pricelist item.
47
56
 
48
57
  **Table of contents**
49
58
 
@@ -53,12 +62,13 @@ This module shows the product's cost and margin from the pricelists.
53
62
  Usage
54
63
  =====
55
64
 
56
- * Go to "Sale > Products > Pricelists"
65
+ - Go to "Sale > Products > Pricelists"
66
+ - Open a pricelist form
67
+ - There are 3 new columns on the "Price rules" list.
57
68
 
58
- * Open a pricelist form
69
+ |Pricelist Item|
59
70
 
60
- * There are 3 new columns on the "Price rules" list.
61
- .. image:: https://raw.githubusercontent.com/OCA/product-attribute/16.0/product_pricelist_margin/static/description/pricelist_item.png
71
+ .. |Pricelist Item| image:: https://raw.githubusercontent.com/OCA/product-attribute/18.0/product_pricelist_margin/static/description/pricelist_item.png
62
72
 
63
73
  Bug Tracker
64
74
  ===========
@@ -66,7 +76,7 @@ Bug Tracker
66
76
  Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/issues>`_.
67
77
  In case of trouble, please check there if your issue has already been reported.
68
78
  If you spotted it first, help us to smash it by providing a detailed and welcomed
69
- `feedback <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_pricelist_margin%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
79
+ `feedback <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_pricelist_margin%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
70
80
 
71
81
  Do not contact contributors directly about support or help with technical issues.
72
82
 
@@ -74,17 +84,18 @@ Credits
74
84
  =======
75
85
 
76
86
  Authors
77
- ~~~~~~~
87
+ -------
78
88
 
79
89
  * Camptocamp
80
90
 
81
91
  Contributors
82
- ~~~~~~~~~~~~
92
+ ------------
83
93
 
84
- * Nguyen Minh Chien <chien@trobz.com>
94
+ - Nguyen Minh Chien <chien@trobz.com>
95
+ - Telmo Santos <telmo.santos@camptocamp.com>
85
96
 
86
97
  Maintainers
87
- ~~~~~~~~~~~
98
+ -----------
88
99
 
89
100
  This module is maintained by the OCA.
90
101
 
@@ -96,6 +107,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
96
107
  mission is to support the collaborative development of Odoo features and
97
108
  promote its widespread use.
98
109
 
99
- This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/16.0/product_pricelist_margin>`_ project on GitHub.
110
+ This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/18.0/product_pricelist_margin>`_ project on GitHub.
100
111
 
101
112
  You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
@@ -0,0 +1,23 @@
1
+ odoo/addons/product_pricelist_margin/README.rst,sha256=CgDMeIOJ-2LbFd96PD1bKL6MRzb-f_GPr9TNZ-2FlsY,3719
2
+ odoo/addons/product_pricelist_margin/__init__.py,sha256=X9EJGOE2GtZbS0G82PtSXmWSZ_R8jEM0rlJTDliQjp4,21
3
+ odoo/addons/product_pricelist_margin/__manifest__.py,sha256=XfxH_JtXs-KULtKVGLsVZebU_PS0egz25Bq15-f1X90,572
4
+ odoo/addons/product_pricelist_margin/i18n/fr.pot,sha256=gvpSUOzdZfnw8PARtbfaNK7NQDhjpU9tD0AJbOlao0E,1643
5
+ odoo/addons/product_pricelist_margin/i18n/it.po,sha256=lTPFm7mzokdhWkjvk6ppiwvKLvyGvj1JpVIX-vnNwlU,2117
6
+ odoo/addons/product_pricelist_margin/i18n/product_pricelist_margin.pot,sha256=huEyEq8mJUQ6jJSWDSUiEa2U0amuf1O0L-ZF6cBhsMs,1385
7
+ odoo/addons/product_pricelist_margin/i18n/product_pricelist_margins.pot,sha256=QxKxHYMfnmBCm-hgu9q0w-VZ1GL95TPJYI697El79BI,1598
8
+ odoo/addons/product_pricelist_margin/models/__init__.py,sha256=5O-ZCP4vtIwGNcyevX6dEHWtAgA-rVUcHEiBf70zr4o,37
9
+ odoo/addons/product_pricelist_margin/models/product_pricelist_item.py,sha256=yLcPlth5X2QAO0ktoneGdlQw6vWMEApwr_VPBikhAEQ,2373
10
+ odoo/addons/product_pricelist_margin/readme/CONTRIBUTORS.md,sha256=keOCAepnzoIVmdKysqZaH7YJnUW_EI06PrraDR4GPFM,91
11
+ odoo/addons/product_pricelist_margin/readme/DESCRIPTION.md,sha256=Q6-xRPv76j0y9rBcDA6w53c9b9Ibr9sjIKlOARaErUs,344
12
+ odoo/addons/product_pricelist_margin/readme/USAGE.md,sha256=umNyY6YJ-Et4f50_wAbMaA-ayf86Lg7fR_1aqwSpfEw,177
13
+ odoo/addons/product_pricelist_margin/static/description/icon.png,sha256=6xBPJauaFOF0KDHfHgQopSc28kKvxMaeoQFQWZtfZDo,9455
14
+ odoo/addons/product_pricelist_margin/static/description/index.html,sha256=HE4Vo8vzUQhN6nrAzF7jSHpcoV8V2tr3KLIoiog9r-4,13395
15
+ odoo/addons/product_pricelist_margin/static/description/pricelist_item.png,sha256=HRwmmahzytnJiRoDziaVM_c6HKmXKxXpRlC_gYaoJ1M,50455
16
+ odoo/addons/product_pricelist_margin/tests/__init__.py,sha256=UKD8x1fiapNCuRoRZroT8v_O7QHI1P4GHKEjteEq41E,26
17
+ odoo/addons/product_pricelist_margin/tests/test_margin.py,sha256=hhpYvKJem1hiwUAxMFQkpbULUx_WgoYxK1bcWW9DGOU,1855
18
+ odoo/addons/product_pricelist_margin/views/product_pricelist_item_views.xml,sha256=nM6uTRcpgiolesfq3maF1j0Rp-uNM-06AqpEuoGVTTs,1869
19
+ odoo/addons/product_pricelist_margin/views/product_pricelist_views.xml,sha256=5jzXihUW__fSrLAiHvaZsEOJbzJgxWybbmd1jUyIV_Y,939
20
+ odoo_addon_product_pricelist_margin-18.0.1.0.0.2.dist-info/METADATA,sha256=RwJa6I3mXCWjjE5yfYfIMrf7ydZJ4Ywk81LEmKbPJdY,4322
21
+ odoo_addon_product_pricelist_margin-18.0.1.0.0.2.dist-info/WHEEL,sha256=ZhOvUsYhy81Dx67gN3TV0RchQWBIIzutDZaJODDg2Vo,81
22
+ odoo_addon_product_pricelist_margin-18.0.1.0.0.2.dist-info/top_level.txt,sha256=QE6RBQ0QX5f4eFuUcGgU5Kbq1A_qJcDs-e_vpr6pmfU,4
23
+ odoo_addon_product_pricelist_margin-18.0.1.0.0.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.45.1)
2
+ Generator: Whool 1.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1 +0,0 @@
1
- * Nguyen Minh Chien <chien@trobz.com>
@@ -1 +0,0 @@
1
- This module shows the product's cost and margin from the pricelists.
@@ -1,6 +0,0 @@
1
- * Go to "Sale > Products > Pricelists"
2
-
3
- * Open a pricelist form
4
-
5
- * There are 3 new columns on the "Price rules" list.
6
- .. image:: ../static/description/pricelist_item.png
@@ -1,23 +0,0 @@
1
- odoo/addons/product_pricelist_margin/README.rst,sha256=3WTwkbV6M6C77XZlLZ7gS5lTpR5Ou_qnoFtiVr9m2Dg,3202
2
- odoo/addons/product_pricelist_margin/__init__.py,sha256=X9EJGOE2GtZbS0G82PtSXmWSZ_R8jEM0rlJTDliQjp4,21
3
- odoo/addons/product_pricelist_margin/__manifest__.py,sha256=dTIJ_RF8CZ5Fl0EFQ8CJF1EG4zUrkDTssgCYvfCvyQ0,572
4
- odoo/addons/product_pricelist_margin/i18n/fr.pot,sha256=gvpSUOzdZfnw8PARtbfaNK7NQDhjpU9tD0AJbOlao0E,1643
5
- odoo/addons/product_pricelist_margin/i18n/it.po,sha256=lTPFm7mzokdhWkjvk6ppiwvKLvyGvj1JpVIX-vnNwlU,2117
6
- odoo/addons/product_pricelist_margin/i18n/product_pricelist_margin.pot,sha256=DzN3dyKPk91lOR4KZ1inU3xEA_0r5Mt2NRvqmve-KMo,1507
7
- odoo/addons/product_pricelist_margin/i18n/product_pricelist_margins.pot,sha256=QxKxHYMfnmBCm-hgu9q0w-VZ1GL95TPJYI697El79BI,1598
8
- odoo/addons/product_pricelist_margin/models/__init__.py,sha256=5O-ZCP4vtIwGNcyevX6dEHWtAgA-rVUcHEiBf70zr4o,37
9
- odoo/addons/product_pricelist_margin/models/product_pricelist_item.py,sha256=c0osh3rUUh7uf6vwew1cz6h3A3lJ3enhR_1FAQfGBE4,2177
10
- odoo/addons/product_pricelist_margin/readme/CONTRIBUTORS.rst,sha256=UJyDuCaB8tf9geXoaMc1oLOtC48nG131wx1ettF4BLY,38
11
- odoo/addons/product_pricelist_margin/readme/DESCRIPTION.rst,sha256=ssHn8TRsMaxSSCph4gwLkihlh0vaMI650tE4gy7G0rQ,69
12
- odoo/addons/product_pricelist_margin/readme/USAGE.rst,sha256=4bnXuUc-k5UL0X22YiBwpNooPMjqgcu2ZA3BBVJfN5E,172
13
- odoo/addons/product_pricelist_margin/static/description/icon.png,sha256=6xBPJauaFOF0KDHfHgQopSc28kKvxMaeoQFQWZtfZDo,9455
14
- odoo/addons/product_pricelist_margin/static/description/index.html,sha256=aqsB6YmT-1teJG3r4TWtdf6KoV798SGokeuxUIDGg88,12938
15
- odoo/addons/product_pricelist_margin/static/description/pricelist_item.png,sha256=HRwmmahzytnJiRoDziaVM_c6HKmXKxXpRlC_gYaoJ1M,50455
16
- odoo/addons/product_pricelist_margin/tests/__init__.py,sha256=UKD8x1fiapNCuRoRZroT8v_O7QHI1P4GHKEjteEq41E,26
17
- odoo/addons/product_pricelist_margin/tests/test_margin.py,sha256=EN04IOflZKUauVt0DbJT5onuVhBnJCyQ_qDBCuCsHMQ,1424
18
- odoo/addons/product_pricelist_margin/views/product_pricelist_item_views.xml,sha256=XwqCnck9dfZGt50odzC_DaAkrCZObYtSmg0xKtvv2zE,1929
19
- odoo/addons/product_pricelist_margin/views/product_pricelist_views.xml,sha256=g74Tkw7zVoa6CNJEpgLLkDaLHiFArB7kdJnfjX4GAXg,1650
20
- odoo_addon_product_pricelist_margin-16.0.1.0.0.3.dist-info/METADATA,sha256=oPMgvew2uFkOOFzh9xz94v-RXoRgjp_sSuXaYctiH0A,3776
21
- odoo_addon_product_pricelist_margin-16.0.1.0.0.3.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
22
- odoo_addon_product_pricelist_margin-16.0.1.0.0.3.dist-info/top_level.txt,sha256=qBj40grFkGOfDZ2WDSw3y1RnDlgG0u8rP8pvGNdbz4w,5
23
- odoo_addon_product_pricelist_margin-16.0.1.0.0.3.dist-info/RECORD,,