Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odgovori
5366 Prikazi

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
Opusti
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
Opusti
Related Posts Odgovori Prikazi Aktivnost
0
mar. 15
3937
1
mar. 15
4507
1
mar. 15
5411
4
mar. 15
7098
0
mar. 15
4075