Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions product_catalog_aeroo_report/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
"name": "Product Catalog Aeroo Report",
"version": "18.0.1.0.0",
"version": "19.0.1.0.0",
"category": "Aeroo Reporting",
"sequence": 14,
"summary": "",
Expand All @@ -43,7 +43,7 @@
"demo/product_template_demo.xml",
"demo/product_product_demo.xml",
],
"installable": False,
"installable": True,
"auto_install": False,
"application": True,
}
1 change: 0 additions & 1 deletion product_catalog_aeroo_report/demo/product_product_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
<field name="include_sub_categories" eval="True"/>
<field name="product_type">product.product</field>
<field name="report_id" ref="report_product_catalog_by_categories_odt"/>
<field name="category_ids" eval="[(4, ref('product.product_category_all'))]"/>
</record>
</odoo>
3 changes: 0 additions & 3 deletions product_catalog_aeroo_report/demo/product_template_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<field name="product_type">product.template</field>
<field name="prod_display_type">prod_per_line</field>
<field name="report_id" ref="report_product_catalog_ods"/>
<field name="category_ids" eval="[(4, ref('product.product_category_all'))]"/>
</record>

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

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

</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ProductCatalogReport(models.Model):
)

def prepare_report(self):
context = dict(self._context.copy())
context = dict(self.env.context.copy())
categories = self.category_ids
# because this value usually cames from wizard, if we call report from
# this model, we add taxes_included parameter
Expand Down
28 changes: 17 additions & 11 deletions product_catalog_aeroo_report/report/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# directory
##############################################################################
from odoo import _, api, fields, models
from odoo.tools import formatLang


class Parser(models.AbstractModel):
Expand All @@ -13,20 +14,20 @@ class Parser(models.AbstractModel):

@api.model
def aeroo_report(self, docids, data):
self.env.print_product_uom = self._context.get("print_product_uom", False)
self.env.product_type = self._context.get("product_type", "product.product")
self.env.prod_display_type = self._context.get("prod_display_type", False)
pricelist_ids = self._context.get("pricelist_ids", [])
categories_order = self._context.get("categories_order", "")
self.env.print_product_uom = self.env.context.get("print_product_uom", False)
self.env.product_type = self.env.context.get("product_type", "product.product")
self.env.prod_display_type = self.env.context.get("prod_display_type", False)
pricelist_ids = self.env.context.get("pricelist_ids", [])
categories_order = self.env.context.get("categories_order", "")
pricelists = self.env["product.pricelist"].browse(pricelist_ids)

# Get categories ordered
category_type = self._context.get("category_type", False)
category_type = self.env.context.get("category_type", False)
if category_type == "public_category":
categories = self.env["product.public.category"]
else:
categories = self.env["product.category"]
category_ids = self._context.get("category_ids", [])
category_ids = self.env.context.get("category_ids", [])
categories = categories.search([("id", "in", category_ids)], order=categories_order)
products = self.get_products(category_ids)
self = self.with_context(
Expand All @@ -39,9 +40,10 @@ def aeroo_report(self, docids, data):
prod_display_type=self.env.prod_display_type,
today=fields.Date.today(),
get_price=self.get_price,
get_formatted_price=self.get_formatted_price,
get_description=self.get_description,
get_products=self.get_products,
context=self._context,
context=self.env.context,
field_value_get=self.field_value_get,
)
return super().aeroo_report(docids, data)
Expand All @@ -62,6 +64,10 @@ def get_price(self, product, pricelist):
price = product_obj.browse([product.id])._get_contextual_price()
return price

def get_formatted_price(self, product, pricelist):
price = self.get_price(product, pricelist)
return formatLang(self.env, price, currency_obj=pricelist.currency_id)

def get_description(self, product, print_product_uom):
sale_uom = self.env["product.template"].fields_get(["sale_uom_ids"])
# we force to not print default code because it's already shown in the reports.
Expand All @@ -84,9 +90,9 @@ def get_description(self, product, print_product_uom):
def get_products(self, category_ids):
if not isinstance(category_ids, list):
category_ids = [category_ids]
order = self._context.get("products_order", "")
only_with_stock = self._context.get("only_with_stock", False)
category_type = self._context.get("category_type", False)
order = self.env.context.get("products_order", "")
only_with_stock = self.env.context.get("only_with_stock", False)
category_type = self.env.context.get("category_type", False)
if category_type == "public_category":
domain = [("public_categ_ids", "in", category_ids)]
else:
Expand Down