Hi all,
Can anyone take a look at my code I got below error message, when adding 2 lines on my "onchange_prodcode" funchtion. please see the lines with bold once in onchange.
is there any wrong with my onchange code?
Thanks
XML
<record id="abs_product_description" model="ir.ui.view">
<field name="name">abs.product.description.form.view</field>
<field name="model">abs.prod.desc</field>
<field eval="7" name="priority"/>
<field name="arch" type="xml">
<form string="Product" version="7.0">
<sheet>
<div class="oe_edit_only">
<label for="name" string="Product Code"/>
</div>
<h1><field name="name" style="width: 37%%"/></h1>
<group>
......................
<field name="price_id" style="width: 37%%"/>
</group>
</sheet>
</form>
</field>
</record>
PYTHON
class test_product(osv.Model):
_name = "test.product"_columns = {
'prodcode_id': fields.many2one("abs.prod.desc", 'Product Code'),
'description_id': fields.many2one('abs.desc', 'Description'),
'description': fields.related('description_id', type='many2one', relation='abs.desc', string='Description',),
'variants_id': fields.many2one('abs.var', 'Variants'),
'variants': fields.related('variants_id', type='many2one', relation='abs.prod.var', string='Variants',),
}
def onchange_prodcode(self, cr, uid, ids, prodcode_id, context=None):
if prodcode_id:
description_id = self.pool.get('abs.prod.desc').browse(cr, uid, prodcode_id, context).description_id.id
variants_id = self.pool.get('abs.prod.var').browse(cr, uid, prodcode_id, context).variants_id.id
return {'value':{'description_id':description_id,'variants_id':variants_id}}
return {}class descriptionproduct(osv.osv):
_description="Description Product"
_name = 'abs.prod.desc'
_columns = {
'description_id': fields.many2one('abs.desc', 'Description', required=True),
'variants_id': fields.many2one('abs.var', 'Variants', required=True),
'name': fields.char('Code', size=64, required=True,),
}
class description(osv.osv):
_name = 'abs.desc'
_description = 'Description'
_columns = {
'name': fields.char('Description Name', size=64, required=True,),
}
class variantsproduct(osv.osv):
_description="Variants Product"
_name = 'abs.prod.var'
_columns = {
'variants_id': fields.many2one('abs.var', 'Variants', required=True),
'name': fields.char('Variants Name', size=64, required=True,),
}class variants(osv.osv):
_name = 'abs.var'
_description = 'Variants'
_columns = {
'name': fields.char('Variants', size=64, required=True,),
}
any body can take a look at this?
please see the screen shots, when hitting save populate only the code and description but cannot fetch the variants value. create-- http://tinypic.com/view.php?pic=v7cgmc&s=8#.VFep_4XzSR9 after saving http://tinypic.com/view.php?pic=23tphx&s=8#.VFep5YXzSR8