Reputation: 393
I want to extend the onchange_product_id method of the sale.order.line model. I tried to do it in new and old api style, but nothing worked. Here are my tries:
Old api:
import logging
from openerp.osv import fields, osv
_logger = logging.getLogger(__name__)
class sale_order_line(osv.osv):
_inherit = 'sale.order.line'
def onchange_product_id(self, cr, uid, ids, product_id, context=None):
_logger.debug('product_id has changed')
return {}
New api:
from openerp import models, fields, api
import logging
_logger = logging.getLogger(__name__)
class sale_order_line(models.Model):
_inherit = 'sale.order.line'
@api.onchange('product_id')
def onchange_product_id(self):
_logger.debug('product_id has changed')
return True
Upvotes: 1
Views: 780
Reputation: 9640
Try this way (I didn't try it yet, but it should work)
from openerp.osv import fields, osv
class CustomSaleOrderLine(osv.osv):
_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):
# some operations
return super(CustomSaleOrderLine, self).product_id_change(cr, uid, ids, pricelist, product, qty,
uom, qty_uos, uos, name, partner_id,
lang, update_tax, date_order, packaging, fiscal_position, flag, context)
Upvotes: 2