Skip to content

Commit 036d25d

Browse files
authored
Merge pull request #1403 from OCA/16.0
Syncing from upstream OCA/product-attribute (16.0)
2 parents a8e1b60 + 079d59b commit 036d25d

12 files changed

Lines changed: 141 additions & 55 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ addon | version | maintainers | summary
6464
[product_net_weight](product_net_weight/) | 16.0.1.0.0 | <a href='https://github.com/legalsylvain'><img src='https://github.com/legalsylvain.png' width='32' height='32' style='border-radius:50%;' alt='legalsylvain'/></a> | Add 'Net Weight' on product models
6565
[product_optional_product_quantity](product_optional_product_quantity/) | 16.0.1.1.0 | | Specify optional products quantity for product
6666
[product_origin](product_origin/) | 16.0.1.0.0 | <a href='https://github.com/rousseldenis'><img src='https://github.com/rousseldenis.png' width='32' height='32' style='border-radius:50%;' alt='rousseldenis'/></a> <a href='https://github.com/legalsylvain'><img src='https://github.com/legalsylvain.png' width='32' height='32' style='border-radius:50%;' alt='legalsylvain'/></a> | Adds the origin of the product
67-
[product_packaging_container_deposit](product_packaging_container_deposit/) | 16.0.1.2.0 | | Add container deposit fees in a order
67+
[product_packaging_container_deposit](product_packaging_container_deposit/) | 16.0.1.2.1 | | Add container deposit fees in a order
6868
[product_packaging_dimension](product_packaging_dimension/) | 16.0.1.1.1 | | Manage packaging dimensions and weight
6969
[product_packaging_level](product_packaging_level/) | 16.0.1.2.1 | | This module binds a product packaging to a packaging level
7070
[product_packaging_level_purchasable](product_packaging_level_purchasable/) | 16.0.1.1.0 | | Control purchase of products via packaging settings.
7171
[product_packaging_level_salable](product_packaging_level_salable/) | 16.0.1.0.0 | | Product Packaging level salable
72-
[product_pricelist_alternative](product_pricelist_alternative/) | 16.0.1.2.0 | | Calculate product price based on alternative pricelists
72+
[product_pricelist_alternative](product_pricelist_alternative/) | 16.0.1.2.1 | | Calculate product price based on alternative pricelists
7373
[product_pricelist_direct_print](product_pricelist_direct_print/) | 16.0.1.3.1 | <a href='https://github.com/legalsylvain'><img src='https://github.com/legalsylvain.png' width='32' height='32' style='border-radius:50%;' alt='legalsylvain'/></a> | Print price list from menu option, product templates, products variants or price lists
7474
[product_pricelist_direct_print_company_group](product_pricelist_direct_print_company_group/) | 16.0.1.0.0 | | Print Pricelist items using the company group model
7575
[product_pricelist_direct_print_website_sale](product_pricelist_direct_print_website_sale/) | 16.0.1.0.0 | <a href='https://github.com/CarlosRoca13'><img src='https://github.com/CarlosRoca13.png' width='32' height='32' style='border-radius:50%;' alt='CarlosRoca13'/></a> | Extend Product Pricelist Direct Print for filter by public categories

product_packaging_container_deposit/README.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
15
===================================
26
Product Packaging Container Deposit
37
===================================
@@ -7,13 +11,13 @@ Product Packaging Container Deposit
711
!! This file is generated by oca-gen-addon-readme !!
812
!! changes will be overwritten. !!
913
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:99a5d919b3a017ca6032d6bd9c7e3804a2bc3b8cd0edff0e902c2c2f45c7fad9
14+
!! source digest: sha256:fb2b09c1d84254e1245d1b076aa016d57982fd7593e072dbcdee46c13770dfce
1115
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1216
1317
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1418
:target: https://odoo-community.org/page/development-status
1519
: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
1721
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1822
:alt: License: AGPL-3
1923
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github

