Odoo Help

2

2
2 Answers
2
Marc Lijour Canada
8/8/17, 7:01 PM

Update: there are two possible ways to achieve the same result (i.e. getting two boolean fields checked).

OPTION 1) Using Python code

About the issues described above, and for the record:

  • the infinite loop comes for the fact the above code did not implement the right type of inheritance (it did implement class inheritance instead of the desired prototype inheritance). The fix is to add a _name attribute (different from _inherit). See https://www.odoo.com/documentation/10.0/howtos/backend.html#inheritance

  • the view needs to be fixed accordingly

See the revised code:


class ResBaseConfigSettings(models.TransientModel):
    _name = "my.config.settings" # that's prototype inheritance (vs. class inheritance if omitted)
                                   # see https://www.odoo.com/documentation/10.0/howtos/backend.html#inheritance
    _inherit = "res.config.settings"
    @api.model 
    def set_signup_parameters(self):
        _logger.info("> Settings sign-up parameters")
        settings = self.env['res.config.settings'].create({
            'auth_signup_uninvited': True,
            'auth_signup_reset_password': True,
        })
        settings.execute()
        _logger.info("> ... done.")

and the view reflecting the new model _name:

<odoo>
  <data noupdate="1">
            <function model="my.config.settings" name="set_signup_parameters"/>
  </data>
</odoo>


OPTION 2) Entirely in a view with a record and a function node

Just make sure your module is called "my_app" or remove the "my_app." part from the id and ref below.

<!-- Another way to set up the signup parameters vs. the record, then the function (in that order) below
           See https://www.odoo.com/forum/help-1/question/how-to-update-a-module-s-config-settings-from-another-module-28230
-->
      <record model="base.config.settings" id="my_app.signup_settings">
        <field name="auth_signup_uninvited" eval="1"/>  
        <field name="auth_signup_reset_password" eval="1"/> 
      </record>
      <function model="base.config.settings" name="execute">
        <!-- ids = --> <value eval="[ref('my_app.signup_settings')]"/>
        <!-- context = --> <value eval="{}"/>
      </function>



1
Maxime Chambreuil Mexico
8/8/17, 9:25 AM

Hello Marc,

The configuration panels are views to trigger different actions in the background when you click on "Apply". It installs modules, adds users to groups or set a default values. You can reproduce those same actions using the dependencies of your module to install other modules or from an XML file in your module to update groups or set the value of the defaults.

Ask a Question
Writer
Keep Informed
4 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now