@api.multi
def unlink(self):
for deferr in self:
if deferr.invoice_id.state != 'draft':
raise UserError('ERROR')
return super(account_deferred_income_charges, self).unlink()
我想用旧的api编写相同的方法。我该怎么办?
def unlink(self, cr, uid, ids, context=None):
def_line_obj = self.pool.get('account.deferred.income.charges.')
return super(account_deferred_income_charges, self).unlink(
cr, uid, ids, context=context
)
答案 0 :(得分:3)
您可以这样写:
from openerp import osv
from openerp.tools.translate import _
def unlink(self, cr, uid, ids, context=None):
for item in self.browse(cr, uid, ids, context=context):
if item.invoice_id.state != 'draft':
raise osv.except_osv(_('User Error!'),_('Error Text'))
return super(account_deferred_income_charges, self).unlink(cr, uid, ids, context=context)