product_packaging_container_deposit/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
{
55
"name": "Product Packaging Container Deposit",
6-
"version": "16.0.1.2.0",
6+
"version": "16.0.1.2.1",
77
"development_status": "Beta",
88
"category": "Product",
99
"summary": "Add container deposit fees in a order",

product_packaging_container_deposit/models/container_deposit_order_mixin.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@ def update_order_container_deposit_quantity(self):
4040
)
4141
line_ids_to_delete = []
4242
for order in self:
43+
lines = order[self._get_order_line_field()]
44+
fieldname_line_product_qty = lines._get_product_qty_field()
45+
fieldname_line_product_qty_delivered_received = (
46+
lines._get_product_qty_delivered_received_field()
47+
)
4348
# Lines to compute container deposit
44-
lines_to_comp_deposit = order[self._get_order_line_field()].filtered(
49+
lines_to_comp_deposit = lines.filtered(
4550
lambda ln: (
4651
ln.product_packaging_id.package_type_id.container_deposit_product_id
4752
)
@@ -52,15 +57,15 @@ def update_order_container_deposit_quantity(self):
5257
)
5358
lines_to_update = {}
5459
lines_to_create = []
55-
for line in self[self._get_order_line_field()]:
60+
for line in lines:
5661
if not line.is_container_deposit:
5762
continue
5863
qty, qty_dlvd_rcvd = deposit_container_qties.pop(
5964
line["product_id"], [False, False]
6065
)
6166
if not qty:
6267
new_vals = {
63-
line._get_product_qty_field(): 0,
68+
fieldname_line_product_qty: 0,
6469
}
6570
if order.state == "draft":
6671
# values_lst.append(Command.delete(line.id))
@@ -71,10 +76,17 @@ def update_order_container_deposit_quantity(self):
7176
lines_to_update[line.id] = new_vals
7277

7378
else:
74-
lines_to_update[line.id] = {
75-
line._get_product_qty_field(): qty,
76-
line._get_product_qty_delivered_received_field(): qty_dlvd_rcvd,
77-
}
79+
lines_to_update[line.id] = values = {}
80+
if line[fieldname_line_product_qty] != qty:
81+
values[fieldname_line_product_qty] = qty
82+
if (
83+
line[fieldname_line_product_qty_delivered_received]
84+
!= qty_dlvd_rcvd
85+
):
86+
values[
87+
fieldname_line_product_qty_delivered_received
88+
] = qty_dlvd_rcvd
89+
7890
for product in deposit_container_qties:
7991
if deposit_container_qties[product][0]:
8092
values = order.prepare_deposit_container_line(
@@ -84,7 +96,9 @@ def update_order_container_deposit_quantity(self):
8496
lines_to_create.append(values)
8597
line_model = self._fields[self._get_order_line_field()].comodel_name
8698
for line_id, values in lines_to_update.items():
87-
self.env[line_model].browse(line_id).exists().write(values)
99+
line = self.env[line_model].browse(line_id).exists()
100+
if line and values:
101+
line.write(values)
88102
if lines_to_create:
89103
self.env[line_model].create(lines_to_create)
90104
# Schedule line to delete after commit to avoid caching issue w/ UI

product_packaging_container_deposit/static/description/index.html

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>Product Packaging Container Deposit</title>
6+
<title>README.rst</title>
77
<style type="text/css">
88

99
/*
@@ -360,16 +360,21 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document" id="product-packaging-container-deposit">
364-
<h1 class="title">Product Packaging Container Deposit</h1>
363+
<div class="document">
365364

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-packaging-container-deposit">
370+
<h1>Product Packaging Container Deposit</h1>
366371
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
367372
!! This file is generated by oca-gen-addon-readme !!
368373
!! changes will be overwritten. !!
369374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:99a5d919b3a017ca6032d6bd9c7e3804a2bc3b8cd0edff0e902c2c2f45c7fad9
375+
!! source digest: sha256:fb2b09c1d84254e1245d1b076aa016d57982fd7593e072dbcdee46c13770dfce
371376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<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_packaging_container_deposit"><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_packaging_container_deposit"><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>
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/16.0/product_packaging_container_deposit"><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_packaging_container_deposit"><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>
373378
<p>Allow to indicate on a product packaging package type that it comes with a container deposit. The deposit product should be a service product.
374379
For instance, you can create a package type “plastic box” and indicate as container deposit “plastic box deposit”.</p>
375380
<p>Use the corresponding sales and purchase modules to add the deposit fees in the order. Each packaging level can have a deposit. The biggest package type of each packaging level will be used in the computation unless a specific package type is given on the order line.</p>
@@ -386,32 +391,32 @@ <h1 class="title">Product Packaging Container Deposit</h1>
386391
</ul>
387392
</div>
388393
<div class="section" id="bug-tracker">
389-
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
394+
<h2><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h2>
390395
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/product-attribute/issues">GitHub Issues</a>.
391396
In case of trouble, please check there if your issue has already been reported.
392397
If you spotted it first, help us to smash it by providing a detailed and welcomed
393398
<a class="reference external" href="https://github.com/OCA/product-attribute/issues/new?body=module:%20product_packaging_container_deposit%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
394399
<p>Do not contact contributors directly about support or help with technical issues.</p>
395400
</div>
396401
<div class="section" id="credits">
397-
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
402+
<h2><a class="toc-backref" href="#toc-entry-2">Credits</a></h2>
398403
<div class="section" id="authors">
399-
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
404+
<h3><a class="toc-backref" href="#toc-entry-3">Authors</a></h3>
400405
<ul class="simple">
401406
<li>Camptocamp</li>
402407
<li>BCIM</li>
403408
</ul>
404409
</div>
405410
<div class="section" id="contributors">
406-
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
411+
<h3><a class="toc-backref" href="#toc-entry-4">Contributors</a></h3>
407412
<ul class="simple">
408413
<li>Telmo Santos &lt;<a class="reference external" href="mailto:telmo.santos&#64;camptocamp.com">telmo.santos&#64;camptocamp.com</a>&gt;</li>
409414
<li>Jacques-Etienne Baudoux (BCIM) &lt;<a class="reference external" href="mailto:je&#64;bcim.be">je&#64;bcim.be</a>&gt;</li>
410415
<li>Simone Orsi &lt;<a class="reference external" href="mailto:simone.orsi&#64;camptocamp.com">simone.orsi&#64;camptocamp.com</a>&gt;</li>
411416
</ul>
412417
</div>
413418
<div class="section" id="maintainers">
414-
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
419+
<h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
415420
<p>This module is maintained by the OCA.</p>
416421
<a class="reference external image-reference" href="https://odoo-community.org">
417422
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -424,5 +429,6 @@ <h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
424429
</div>
425430
</div>
426431
</div>
432+
</div>
427433
</body>
428434
</html>

product_pricelist_alternative/README.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
15
=============================
26
Product Pricelist Alternative
37
=============================
@@ -7,13 +11,13 @@ Product Pricelist Alternative
711
!! This file is generated by oca-gen-addon-readme !!
812
!! changes will be overwritten. !!
913
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:d0c65497950562e7e7984650f3fd3c19fe1edb10d0bf08eb62523523436aa7f1
14+
!! source digest: sha256:cee97fb5bf7cd4cb64b1dc06958ca21fea79d0e8a88c29aeb9ff868d9f79ed84
1115
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1216
1317
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1418
:target: https://odoo-community.org/page/development-status
1519
: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
1721
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1822
:alt: License: AGPL-3
1923
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github

product_pricelist_alternative/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
{
55
"name": "Product Pricelist Alternative",
6-
"version": "16.0.1.2.0",
6+
"version": "16.0.1.2.1",
77
"development_status": "Beta",
88
"category": "Product",
99
"summary": "Calculate product price based on alternative pricelists",

product_pricelist_alternative/models/product_pricelist.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,31 @@ def _compute_price_rule(self, products, qty, uom=None, date=False, **kwargs):
6262

6363
# In some contexts we want to ignore alternative pricelists
6464
# and return the original price
65-
if self.env.context.get("skip_alternative_pricelist", False):
65+
if self.env.context.get(
66+
"skip_alternative_pricelist", False
67+
) or self.env.context.get("based_on_other_pricelist", False):
6668
return res
69+
pricelist_items_ids = [val[1] for val in res.values()]
70+
use_lower_price_item = (
71+
self.env["product.pricelist.item"]
72+
.browse(pricelist_items_ids)
73+
.filtered(lambda rec: rec.alternative_pricelist_policy == "use_lower_price")
74+
)
75+
use_lower_price_item_ids = set(use_lower_price_item.ids)
6776

68-
for product in products:
69-
reference_pricelist_item = self.env["product.pricelist.item"].browse(
70-
res[product.id][1]
77+
products_with_use_lower_price = products.filtered(
78+
lambda rec: res[rec.id][1] in use_lower_price_item_ids
79+
)
80+
for alternative_pricelist in self.alternative_pricelist_ids:
81+
alternative_res = alternative_pricelist._compute_price_rule(
82+
products_with_use_lower_price, qty, uom, date, **kwargs
7183
)
72-
if (
73-
reference_pricelist_item.alternative_pricelist_policy
74-
== "use_lower_price"
75-
):
76-
for alternative_pricelist in self.alternative_pricelist_ids:
77-
alternative_price_rule = alternative_pricelist._compute_price_rule(
78-
product, qty, uom=uom, date=date, **kwargs
79-
)
80-
# use alternative price if lower
81-
if alternative_price_rule[product.id][0] < res[product.id][0]:
82-
res[product.id] = alternative_price_rule[product.id]
84+
for product_id, (
85+
alternative_price,
86+
alternative_item_id,
87+
) in alternative_res.items():
88+
if alternative_price < res[product_id][0]:
89+
res[product_id] = (alternative_price, alternative_item_id)
8390
return res
8491

8592
@api.constrains("alternative_pricelist_ids")

product_pricelist_alternative/models/product_pricelist_item.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,8 @@ def _check_pricelist_alternative_items_based_on_other_pricelist(self):
3333
" Please change to another type of price computation."
3434
)
3535
)
36+
37+
def _compute_price(self, product, quantity, uom, date, currency=None):
38+
if self.compute_price == "formula" and self.base == "pricelist":
39+
self = self.with_context(based_on_other_pricelist=True)
40+
return super()._compute_price(product, quantity, uom, date, currency)

0 commit comments

Comments
 (0)