How to change settings on module installation?

爷,独闯天下 提交于 2019-12-11 05:03:51

问题


I want to change a value in the settings of sale.config.settings. I found this way to do it. But I would like to use the api of Odoo v8. Is that possible? All the examples I found in the source code are using osv.osv_memory


回答1:


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


来源:https://stackoverflow.com/questions/31162964/how-to-change-settings-on-module-installation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!