This question has been flagged
1 Reply
9646 Views

Hello ,

I need your help please.

I try to set a value of group_invoice_so_lines to true in sale.config.settings using a  custom module. In xml file i've added this code:

<?xml version="1.0" encoding="utf-8"?>
<openerp>

    <data noupdate="0">
      
       <function model="res.config.settings" name="set_default">
            <value>sale.config.settings</value>
            <value>group_invoice_so_line</value>
            <value>True</value>
        </function>
        

    </data>
</openerp>

 

but the field value is alaways  set to False.

 

Any idea ? how can I create a module to activate all features that I need.

Avatar
Discard
Best Answer

The Model is a transientModel so you can not store data in xml.

But how to do what happends by clicking options:

look in  'openerp.addons.base.res.res_config.res_config_settings#execute()'

  • For a field like 'default_XXX', ``execute`` sets the (global) default value of the field 'XXX' in the model named by ``default_model`` to the field's value.
  • For a boolean field like 'group_XXX', ``execute`` adds/removes 'implied_group' to/from the implied groups of 'group', depending on the field's value. By default 'group' is the group Employee. Groups are given by their xml id.
  • For a boolean field like 'module_XXX', ``execute`` triggers the immediate installation of the module named 'XXX' if the field has value ``True``.
  • For the other fields, the method ``execute`` invokes all methods with a name that starts with 'set_'; such methods can be defined to implement the effect of those fields.

So your solution would be:

<record model="res.groups" id="base.group_user"> <field name="implied_ids" eval="[(4, ref('sale.group_invoice_so_lines'))]"/> </record>

As you grep in code 'group_invoice_so_lines' that the on_change also changes the "default_order_policy" so you need also add this to your xml.

<function id="sale_order_order_pol_default_set" model="ir.values" name="set_default" eval="('sale.order','order_policy', 'manual')"/>

 

Avatar
Discard