Community mailing list archives
community@mail.odoo.com
Browse archives
Re:Re: Re: GET SELECTION ATTI This is the table and py
Re:Re: GET SELECTION ATTI This is the table and py
Re: Re: GET SELECTION ATTI This is the table and py
byGreetings.
This is the table and pyAt 2015-02-14 11:47:48, "Rigoberto Martinez" <rigo1985@gmail.com> wrote:
Hi magic:
I think the problem you have is related to the variant have a model product.attribute.value a many to many (many2many) with product_product. I think that if you use this field will be easier. I also had to override the name_get to do something similar to what you want and worked with the "attribute_value_ids" field. I hope you serve something.2015-02-13 22:22 GMT-05:00 magic <xubukang@126.com>:ODOO TEAM:HI,I have a question.table:attribute_optionid, name1 greenproduct_product:id, x_material6 1in product.py, i use 'x_material': product.x_material get the value:1but i want to get attribute_option name:greenhow can i do itthank you !Best regardsmagiccode:def name_get(self, cr, user, ids, context=None):
if context is None:
context = {}
if isinstance(ids, (int, long)):
ids = [ids]
if not len(ids):
return []
def _name_get(d):
name = d.get('name','')
code = d.get('default_code',False)
#name_template = d.get('name_template','')
x_YarnCount = d.get('x_YarnCount','')
x_density = d.get('x_density','')
x_width = d.get('x_width','')
x_structure = d.get('x_structure','')
x_material= d.get('x_material','')
# pricetype_obj = self.pool.get('attribute.option').browse(cr, user, ids, context=context).name
# x_structure=pricetype_obj.name
#if code:
#name = '[%s] %s' % (code,name)
info= {'1':'涤棉','4':'纯棉'}
if d.get('variants'):
name = u'纱支:' + x_YarnCount + ' | ' + u'密度:' + info['1'] + ' | ' + u'门幅:' + x_width + ' | ' + u'组织:' + x_structure
# name = 'midu' + x_density + ' | ' + ' - %s' % (d['variants'],)
return (d['id'], name)
partner_id = context.get('partner_id', False)
if partner_id:
partner_ids = [partner_id, self.pool['res.partner'].browse(cr, user, partner_id, context=context).commercial_partner_id.id]
else:
partner_ids = []result = []
for product in self.browse(cr, user, ids, context=context):
sellers = partner_ids and filter(lambda x: x.name.id in partner_ids, product.seller_ids) or []
if sellers:
for s in sellers:
mydict = {
'id': product.id,
'name': s.product_name or product.name,
'default_code': s.product_code or product.default_code,
'variants': product.variants
}
result.append(_name_get(mydict))
else:
mydict = {
'id': product.id,
'name': product.name,
'default_code': product.default_code,
'name_template': product.name_template,
'x_YarnCount': product.x_YarnCount,
'x_density': product.x_density,
'x_width': product.x_width,
'x_structure': product.x_structure,
'x_material': product.x_material,
'variants': product.variants
}
result.append(_name_get(mydict))
return result_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe
_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe
_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe