6.0.2: Custom-Field in res_partner_addresscauses Error with CRM-Module

Bug #766944 reported by René Glauser
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Medium
OpenERP's Framework R&D

Bug Description

I put some custom fields into res.partner.address. After installation of the CRM-module these custom-fields are copied into object crm.lead but as type of base-field. Then when I try to create a lead there is always an error-message concerning these fields copied to crm.lead but non existing in database-table crm_lead. Very confusing?
Seems to be a bug in CRM-Module

Related branches

Amit Parik (amit-parik)
affects: openobject-addons → openobject-server
Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
status: New → Confirmed
Changed in openobject-server:
status: Confirmed → In Progress
Revision history for this message
Yogesh (SerpentCS) (yogesh-serpentcs) wrote :

Hello,

Thanks for reporting!

It has been fixed in lp:~openerp-dev/openobject-server/trunk-bug-766944-ysa
Revision no :- 3417
Revision ID: <email address hidden> and will be merged soon
to the trunk server.

Thanks,

Changed in openobject-server:
status: In Progress → Fix Committed
Revision history for this message
Vo Minh Thu (thu) wrote :

The problem seems to be the following:

When creating a custom field on a model (res.partner.address in your example), it is copied in the (python) columns of the _inheriting models (here, crm.lead). But the ORM doesn't really create the corresponding columns in db for _inheriting models althoug there are in their python columns.

The fix we have chosen is to not _inherit custom fields.

We had two options here: handle the custom field just like regular field (and _inheriting models would receive also the custom field) or add it only to the specified model (and not to its children).

The first option is more consistent with how the ORM works in general. But it is also quite involved w.r.t. to end-users. We prefer here to have something that is simple for the end-user. So adding a custom field to a model doesn't require to know if it is _inherited from or not by other models.

For the person who will fix the bug: the place to look at is probably the createInstance() method in the osv.py file.

Changed in openobject-server:
importance: Low → Medium
status: Fix Committed → In Progress
Revision history for this message
Vo Minh Thu (thu) wrote :

A fix is available. The merge proposal is at https://code.launchpad.net/~openerp-dev/openobject-server/6.0-bug-766944-dont-inherit-x-fields-vmt/+merge/62296

If everything's fine, should be merged in 6.0 soon.

Changed in openobject-server:
status: In Progress → Fix Committed
Revision history for this message
Vo Minh Thu (thu) wrote :

The fix is available in the 6.0 branch at revision 3433.

Thanks for the bug report.

Changed in openobject-server:
status: Fix Committed → Fix Released
Revision history for this message
LAPTVN (laptvn) wrote :

Dear Thu,

it seems this bug is not fixed in version 603.

I have tried to add a custom field, i.e. x_Introduced, to product.product by python code but still not created the column in product table. Also then I rename that field to "Introduced" and reinstall my module, get the below error. Can you please advise me on this?

Environment Information :
System : Windows-XP-5.1.2600-SP3
OS Name : nt
Operating System Release : XP
Operating System Version : 5.1.2600
Operating System Architecture : 32bit
Operating System Locale : en_US.cp1252
Python Version : 2.5.2
OpenERP-Client Version : 6.0.3
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
  File "D:\OpenERP\source\OpenERP_603\openerp-server-6.0.3\bin\netsvc.py", line 489, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth, params)
  File "D:\OpenERP\source\OpenERP_603\openerp-server-6.0.3\bin\service\web_services.py", line 599, in dispatch
    res = fn(db, uid, *params)
  File "D:\OpenERP\source\OpenERP_603\openerp-server-6.0.3\bin\osv\osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "D:\OpenERP\source\OpenERP_603\openerp-server-6.0.3\bin\osv\osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "D:\OpenERP\source\OpenERP_603\openerp-server-6.0.3\bin\osv\osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "D:\OpenERP\source\OpenERP_603\openerp-server-6.0.3\bin\addons\base\module\wizard\base_module_upgrade.py", line 98, in upgrade_module
    _db, pool = pooler.restart_pool(cr.dbname, update_module=True)
  File "D:\OpenERP\source\OpenERP_603\openerp-server-6.0.3\bin\pooler.py", line 60, in restart_pool
    return get_db_and_pool(db_name, force_demo, status, update_module=update_module)
  File "D:\OpenERP\source\OpenERP_603\openerp-server-6.0.3\bin\pooler.py", line 39, in get_db_and_pool
    addons.load_modules(db, force_demo, status, update_module)
  File "D:\OpenERP\source\OpenERP_603\openerp-server-6.0.3\bin\addons\__init__.py", line 883, in load_modules
    processed_modules.extend(load_module_graph(cr, graph, status, report=report, skip_modules=processed_modules))
  File "D:\OpenERP\source\OpenERP_603\openerp-server-6.0.3\bin\addons\__init__.py", line 719, in load_module_graph
    init_module_objects(cr, package.name, modules)
  File "D:\OpenERP\source\OpenERP_603\openerp-server-6.0.3\bin\addons\__init__.py", line 414, in init_module_objects
    result = obj._auto_init(cr, {'module': module_name})
  File "D:\OpenERP\source\OpenERP_603\openerp-server-6.0.3\bin\osv\orm.py", line 2655, in _auto_init
    cr.execute("COMMENT ON COLUMN %s.%s IS '%s'" % (self._table, k, f.string.replace("'", "''")))
  File "D:\OpenERP\source\OpenERP_603\openerp-server-6.0.3\bin\sql_db.py", line 78, in wrapper
    return f(self, *args, **kwargs)
  File "D:\OpenERP\source\OpenERP_603\openerp-server-6.0.3\bin\sql_db.py", line 131, in execute
    res = self._obj.execute(query, params)
ProgrammingError: column "introduced" of relation "product_product" does not exist

Revision history for this message
Lorenzo Battistini (elbati) wrote :

I don't think this is fixed in 6.0, see bug 799378 , it comes from the same issue.

Vo Minh Thu said
https://bugs.launchpad.net/openobject-server/+bug/799378/comments/5

Revision history for this message
LAPTVN (laptvn) wrote :

Thanks Lorenzo.

Yes, the problem comes from the field is not created in the table. But just have problem with custom field - field name start with x_*. For your issue, assuming you just declare depend module in init file, it should be ok?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.