Skip to content

Commit

Permalink
run precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
victor-champonnois committed May 10, 2023
1 parent cd7972f commit e8b44b6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions product_top_category/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"summary": """Compute the Top Category of Products""",
"version": "12.0.1.0.0",
"category": "Sale",
"website": "https://coopiteasy.be",
"author": "Coop IT Easy SC",
"website": "https://github.com/OCA/product-attribute",
"author": "Coop IT Easy SC, Odoo Community Association (OCA)",
"maintainers": ["victor-champonnois"],
"license": "AGPL-3",
"application": False,
Expand Down
7 changes: 4 additions & 3 deletions product_top_category/models/product_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ def _get_top_category(self):
self.ensure_one()
if self.parent_id:
return self.parent_id._get_top_category()
else:
else:
return self

@api.depends('parent_id', 'parent_id.top_categ_id')
def _compute_top_category(self):
for categ in self:
categ.top_categ_id = categ._get_top_category()


top_categ_id = fields.Many2one('product.category',
compute=_compute_top_category, string="Product Top Category", store=True)
compute=_compute_top_category,
string="Product Top Category",
store=True)
6 changes: 3 additions & 3 deletions product_top_category/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class ProductTemplate(models.Model):
_inherit = "product.template"

top_categ_id = fields.Many2one('product.category',
related='categ_id.top_categ_id',
store=True)
related='categ_id.top_categ_id',
store=True)
6 changes: 6 additions & 0 deletions setup/product_top_category/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit e8b44b6

Please sign in to comment.