如何更改模块安装的设置?

时间:2015-07-01 13:35:55

标签: module installation settings odoo odoo-8

我想更改sale.config.settings设置中的值。我找到this way来做这件事。但我想使用Odoo v8的api。那可能吗?我在源代码中找到的所有示例都使用osv.osv_memory

1 个答案:

答案 0 :(得分:0)

xml ===================

<?xml version="1.0"?>
<openerp>
 <data>
       <function model="my.model.init" name="_init_settings" />

 </data>
</openerp>

python ======================

from openerp import api, models
class my_model_init(models.TransientModel):

    _name = ''my.model.init"
    @api.multi
    def _init_settings(self):
        sale_settings_pool = self.env['sale.config.settings']
        sale_settings_id = sale_settings_pool.create({'group_route_so_lines':True})
        sale_settings_obj = sale_settings_pool.browse(sale_settings_id)
        sale_settings_obj.execute()  # this call is actually changes the setting, you're missing this step.
        return True