我需要覆盖sale.py。
中的内置方法_prepare_invoice但我收到此错误
ValueError: "'builtin_function_or_method' object is not iterable" while evaluating
u'action_invoice_create()'
我需要覆盖方法来创建新发票。
File "/home/cybrosys/Desktop/odoo-8.0-20150624/addons/Ship/Ship.py", line 104, in _prepare_invoice
sal_rec = self.browse(cr,uid,id,context=context)
File "/home/cybrosys/Desktop/odoo-8.0-20150624/openerp/api.py", line 241, in wrapper
return old_api(self, *args, **kwargs)
File "/home/cybrosys/Desktop/odoo-8.0-20150624/openerp/models.py", line 5222, in browse
ids = _normalize_ids(arg)
File "/home/cybrosys/Desktop/odoo-8.0-20150624/openerp/models.py", line 6090, in _normalize_ids
return tuple(arg)
答案 0 :(得分:1)
以下方法会根据不同的API调用覆盖不同的方式
适用于OpenERP 7.0
from openerp.osv import fields, osv
class sale_order(osv.osv):
_inherit = 'sale.order'
def _prepare_invoice(self, cr, uid, order, lines, context=None):
res=super(sale_order, self)._prepare_invoice(cr, uid, order, lines, context=context)
res.update({'delivery_note': order.partner_id.picking_warn_msg})
return res
适用于Odoo 8.0或更高版本
如果您在Odoo中使用新API,则应遵循以下方式
from openerp import models, fields, api, _
class sale_order(models.Model)
_inherit = 'sale.order'
@api.v7
def _prepare_invoice(self, cr, uid, order, lines, context=None):
res=super(sale_order, self)._prepare_invoice(cr, uid, order, lines, context=context)
res.update({'delivery_note': order.partner_id.picking_warn_msg})
return res
我希望我的回答可以帮到你:)。