Skip to content

Commit d372f60

Browse files
authored
Merge pull request #1613 from OCA/18.0
Syncing from upstream OCA/product-attribute (18.0)
2 parents 2aa31d9 + 1e006e2 commit d372f60

10 files changed

Lines changed: 44 additions & 11 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ addon | version | maintainers | summary
7272
[product_pricelist_alternative](product_pricelist_alternative/) | 18.0.1.0.0 | | Calculate product price based on alternative pricelists
7373
[product_pricelist_assortment](product_pricelist_assortment/) | 18.0.1.0.1 | | Product assortment and pricelist
7474
[product_pricelist_by_contact](product_pricelist_by_contact/) | 18.0.1.0.0 | | Product Pricelist Per Contact
75-
[product_pricelist_direct_print](product_pricelist_direct_print/) | 18.0.1.1.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> | Print price list from menu option, product templates, products variants or price lists
75+
[product_pricelist_direct_print](product_pricelist_direct_print/) | 18.0.1.1.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
7676
[product_pricelist_direct_print_company_group](product_pricelist_direct_print_company_group/) | 18.0.1.0.0 | | Print Pricelist items using the company group model
7777
[product_pricelist_direct_print_website_sale](product_pricelist_direct_print_website_sale/) | 18.0.1.0.1 | <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
78-
[product_pricelist_direct_print_xlsx](product_pricelist_direct_print_xlsx/) | 18.0.1.0.2 | | Print price list in XLSX format
78+
[product_pricelist_direct_print_xlsx](product_pricelist_direct_print_xlsx/) | 18.0.1.0.3 | | Print price list in XLSX format
7979
[product_pricelist_discount_by_range](product_pricelist_discount_by_range/) | 18.0.1.0.0 | | Allows to create priceslists with discount ranges
8080
[product_pricelist_fixed_currency_rate](product_pricelist_fixed_currency_rate/) | 18.0.1.0.1 | <a href='https://github.com/LoisRForgeFlow'><img src='https://github.com/LoisRForgeFlow.png' width='32' height='32' style='border-radius:50%;' alt='LoisRForgeFlow'/></a> <a href='https://github.com/kobros-tech'><img src='https://github.com/kobros-tech.png' width='32' height='32' style='border-radius:50%;' alt='kobros-tech'/></a> | Set a fixed currency rate between pricelists
8181
[product_pricelist_item_list_view](product_pricelist_item_list_view/) | 18.0.1.0.0 | <a href='https://github.com/LoisRForgeFlow'><img src='https://github.com/LoisRForgeFlow.png' width='32' height='32' style='border-radius:50%;' alt='LoisRForgeFlow'/></a> | View and search the list of pricelist items

product_pricelist_direct_print/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Product Pricelist Direct Print
1111
!! This file is generated by oca-gen-addon-readme !!
1212
!! changes will be overwritten. !!
1313
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14-
!! source digest: sha256:a12c01596213a3647cfc6109b3cdff7fa93db0e1b6488c61ee2a5f474117d93b
14+
!! source digest: sha256:0c5e0096d45b292129979ae295c2839347859eae02f1c711bda9e6036b8cea4e
1515
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1616
1717
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png

product_pricelist_direct_print/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Product Pricelist Direct Print",
66
"summary": "Print price list from menu option, product templates, "
77
"products variants or price lists",
8-
"version": "18.0.1.1.0",
8+
"version": "18.0.1.1.1",
99
"category": "Product",
1010
"website": "https://github.com/OCA/product-attribute",
1111
"author": "Tecnativa, GRAP, Odoo Community Association (OCA)",

product_pricelist_direct_print/reports/report_product_pricelist.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<template id="report_product_pricelist_document">
66
<t t-call="web.html_container">
77
<t t-set="o" t-value="o.with_context(lang=o.lang)" />
8+
<t
9+
t-set="o"
10+
t-value="o.with_context(product_prices=o._get_product_prices(o.get_products_to_print()))"
11+
/>
812
<t t-set="pricelist" t-value="o.get_pricelist_to_print()" />
913
<t t-set="company" t-value="pricelist.company_id or env.company" />
1014
<t t-call="web.external_layout">

