Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
4026 Widoki

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 

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
cze 22
7374
1
lis 22
102
0
lip 25
705
1
maj 25
1467
ADD PROPERTIES Rozwiązane
1
maj 25
1611