Odoo Help

Welcome!

This community 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.

0

sale.config.settings set value of configuration Field

By
Riadh KAABI
on 7/19/14, 9:06 PM 1,849 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.

1
Torsten Francke
On 12/15/14, 10:50 AM

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')"/>

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/19/14, 9:06 PM
Seen: 1849 times
Last updated: 3/16/15, 8:10 AM