In OpenERP first create custom module and inherits the hr module in your existing module.
Follow these step given below
Step1- First create existing module like as test and than create .py file in your own module like as a test.py file and this file pass in the __init__.py file.
Using this code given below
class product_product(osv.osv):
_inherit='product.product'
_columns= {
'design':fields.char('Design', size=128, required=True),
'dyes':fields.char('Dyes', size=128, required=True),
'colour':fields.char('Colour', size=128, required=True),
'min_price':fields.char('Min price', size=128, required=True),
'market_value':fields.char('Market value', size=128),
'supplier':fields.char('Supplier', size=128),
'age':fields.char('Age', size=128, required=True),
'm_length':fields.float('Size(M. Length)'),
'm_width':fields.float('Size(M. Width)'),
'f_length':fields.float('Size(F. Length)'),
'f_width':fields.float('Size(F. Width)'),
'origin':fields.many2one('res.country',"Origin", required=True),
}
def update_descrp(self, cr, uid, ids, context=None):
obj = self.pool.get('product.product')
for val in self.browse(cr, uid, ids, context=context):
a1 = ''
if val.design:
a1 = val.design
a2 = ''
if val.origin:
a2 = val.origin.name
a5 = ''
if val.dyes:
a5 = val.dyes
a6 = ''
if val.colour:
a6 = val.colour
a7 = ''
if val.m_length:
a7 = val.m_length
a8 = ''
if val.m_width:
a8 = val.m_width
a9 = ''
if val.f_length:
a9 = val.f_length
a10 = ''
if val.f_width:
a10 = val.f_width
description = 'Design' + ' : ' + str(a1) + '\n' + 'Origin' + ' : ' + str(a2) + '\n' + 'Material' + ' : ' + str(a4) + '\n' + 'Dyes' + ' : ' + str(a5) + '\n' + 'Colour' + ' : ' + str(a6) + '\n' + 'Size(M)' + ' : ' + str(a7) + 'x' + str(a8) + '\n' + 'Size(F)' + ' : ' + str(a9) + 'x' + str(a10)
self.write(cr, uid, [val.id], {'description': description,})
return True
def create(self, cr, uid, vals, context=None):
a1 = ''
if vals.get('design'):
a1 = vals.get('design')
a2 = ''
if vals.get('origin'):
aa = self.pool.get('res.country').browse(cr, uid, vals.get('origin'), context=context)
a2= aa.name
a5 = ''
if vals.get('dyes'):
a5 = vals.get('dyes')
a6 = ''
if vals.get('colour'):
a6 = vals.get('colour')
a7 = ''
if vals.get('m_length'):
a7 = vals.get('m_length')
a8 = ''
if vals.get('m_width'):
a8 = vals.get('m_width')
a9 = ''
if vals.get('f_length'):
a9 = vals.get('f_length')
a10 = ''
if vals.get('f_width'):
a10 = vals.get('f_width')
if not vals.get('description'):
vals['description'] = 'Design' + ' : ' + str(a1) + '\n' + 'Origin' + ' : ' + str(a2) + '\n' +'Material' + ' : ' + str(a4) + '\n' + 'Dyes' + ' : ' + str(a5) + '\n' + 'Colour' + ' : ' + str(a6) + '\n' + 'Size(M)' + ' : ' + str(a7) + 'x' + str(a8) + '\n' + 'Size(F)' + ' : ' + str(a9) + 'x' + str(a10)
return super(product_product, self).create(cr, uid, vals, context=context)
Step2- Then we create another .xml file like as a test.xml file in your own module and pass this file in the __openerp__.py file.
Using this code given below
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="product_normal_form_view11" model="ir.ui.view">
<field name="name">product.normal.form</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='description']" position="before">
<button name="update_descrp" string="Update Description" type="object" icon="gtk-apply" />
</xpath>
<xpath expr="/form/sheet/notebook/page/group/group/field[@name='list_price']" position="replace">
<field name="list_price" string="Price"/>
<field name="design"/>
<label for="m_length" string ="Size(M)"/>
<div>
<field name="m_length" placeholder="length" style="width: 45%%" />
<field name="m_width" placeholder="width" style="width: 44%%" />
</div>
<field name="dyes"/>
<field name="min_price"/>
<field name="origin"/>
</xpath>
<xpath expr="//field[@name='default_code']" position="before">
<field name="market_value"/>
<field name="fringes"/>
<field name="selvedges"/>
<field name="supplier"/>
<field name="colour"/>
<field name="age"/>
<label for="f_length" string ="Size(F)"/>
<div>
<field name="f_length" placeholder="Length" style="width: 45%%"/>
<field name="f_width" placeholder="Width" style="width: 44%%" />
</div>
</xpath>
</field>
</record>
</data>
</openerp>
0 Comment(s)