product_pricelist_direct_print/static/description/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ <h1>Product Pricelist Direct Print</h1>
372372
!! This file is generated by oca-gen-addon-readme !!
373373
!! changes will be overwritten. !!
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375-
!! source digest: sha256:a12c01596213a3647cfc6109b3cdff7fa93db0e1b6488c61ee2a5f474117d93b
375+
!! source digest: sha256:0c5e0096d45b292129979ae295c2839347859eae02f1c711bda9e6036b8cea4e
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377377
<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_direct_print"><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_direct_print"><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>
378378
<p>Print price list from menu option, product templates, products variants

product_pricelist_direct_print/wizards/product_pricelist_print.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,36 @@ class ProductPricelistPrint(models.TransientModel):
9797
def _onchange_categ_ids(self):
9898
self.print_child_categories = len(self.categ_ids) > 0
9999

100+
def _get_product_prices(self, products):
101+
"""Return ``{product_id: price}`` computing every product in a single
102+
batched call.
103+
104+
The native ``_compute_price_rule`` fetches the applicable rules once for
105+
the whole recordset, so calling it once for all the products avoids the
106+
N+1 of recomputing the price (and re-searching the rules) per report
107+
row. The result is meant to be injected in the context as
108+
``product_prices`` so ``_compute_product_price`` reads it instead of
109+
recomputing.
110+
"""
111+
self.ensure_one()
112+
if not products:
113+
return {}
114+
return self.get_pricelist_to_print()._get_products_price(
115+
products, 1, date=self.date
116+
)
117+
100118
@api.depends_context("product")
101119
def _compute_product_price(self):
102120
product = self.env.context["product"]
103-
price = self.get_pricelist_to_print()._get_product_price(
104-
product, 1, date=self.date
105-
)
121+
# Reuse the batched prices injected by the report when available to
122+
# avoid recomputing the price (and re-searching the rules) per product.
123+
prices = self.env.context.get("product_prices")
124+
if prices is not None and product.id in prices:
125+
price = prices[product.id]
126+
else:
127+
price = self.get_pricelist_to_print()._get_product_price(
128+
product, 1, date=self.date
129+
)
106130
if self.vat_mode == "vat_excl":
107131
self.product_price = product.taxes_id.compute_all(price)["total_excluded"]
108132
elif self.vat_mode == "vat_incl":

product_pricelist_direct_print_xlsx/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Product Pricelist Direct Print (XLSX)
1111
!! This file is generated by oca-gen-addon-readme !!
1212
!! changes will be overwritten. !!
1313
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14-
!! source digest: sha256:0f7edad20ac09e9fb78de60a6ee62e9ae88e362fba9b420bbd129f81bda79750
14+
!! source digest: sha256:d01459cfcc4c9c8047832601c2e0bb73d161ba4b006aad27a17bdc082c4482a2
1515
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1616
1717
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png

product_pricelist_direct_print_xlsx/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Product Pricelist Direct Print (XLSX)",
66
"summary": "Print price list in XLSX format",
7-
"version": "18.0.1.0.2",
7+
"version": "18.0.1.0.3",
88
"category": "Product",
99
"website": "https://github.com/OCA/product-attribute",
1010
"author": "Tecnativa, GRAP, Odoo Community Association (OCA)",

product_pricelist_direct_print_xlsx/report/product_pricelist_xlsx.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ def generate_xlsx_report(self, workbook, data, objects):
1717
self = self.with_context(
1818
lang=book.lang or self.env["res.users"].browse(book.create_uid.id).lang
1919
)
20+
# Precompute every product price in a single batched call so the price
21+
# column does not recompute (and re-search the pricelist rules) per row.
22+
book = book.with_context(
23+
product_prices=book._get_product_prices(book.get_products_to_print())
24+
)
2025
pricelist = book.get_pricelist_to_print()
2126
sheet = self._create_product_pricelist_sheet(workbook, book, pricelist, formats)
2227
sheet = self._fill_data(workbook, sheet, book, pricelist, formats)

product_pricelist_direct_print_xlsx/static/description/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ <h1>Product Pricelist Direct Print (XLSX)</h1>
372372
!! This file is generated by oca-gen-addon-readme !!
373373
!! changes will be overwritten. !!
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375-
!! source digest: sha256:0f7edad20ac09e9fb78de60a6ee62e9ae88e362fba9b420bbd129f81bda79750
375+
!! source digest: sha256:d01459cfcc4c9c8047832601c2e0bb73d161ba4b006aad27a17bdc082c4482a2
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377377
<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_direct_print_xlsx"><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_direct_print_xlsx"><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>
378378
<p>This module is based on the OCA module

0 commit comments

Comments
 (0)