Odoo Help


Filtration in xml view

Noble Man
on 4/2/15, 9:39 AM 920 views

what I am trying to do is I have three product type (free, restricted and other) that can be sold for certain customers only. So, what I have done is I created product_tag objects which contains product type

class product_tag(osv.osv):


_columns = {

'name': fields.char('Name', size=64, required=True),



and i created many2one relation with product 

'prod_tag':fields.many2one('product.tag', 'Item Tags'),
and  many2many relation with res.partner with inheritance 

class res_partner(osv.osv):


_inherit ='res.partner'

_columns = {

'cutomer_tag':fields.many2many('product.tag', 'rel_itemallowed_tag','item_category','tag_id','Allowed Item Tags'),



 this many2many relation helps to update customer's level either to buy one type or multiple product type, so what i want is how can i filter products in sales order by analyzing product tag and customer tag (by filtering product type by customer tag)?

Like if a customer tag is 'free' and  'other' all products those are free and othe type only to be visible in  many2one product filed of sale order form 


Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--

| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 4/4/15, 12:52 PM


override search function in class product.product :

verify in my code :

self.pool.get('res.partner').browse(cr, uid, context['partner_id'], context=context).cutomer_tag

will return a list of id, else modify my code to get a list of id.

my code (I use search function used in opernerp v8):

def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):

     context = context or {}

     if context.get('partner_id'):

     # add to domain (variable args in body function),  prod_tag = False and customer tags

         prod_tag_ids = [False] + self.pool.get('res.partner').browse(cr, uid, context['partner_id'], context=context).cutomer_tag or []

         args.append((('prod_tag', 'in', prod_tag_ids)))

     return super(product_product, self).search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=count)


Noble Man
On 4/15/15, 4:15 AM

@Cyril Gaspard, Thank you and I am using v7. I managed to override it but I am getting this error "Iteration is not allowed on browse_record(product.tag, 1)" .

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/2/15, 9:39 AM
Seen: 920 times
Last updated: 2/12/16, 2:23 AM