OpenERP : Multiple module overriding onchange function

徘徊边缘 提交于 2019-12-11 09:53:51

问题


I need to override onchange_partner_id function present in sale.order but I'm working on a system that already have a module overriding this function. I tried to write my own onchange_partner_id with similar code :

def onchange_partner_id(self, cr, uid, ids, part):
    res = super(sale_order, self).onchange_partner_id(cr, uid, ids, part)
    // doing some stuff and adding it to res['value']['myfield']
return res

But my function isn't read by OpenERP. So my question is, is it possible to have multiple function overriding the same function and if i's possible how do I proceed ? Thanks in advance


回答1:


Yes you can override this method, for that you need to define new class in which inherit sale.order and define your method.

Your method will be called definitely.

class sale_order(osv.osv):
    _inherit = 'sale.order'

    def onchange_partner_id(self, cr, uid, ids, part, context=None):
        res = super(sale_order, self).onchange_partner_id(cr, uid, ids, part,context=context)
        // doing some stuff and adding it to res['value']['myfield']
        return res


来源:https://stackoverflow.com/questions/30080690/openerp-multiple-module-overriding-onchange-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!