Reputation: 7
I'm inheriting res_config_settings_views and i want the checkbox under analytics groups to load as checked on every page reload i.e., i want to set the value of analytics accounting checkbox as true as default.
I have tried setting it to true via inheriting model by defining as group_analytic_accounting = fields.Boolean(string='', default=True)
in the py file and also i have tried setting it as default from xml file as <field name="group_analytic_accounting">{'default_group_analytic_accounting': 'True'}</field>
Both of them turned out to be failed attempts. Any help or guidance here is much appreciated.
P.S: Odoo Version is 12
Thank you
edit: below is the xml code
P.S: I'm inheriting res_config_settings_views (Odoo Community->addons->account->views). I want to modify just the analytic div and load the checkbox as checked in default
<xpath expr="//div[@id='analytic']" position="replace">
<div class="row mt16 o_settings_container" id="analytic">
<div class="col-12 col-lg-6 o_setting_box" title="Allows you to use the analytic accounting." groups="account.group_account_user">
<div class="o_setting_left_pane">
<field name="group_analytic_accounting"/>
</div>
<div class="o_setting_right_pane">
<label for="group_analytic_accounting"/>
<div class="text-muted">
Track costs & revenues by project, department, etc.
</div>
<div class="content-group" attrs="{'invisible': [('group_analytic_accounting', '=', False)]}">
<div class="mt16" id="analytic_account_link">
<button name="%(analytic.action_analytic_account_form)d" icon="fa-arrow-right"
type="action" string="Analytic Accounts" class="btn-link"/>
</div>
<div id="analytic_account_groups_link">
<button name="%(analytic.account_analytic_group_action)d" icon="fa-arrow-right"
type="action" string="Analytic Account Groups" class="btn-link"/>
</div>
</div>
</div>
</div>
</div>
below is the python code
class Account(models.TransientModel):
_inherit = 'res.config.settings'
group_analytic_accounting = fields.Boolean(string='Test Analytic Accounting', implied_group='analytic.group_analytic_accounting', default=True, required=True, change_default=True)
Upvotes: 0
Views: 3110
Reputation: 805
If var = fields.Boolean(string='', default=True)
does n't works try putting a compute field or call a function from the field.
def function_name(self):
self.var = True
Upvotes: 0
Reputation: 1
var = fields.Boolean(string='', default=True)
This code should work. Can we see the entire class?
Upvotes: 0