Search code examples
odooodoo-12odoo-accountingodoo-wizard

How to override wizard's method on odoo 12


I am trying to override a single method on wizard's class that gets executed when the user click submit.

account_consolidation_custom/wizard/CustomClass.py

class AccountConsolidationConsolidate(models.TransientModel):
    _name = 'account.consolidation.consolidate_custom'
    _inherit = 'account.consolidation.base'

    def get_account_balance(self, account, partner=False, newParam=False):
    ....my custom code...

account_consolidation_custom/__manifest_.py

{
    'name': "account_consolidation_custom",

    'summary': """""",

    'description': """
    """,

    'author': "My Company",
    'website': "http://www.yourcompany.com",

    'category': 'Uncategorized',
    'version': '0.1',

    'depends': ['base','account_consolidation'],

    # always loaded
    'data': [],
}

The method's name is exactly the same as the original, but when I click on the submit button, nothing seems to happen, is still calling the method from the base module instead of the custom.

Do you know how to get only one method overwritten instead of the whole wizard class?


Solution

  • You're creating a new wizard/transient model when giving different values to the private attributes _name and _inherit. Instead you should use the original odoo model name account.consolidation.consolidate to both attributes or just remove the _name attribute completely.

    Odoo has it's own inheriting mechanism, which is managed by the three class attributes _name, _inherit and _inherits.