I allready made a modul to create field base_price at sales order line, now I want to fill that field with list_price from product template and change everytime product_id change, how to write a modul for that purpose.
I wrote this modul for trial , but didn't work.
this is modul to create field base_price
from openerp.osv import orm, fields
import openerp.addons.decimal_precision as dp
class sale_order_line(orm.Model):
_name = 'sale.order.line'
_inherit = 'sale.order.line'
_columns = {
'base_price':fields.float('Base Price', required=True, digits_compute=dp.get_precision('Product Price'), readonly=True, states={'draft':[('readonly', False)]}),
}
_default = {
'base_price': 0.0,
}
this is the xml file
<?xml version="1.0"?>
<openerp>
<data>
<record model="ir.ui.view" id="view_order_form">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<xpath expr="//form/sheet/notebook/page/field[@name='order_line']/form/group/group/field[@name='price_unit' ]" position="before">
<field name="base_price"/>
</xpath>
<xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='price_unit' ]" position="before">
<field name="base_price"/>
</xpath>
</field>
</record>
</data>
</openerp>
And this is a modul to fiiling value to that fields, and I make it at different modul.
from openerp.osv import orm, fields, api
class sale_order_line(orm.Model):
_inherit = "sale.order.line"
def product_id_change( self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='',
partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False,
fiscal_position=False, flag=False, context=None):
vals=super(sale_order_line.self).product_id_change(cr, uid, ids, pricelist, product, qty=qty, uom=uom,
qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id, lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag, context=context)
vals['value'].update({'base_price':999.99})
return vals
There are no error when I'm installing this modul, but when I change Product at sales order line form, nothing happened to field base_price.
Sorry there are no equal before 999.99, it's mistype.
@Goswani : Sorry, it's not worked, nothing change. thanks
Try to change this line without "equal to"(=) symbol in it vals['value'].update({'base_price': 999.99})
also, it would be helpful if you provide us with the error traceback in the question itself by editing it.