Skip to Content
Menu
This question has been flagged
1 Reply
5315 Views

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?

Avatar
Discard
Best Answer

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.

Avatar
Discard
Related Posts Replies Views Activity
0
Mar 15
3883
1
Mar 15
4464
1
Mar 15
5340
4
Mar 15
7045
0
Mar 15
4046