Search code examples
pythonodooodoo-15

Accessing global variable in my custom module from a master


In a master i have a global variable called "READ_ONLY_ON_STATES" which is a dictionary

READ_ONLY_ON_STATES = {"on_validation":[("readonly", True)]}

This is the dictionary defined in the master.

I now want to access this dictionary on my module and add another key in that "READ_ONLY_ON_STATES" variable...

How to achive it... Tried various ways but unable to to... Can anyone help me out please


Solution

  • You can import READ_ONLY_ON_STATES using odoo.addons.MODULE_NAME. If it is declared in models directory inside master file, use the following:

    from odoo.addons.MODULE_NAME.models.master import READ_ONLY_ON_STATES
    

    You can find an example in stock module where they import WARNING_HELP and WARNING_MESSAGE from base module.

    from odoo.addons.base.models.res_partner import WARNING_HELP, WARNING_MESSAGE