[FIX] project, sale_timesheet: common field between non-dependent modules workaround

The project and sale_timesheet modules both define a project_time_mode_id field on res.company but they are not dependent on each other. This causes problem because the first module that creates the field "wins" the xmlid and will delete the field on uninstall, regardless of the other module (which will then stop working until you do an update that will recreate the field).

To work around this in a stable version, we manually create xmlids for the field in each module; on uninstall the field will not be deleted if an xmlid still refers it (which will be the case if the other module is installed).

Inheriting fields from modules that are not dependent in a direct way (ancestor-child) is not supported, so normally you should use modularity to define the field in a parent module. Since 9.0 is a stable version, we need a small workaround.
This commit is contained in:
Damien Bouvy
2015-10-16 16:38:25 +02:00
parent be5fc7b1a4
commit 31ff6c68f4
3 changed files with 29 additions and 2 deletions
+11 -1
View File
@@ -21,6 +21,17 @@
<!-- alias domain: project.config.settings -->
<function id="default_alias_domain_project" model="ir.values" name="set_default" eval="('project.config.settings', 'generate_project_alias', 1)"/>
<!-- sale_timesheet and project define the same field without depending on each, which causes the field to be deleted when the module that created it
is deleted. To avoid this, we create xmlids manually for this field in both modules to prevent accidental deletion. To fix in saas-7 by moving the field definition-->
<record id="duplicate_field_xmlid" model="ir.model.data">
<field name="res_id" search="[('model','=','res.company'),('name','=','project_time_mode_id')]" model="ir.model.fields"/>
<field name="model">ir.model.fields</field>
<field name="module">project</field>
<field name="name">project_time_mode_id_duplicate_xmlid</field>
<field name="noupdate">True</field>
</record>
</data>
<data>
@@ -319,6 +330,5 @@
<field name="displayed_image_id" ref="msg_task_data_14_attach"/>
</record>
</data>
</openerp>
+2 -1
View File
@@ -17,7 +17,8 @@ have real delivered quantities in sales orders.
'author': 'OpenERP SA',
'website': 'https://www.odoo.com/page/warehouse',
'depends': ['sale', 'hr_timesheet'],
'data': ['views/sale_timesheet_view.xml'],
'data': ['views/sale_timesheet_view.xml',
'data/sale_timesheet_data.xml'],
'demo': ['data/sale_timesheet_demo.xml'],
'installable': True,
'auto_install': True,
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!-- sale_timesheet and project define the same field without depending on each, which causes the field to be deleted when the module that created it
is deleted. To avoid this, we create xmlids manually for this field in both modules to prevent accidental deletion. To fix in saas-7 by moving the field definition-->
<record id="duplicate_field_xmlid" model="ir.model.data">
<field name="res_id" search="[('model','=','res.company'),('name','=','project_time_mode_id')]" model="ir.model.fields"/>
<field name="model">ir.model.fields</field>
<field name="module">sale_timesheet</field>
<field name="name">project_time_mode_id_duplicate_xmlid</field>
<field name="noupdate">True</field>
</record>
</data>
</odoo>