product_category.py 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. # -*- coding: utf-8 -*-
  2. # Part of BiztechCS. See LICENSE file for full copyright and licensing details.
  3. from openerp import api, fields, models, _
  4. class product_category(models.Model):
  5. _inherit = 'product.public.category'
  6. include_in_menu = fields.Boolean(
  7. string="Include in Navigation Menu", help="Include in Navigation Menu")
  8. class website(models.Model):
  9. _inherit = 'website'
  10. def get_product_category(self):
  11. category_obj = self.env['product.public.category']
  12. category_ids = category_obj.search(
  13. [('parent_id', '=', False), ('include_in_menu', '!=', False)])
  14. if category_ids and len(category_ids) > 5:
  15. category_ids = category_ids[:5]
  16. elif category_ids and len(category_ids) <= 5:
  17. category_ids = category_ids
  18. return category_ids
  19. def get_product_child_category(self, child_id):
  20. category_obj = self.env['product.public.category']
  21. category_ids = category_obj.search(
  22. [('parent_id', '=', child_id), ('include_in_menu', '!=', False)], order="sequence asc")
  23. return category_ids