Я хочу, чтобы переопределить default_get
в odoo9 и Мой кодКак переопределить default_get в odoo9?
class account_payment(models.Model):
_inherit = "account.payment"
@api.model
def default_get(self, fields):
#print 'PRINT1',MAP_INVOICE_TYPE_PARTNER_TYPE
rec = super(account_payment, self).default_get(fields)
invoice_defaults = self.resolve_2many_commands('invoice_ids', rec.get('invoice_ids'))
if invoice_defaults and len(invoice_defaults) == 1:
invoice = invoice_defaults[0]
rec['communication'] = invoice['reference'] or invoice['name'] or invoice['number']
rec['currency_id'] = invoice['currency_id'][0]
rec['payment_type'] = invoice['type'] in ('out_invoice', 'in_refund', 'sponsor_invoice',) and 'inbound' or 'outbound' # modified for charity
rec['partner_type'] = MAP_INVOICE_TYPE_PARTNER_TYPE[invoice['type']]
rec['partner_id'] = invoice['partner_id'][0]
rec['amount'] = invoice['residual']
return rec
, но когда я нажимаю создать это показывает сообщение об ошибке, что точка унаследованный класс первого затем вызвать базовый класс, как это возможно? Пожалуйста помоги.
Сообщение об ошибке:
File "/opt/odoo_v9_charity/server/addons/web_charity/models/account_payment.py", line 87, in default_get rec = super(account_payment_charity, self).default_get(fields) File "/opt/odoo_v9_charity/server/openerp/api.py", line 248, in wrapper return new_api(self, *args, **kwargs) File "/opt/odoo_v9_charity/server/openerp/addons/account/models/account_payment.py", line 257, in default_get rec['partner_type'] = MAP_INVOICE_TYPE_PARTNER_TYPE[invoice['type']] KeyError: u'sponsor_out_invoice'