[FIX] openerp: don't ignore active field on new views when updating a module

Without this fix, if you have a new view in a module with active=False, the active tag will be ignore when upgrading the module because of 'update' mode, and the view will be activated by default !
This commit is contained in:
David Monjoie 2014-11-27 09:52:17 +01:00
parent 9bc712b075
commit f1c70d4cc9
1 changed files with 12 additions and 8 deletions

View File

@ -798,7 +798,9 @@ form: module.record_id""" % (xml_id,)
record.append(Field(el.get('priority', "16"), name='priority')) record.append(Field(el.get('priority', "16"), name='priority'))
if 'inherit_id' in el.attrib: if 'inherit_id' in el.attrib:
record.append(Field(name='inherit_id', ref=el.get('inherit_id'))) record.append(Field(name='inherit_id', ref=el.get('inherit_id')))
if el.get('active') in ("True", "False") and mode != "update": if el.get('active') in ("True", "False"):
view_id = self.id_get(cr, tpl_id, raise_if_not_found=False)
if mode != "update" or not view_id:
record.append(Field(name='active', eval=el.get('active'))) record.append(Field(name='active', eval=el.get('active')))
if el.get('customize_show') in ("True", "False"): if el.get('customize_show') in ("True", "False"):
record.append(Field(name='customize_show', eval=el.get('customize_show'))) record.append(Field(name='customize_show', eval=el.get('customize_show')))
@ -824,19 +826,21 @@ form: module.record_id""" % (xml_id,)
return self._tag_record(cr, record, data_node) return self._tag_record(cr, record, data_node)
def id_get(self, cr, id_str): def id_get(self, cr, id_str, raise_if_not_found=True):
if id_str in self.idref: if id_str in self.idref:
return self.idref[id_str] return self.idref[id_str]
res = self.model_id_get(cr, id_str) res = self.model_id_get(cr, id_str, raise_if_not_found)
if res and len(res)>1: res = res[1] if res and len(res)>1: res = res[1]
return res return res
def model_id_get(self, cr, id_str): def model_id_get(self, cr, id_str, raise_if_not_found=True):
model_data_obj = self.pool['ir.model.data'] model_data_obj = self.pool['ir.model.data']
mod = self.module mod = self.module
if '.' in id_str: if '.' not in id_str:
mod,id_str = id_str.split('.') id_str = '%s.%s' % (mod, id_str)
return model_data_obj.get_object_reference(cr, self.uid, mod, id_str) return model_data_obj.xmlid_to_res_model_res_id(
cr, self.uid, id_str,
raise_if_not_found=raise_if_not_found)
def parse(self, de, mode=None): def parse(self, de, mode=None):
if de.tag != 'openerp': if de.tag != 'openerp':