コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
5343 ビュー

I want to create a class which inherits from account.invoice in order to modify the _amount_all method.
I already create this method in my module:

class account_invoice(osv.osv):
    _inherit = 'account.invoice'

   def _amount_all(self, cr, uid, ids, name, args, context=None):
        res = super(account_invoice, self)._amount_all(cr, uid, ids, name, args, context)
        # My operations
        return res

But when installed, my method is never called.

Is there another way for doing this inheritance?

アバター
破棄
最善の回答

In addition, in your module, you redefine all culumns where _amount_all is called. For v7:

_columns  = {

        'amount_untaxed': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Subtotal', track_visibility='always',
            store={
                'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20),
                'account.invoice.tax': (_get_invoice_tax, None, 20),
                'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount','invoice_id'], 20),
            },
            multi='all'),

        'amount_tax': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Tax',
            store={
                'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20),
                'account.invoice.tax': (_get_invoice_tax, None, 20),
                'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount','invoice_id'], 20),
            },
            multi='all'),

        'amount_total': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Total',
            store={
                'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20),
                'account.invoice.tax': (_get_invoice_tax, None, 20),
                'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount','invoice_id'], 20),
            },
            multi='all'),

}

The method will be called.

アバター
破棄
関連投稿 返信 ビュー 活動
0
3月 15
3907
1
3月 15
4495
1
3月 15
5389
4
3月 15
7069
0
3月 15
4067