2016-08-24 12 views
0

私は借方/貸方メモのために、私は適応しているOdoo v9モジュールで苦労しています。AttributeError: 'account.invoice.refund'オブジェクトに 'journal_id'属性がありません - Odoo v9コミュニティ

私はこれまでのところ、私はこの機能には、今すぐこの問題を持って、その上のバグを修正しています:

def compute_refund(self, cr, uid, ids, mode='refund', context=None): 
    """@param cr: the current row, from the database cursor, 
    @param uid: the current user’s ID for security checks, 
    @param ids: the account invoice refund’s ID or list of IDs 

    """ 
    inv_obj = self.pool.get('account.invoice') 
    reconcile_obj = self.pool.get('account.move.reconcile') 
    account_m_line_obj = self.pool.get('account.move.line') 
    mod_obj = self.pool.get('ir.model.data') 
    act_obj = self.pool.get('ir.actions.act_window') 
    inv_tax_obj = self.pool.get('account.invoice.tax') 
    inv_line_obj = self.pool.get('account.invoice.line') 
    res_users_obj = self.pool.get('res.users') 

    if context is None: 
     context = {} 

    for form in self.browse(cr, uid, ids, context=context): 
     created_inv = [] 
     date = False 
     period = False 
     description = False 
     company = res_users_obj.browse(
      cr, uid, uid, context=context).company_id 
     journal_id = form.journal_id.id 
     for inv in inv_obj.browse(cr, uid, context.get('active_ids'), 
            context=context): 
      if inv.state in ['draft', 'proforma2', 'cancel']: 
       raise osv.except_osv(_('Error!'), _(
        'Cannot %s draft/proforma/cancel invoice.') % (mode)) 
      if inv.reconciled and mode in ('cancel', 'modify'): 
       raise osv.except_osv(_('Error!'), _(
        'Cannot %s invoice which is already reconciled, ' 
        'invoice should be unreconciled first. You can only ' 
        'refund this invoice.') % (mode)) 
      if form.period.id: 
       period = form.period.id 
      else: 
       period = inv.period_id and inv.period_id.id or False 

      if not journal_id: 
       journal_id = inv.journal_id.id 

      if form.date: 
       date = form.date 
       if not form.period.id: 
        cr.execute("select name from ir_model_fields \ 
            where model = 'account.period' \ 
            and name = 'company_id'") 
        result_query = cr.fetchone() 
        if result_query: 
         cr.execute("""select p.id from account_fiscalyear y 
             , account_period p 
             where y.id=p.fiscalyear_id \ 
          and date(%s) between p.date_start AND 
          p.date_stop and y.company_id = %s limit 1""", 
            (date, company.id,)) 
        else: 
         cr.execute("""SELECT id 
           from account_period where date(%s) 
           between date_start AND date_stop \ 
           limit 1 """, (date,)) 
        res = cr.fetchone() 
        if res: 
         period = res[0] 
      else: 
       date = inv.date_invoice 
      if form.description: 
       description = form.description 
      else: 
       description = inv.name 

      if not period: 
       raise osv.except_osv(_('Insufficient Data!'), 
            _('No period found on the invoice.')) 

      refund_id = inv_obj.refund(cr, uid, [ 
             inv.id], date, period, 
             description, journal_id, 
             context=context) 
      refund = inv_obj.browse(cr, uid, refund_id[0], context=context) 
      # Add parent invoice 
      inv_obj.write(cr, uid, [refund.id], 
          {'date_due': date, 
          'check_total': inv.check_total, 
          'parent_id': inv.id}) 
      inv_obj.button_compute(cr, uid, refund_id) 

      created_inv.append(refund_id[0]) 
      if mode in ('cancel', 'modify'): 
       movelines = inv.move_id.line_id 
       to_reconcile_ids = {} 
       for line in movelines: 
        if line.account_id.id == inv.account_id.id: 
         to_reconcile_ids[line.account_id.id] = [line.id] 
        if type(line.reconcile_id) != osv.orm.browse_null: 
         reconcile_obj.unlink(cr, uid, line.reconcile_id.id) 
       refund.signal_workflow('invoice_open') 
       #wf_service.trg_validate(uid, 'account.invoice', 
             #refund.id, 'invoice_open', cr) 
       refund = inv_obj.browse(
        cr, uid, refund_id[0], context=context) 
       for tmpline in refund.move_id.line_id: 
        if tmpline.account_id.id == inv.account_id.id: 
         to_reconcile_ids[ 
          tmpline.account_id.id].append(tmpline.id) 
       for account in to_reconcile_ids: 
        account_m_line_obj.reconcile(
         cr, uid, to_reconcile_ids[account], 
         writeoff_period_id=period, 
         writeoff_journal_id=inv.journal_id.id, 
         writeoff_acc_id=inv.account_id.id 
        ) 
       if mode == 'modify': 
        invoice = inv_obj.read(cr, uid, [inv.id], 
              ['name', 'type', 'number', 
              'reference', 'comment', 
              'date_due', 'partner_id', 
              'partner_insite', 
              'partner_contact', 
              'partner_ref', 'payment_term', 
              'account_id', 'currency_id', 
              'invoice_line', 'tax_line', 
              'journal_id', 'period_id'], 
              context=context) 
        invoice = invoice[0] 
        del invoice['id'] 
        invoice_lines = inv_line_obj.browse(
         cr, uid, invoice['invoice_line'], context=context) 
        invoice_lines = inv_obj._refund_cleanup_lines(
         cr, uid, invoice_lines, context=context) 
        tax_lines = inv_tax_obj.browse(
         cr, uid, invoice['tax_line'], context=context) 
        tax_lines = inv_obj._refund_cleanup_lines(
         cr, uid, tax_lines, context=context) 
        invoice.update({ 
         'type': inv.type, 
         'date_invoice': date, 
         'state': 'draft', 
         'number': False, 
         'invoice_line': invoice_lines, 
         'tax_line': tax_lines, 
         'period_id': period, 
         'name': description, 
         'origin': self._get_orig(cr, uid, inv, context={}), 
        }) 
        for field in (
         'partner_id', 'account_id', 'currency_id', 
          'payment_term', 'journal_id'): 
         invoice[field] = invoice[ 
          field] and invoice[field][0] 
        inv_id = inv_obj.create(cr, uid, invoice, {}) 
        if inv.payment_term.id: 
         data = inv_obj.onchange_payment_term_date_invoice(
          cr, uid, [inv_id], inv.payment_term.id, date) 
         if 'value' in data and data['value']: 
          inv_obj.write(cr, uid, [inv_id], data['value']) 
        created_inv.append(inv_id) 
     xml_id = (inv.type == 'out_refund') and 'action_invoice_tree1' or \ 
       (inv.type == 'in_refund') and 'action_invoice_tree2' or \ 
       (inv.type == 'out_invoice') and 'action_invoice_tree3' or \ 
       (inv.type == 'in_invoice') and 'action_invoice_tree4' 
     result = mod_obj.get_object_reference(cr, uid, 'account', xml_id) 
     id = result and result[1] or False 
     result = act_obj.read(cr, uid, id, context=context) 
     invoice_domain = eval(result['domain']) 
     invoice_domain.append(('id', 'in', created_inv)) 
     result['domain'] = invoice_domain 
     return result 

私は還付請求書を作成しようとするたびに、それがこのエラーがスローされます。

Traceback (most recent call last): 
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/http.py", line 646, in _handle_exception 
return super(JsonRequest, self)._handle_exception(exception) 
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/http.py", line 683, in dispatch 
result = self._call_function(**self.params) 
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/http.py", line 319, in _call_function 
return checked_call(self.db, *args, **kwargs) 
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/service/model.py", line 118, in wrapper 
return f(dbname, *args, **kwargs) 
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/http.py", line 312, in checked_call 
result = self.endpoint(*a, **kw) 
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/http.py", line 962, in __call__ 
return self.method(*args, **kw) 
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/http.py", line 512, in response_wrap 
response = f(*args, **kw) 
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/addons/web/controllers/main.py", line 901, in call_button 
action = self._call_kw(model, method, args, {}) 
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/addons/web/controllers/main.py", line 889, in _call_kw 
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) 
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/api.py", line 250, in wrapper 
return old_api(self, *args, **kwargs) 
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/addons/debit_credit_note/wizard/account_invoice_refund.py", line 280, in invoice_refund 
return self.compute_refund(cr, uid, ids, data_refund, context=context) 
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/api.py", line 250, in wrapper 
return old_api(self, *args, **kwargs) 
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/addons/debit_credit_note/wizard/account_invoice_refund.py", line 130, in compute_refund 
journal_id = form.journal_id.id 
AttributeError: 'account.invoice.refund' object has no attribute 'journal_id' 

私はres_users_obj = self.pool.get('res.users')後ロジックjournal_obj = self.pool.get('account.journal')に次の行を追加それでも同じエラーを取得しましたが、私はこの操作のためaccount.jounalオブジェクトをロードする必要があると思うが、このラインで私はまだやることができませんそれ。

誰もがこれにいくつかの光を当てることができますか?

詳細が必要な場合はお知らせください。

ありがとうございます!

答えて

2

開発者モードを有効にし、設定 - >技術 - >データベース構造 - >モデルに移動してaccount.invoice.refundを検索し、journal_idという名前のフィールドがあるかどうかを確認します。私が見ることができるように、このフィールドはv8で存在しましたが、v9では存在しません。

あなたはrunbot.odoo.com管理

+0

が、私はモジュールが完全バージョン9に移行されていないと思う/管理者にこれを確認することができ、コードは意味が完全に移行されない、両方のバージョンでまったく同じですが、それはまだ奇妙ですトー – NeoVe

関連する問題