Odoo Help

Welcome!

This community 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.

0

Filtration in xml view

By
Noble Man
on 4/2/15, 9:39 AM 491 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):

_name="product.tag"

_columns = {

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

'code':fields.integer('Code'),

 product_tag()

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):

_name='res.partner'

_inherit ='res.partner'

_columns = {

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

}

res_partner()

 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 

1

Cyril Gaspard (GEM)

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

Forum contributor since 2008

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

Hi,


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)


Bye

0
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)" .

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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