1

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?

czuniga
  • 129
  • 10

2 Answers2

2

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.

CZoellner
  • 13,553
  • 3
  • 25
  • 38
  • Thanks for your response, it stills the same after doing those changes, base method is still getting executed, not custom. – czuniga Jan 14 '20 at 19:42
  • Do you have all `__init__.py` files? – CZoellner Jan 14 '20 at 19:45
  • Yes, I have an ```__init__.py``` inside the wizard folder with the file name imported, and then I am calling the wizard ```from . import wizard``` on the main ```__init__.py``` – czuniga Jan 14 '20 at 19:53
  • Ehrm, the original model is not a Transient but an AbstractModel. – CZoellner Jan 14 '20 at 19:58
  • Ah, and you have to extend its inheriting transient model `account.consolidation.consolidate`. I have changed the answer. – CZoellner Jan 14 '20 at 20:00
  • 1
    Thank you for your support, I was able to make it work with the following: ```class AccountConsolidationConsolidate(models.TransientModel): _inherit = 'account.consolidation.consolidate' ```, I appreciate your help! – czuniga Jan 14 '20 at 20:11
1

I was able to make it work using the following code:

class AccountConsolidationConsolidate(models.TransientModel):
    _inherit = 'account.consolidation.consolidate'

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

After that I was able to overwrite the base methods.

czuniga
  • 129
  • 10