Skip to content

Commit 2f7f79d

Browse files
migration-bot-adhocmatiasperalta1
authored andcommitted
[MIG] product_catalog_aeroo_report: Migration to 19.0
1 parent d3635e7 commit 2f7f79d

4 files changed

Lines changed: 20 additions & 17 deletions

File tree

product_catalog_aeroo_report/__manifest__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
##############################################################################
2020
{
2121
"name": "Product Catalog Aeroo Report",
22-
"version": "18.0.1.0.0",
22+
"version": "19.0.1.0.0",
2323
"category": "Aeroo Reporting",
2424
"sequence": 14,
2525
"summary": "",
@@ -43,7 +43,7 @@
4343
"demo/product_template_demo.xml",
4444
"demo/product_product_demo.xml",
4545
],
46-
"installable": False,
46+
"installable": True,
4747
"auto_install": False,
4848
"application": True,
4949
}

product_catalog_aeroo_report/demo/product_template_demo.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<field name="product_type">product.template</field>
99
<field name="prod_display_type">prod_per_line</field>
1010
<field name="report_id" ref="report_product_catalog_ods"/>
11-
<field name="category_ids" eval="[(4, ref('product.product_category_all'))]"/>
1211
</record>
1312

1413
<record id="catalog_demo2" model="product.product_catalog_report">
@@ -19,7 +18,6 @@
1918
<field name="product_type">product.template</field>
2019
<field name="prod_display_type">prod_list</field>
2120
<field name="report_id" ref="report_product_catalog_simple_odt"/>
22-
<field name="category_ids" eval="[(4, ref('product.product_category_all'))]"/>
2321
</record>
2422

2523
<record id="catalog_demo3" model="product.product_catalog_report">
@@ -30,7 +28,6 @@
3028
<field name="product_type">product.template</field>
3129
<field name="prod_display_type">variants</field>
3230
<field name="report_id" ref="report_product_catalog_by_categories_odt"/>
33-
<field name="category_ids" eval="[(4, ref('product.product_category_all'))]"/>
3431
</record>
3532

3633
</odoo>

product_catalog_aeroo_report/models/product_catalog_report.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class ProductCatalogReport(models.Model):
7676
)
7777

7878
def prepare_report(self):
79-
context = dict(self._context.copy())
79+
context = dict(self.env.context.copy())
8080
categories = self.category_ids
8181
# because this value usually cames from wizard, if we call report from
8282
# this model, we add taxes_included parameter

product_catalog_aeroo_report/report/parser.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# directory
44
##############################################################################
55
from odoo import _, api, fields, models
6+
from odoo.tools import formatLang
67

78

89
class Parser(models.AbstractModel):
@@ -13,20 +14,20 @@ class Parser(models.AbstractModel):
1314

1415
@api.model
1516
def aeroo_report(self, docids, data):
16-
self.env.print_product_uom = self._context.get("print_product_uom", False)
17-
self.env.product_type = self._context.get("product_type", "product.product")
18-
self.env.prod_display_type = self._context.get("prod_display_type", False)
19-
pricelist_ids = self._context.get("pricelist_ids", [])
20-
categories_order = self._context.get("categories_order", "")
17+
self.env.print_product_uom = self.env.context.get("print_product_uom", False)
18+
self.env.product_type = self.env.context.get("product_type", "product.product")
19+
self.env.prod_display_type = self.env.context.get("prod_display_type", False)
20+
pricelist_ids = self.env.context.get("pricelist_ids", [])
21+
categories_order = self.env.context.get("categories_order", "")
2122
pricelists = self.env["product.pricelist"].browse(pricelist_ids)
2223

2324
# Get categories ordered
24-
category_type = self._context.get("category_type", False)
25+
category_type = self.env.context.get("category_type", False)
2526
if category_type == "public_category":
2627
categories = self.env["product.public.category"]
2728
else:
2829
categories = self.env["product.category"]
29-
category_ids = self._context.get("category_ids", [])
30+
category_ids = self.env.context.get("category_ids", [])
3031
categories = categories.search([("id", "in", category_ids)], order=categories_order)
3132
products = self.get_products(category_ids)
3233
self = self.with_context(
@@ -39,9 +40,10 @@ def aeroo_report(self, docids, data):
3940
prod_display_type=self.env.prod_display_type,
4041
today=fields.Date.today(),
4142
get_price=self.get_price,
43+
get_formatted_price=self.get_formatted_price,
4244
get_description=self.get_description,
4345
get_products=self.get_products,
44-
context=self._context,
46+
context=self.env.context,
4547
field_value_get=self.field_value_get,
4648
)
4749
return super().aeroo_report(docids, data)
@@ -62,6 +64,10 @@ def get_price(self, product, pricelist):
6264
price = product_obj.browse([product.id])._get_contextual_price()
6365
return price
6466

67+
def get_formatted_price(self, product, pricelist):
68+
price = self.get_price(product, pricelist)
69+
return formatLang(self.env, price, currency_obj=pricelist.currency_id)
70+
6571
def get_description(self, product, print_product_uom):
6672
sale_uom = self.env["product.template"].fields_get(["sale_uom_ids"])
6773
# we force to not print default code because it's already shown in the reports.
@@ -84,9 +90,9 @@ def get_description(self, product, print_product_uom):
8490
def get_products(self, category_ids):
8591
if not isinstance(category_ids, list):
8692
category_ids = [category_ids]
87-
order = self._context.get("products_order", "")
88-
only_with_stock = self._context.get("only_with_stock", False)
89-
category_type = self._context.get("category_type", False)
93+
order = self.env.context.get("products_order", "")
94+
only_with_stock = self.env.context.get("only_with_stock", False)
95+
category_type = self.env.context.get("category_type", False)
9096
if category_type == "public_category":
9197
domain = [("public_categ_ids", "in", category_ids)]
9298
else:

0 commit comments

Comments
 (0)