我想在的设置更改值sale.config.settings
。 我发现这种方式来做到这一点。 但我想用Odoo V8的API。 那可能吗? 我在源代码中发现的所有例子都是用osv.osv_memory
Answer 1:
XML ===================
<?xml version="1.0"?>
<openerp>
<data>
<function model="my.model.init" name="_init_settings" />
</data>
</openerp>
蟒蛇======================
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
文章来源: How to change settings on module installation?