product_category.py 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. # -*- coding: utf-8 -*-
  2. # Part of BiztechCS. See LICENSE file for full copyright and licensing details.
  3. from openerp.osv import osv, orm, fields
  4. class product_category(osv.Model):
  5. _inherit='product.public.category'
  6. _columns={
  7. 'include_in_menu':fields.boolean("Include in Navigation Menu",help="Include in Navigation Menu"),
  8. }
  9. product_category()
  10. class website(osv.Model):
  11. _inherit = 'website'
  12. def get_product_category(self, cr, uid,ids,context=None):
  13. category_ids=self.pool.get('product.public.category').search(cr,uid,[('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. category_data = self.pool.get('product.public.category').browse(cr,uid,category_ids,context)
  19. return category_data
  20. def get_product_child_category(self, cr, uid,ids,child_id,context=None):
  21. category_ids=self.pool.get('product.public.category').search(cr,uid,[('parent_id', '=', child_id),('include_in_menu','!=',False)],order="sequence asc")
  22. category_data = self.pool.get('product.public.category').browse(cr,uid,category_ids,context)
  23. return category_data
  24. # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: