Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
4137 Представления

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 

Аватар
Отменить
Лучший ответ

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

Аватар
Отменить
Автор Лучший ответ

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

Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
июн. 22
7541
1
нояб. 22
102
1
авг. 25
90
0
июл. 25
900
1
мая 25
1649