2016-11-16 12 views
0

私はodoo9でdefault_getをオーバーライドして、私のコードodoo9でdefault_getをオーバーライドする方法はありますか?

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'

答えて

0

辞書/マップMAP_INVOICE_TYPE_PARTNER_TYPEは、単にキー'sponsor_out_invoice'を持っていません。たぶんあなたはそれを追加する必要があります。

関連する問題