Orm.create() should not drop nonexisting fields in passed values

Bug #727727 reported by Stefan Rijnhart (Opener)
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Confirmed
Wishlist
OpenERP's Framework R&D

Bug Description

Hi,

When I create an instance of an OpenERP object, any nonexisting fields-value pairs are dropped silently. This means a great opportunity to protect data integrity against logical errors and typos of developers is lost. A sanity check, if only a debug statement in the logs at this point would be very helpful.

Cheers,
Stefan.

Related branches

Revision history for this message
Vinay Rana (OpenERP) (vra-openerp) wrote :

Hello Stefan,

would you please provide me more information with proper example.

Thanks.

Changed in openobject-server:
status: New → Incomplete
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Vinay,

here are the examples, which I have just tested on a fairly fresh database with only a couple of partner resources. One function creates a partner with an unknown field 'webpage'. The other function writes an unknown field on an existing partner. To be honest, I would expect the ORM to give me an error or a warning. Instead, the unknown field is dropped just like that. When I wrote the original posting, I did not know that this is true for writing as well as for creation. I dare say this is a potential cause of information loss, which can be easily prevented.

    def create_unknown(self, cr, uid, data, context=None):
        partner_obj = self.pool.get('res.partner')
        partner_id = partner_obj.create(cr, uid, {'name': 'Created', 'webpage': 'http://example.com'})
        return True

    def write_unknown(self, cr, uid, data, context=None):
        partner_obj = self.pool.get('res.partner')
        value = partner_obj.write(cr, uid, [7], {'name': 'Changed', 'webpage': 'http://example.com'})
        return True

Cheers,
Stefan.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Bad programming as it is not to check the return value, I wanted to add that the write operation above does in fact return 'True', just as the create operation does return a proper partner id.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :
Revision history for this message
Azazahmed Saiyed (OpenERP) (saz-openerp) wrote :

Hello stefan

Thanks for the reporting. I have checked and the issue is present in current system. To prevent at laease system has to show some error message like "field does not exists in this object".

Thanks for the reporting.

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
status: Incomplete → Confirmed
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

I'm correcting the status to wishlist, to reflect that this is really a nice-to-have, not a bug.
Stefan, it would actually make sense to create a merge proposal with your proposed patch against lp:openobject-server/trunk, so that it can get reviewed and integrated in the next version.
The procedure for creating merge proposals is explained in the documentation [1], and by indicating that your patch fixes this bug (passing this to bzr commit: --fixes lp:727727) it will automatically link the branch with the bug.

Thanks!

[1] http://doc.openerp.com/v6.0/contribute/15_guidelines/contribution_guidelines.html

Changed in openobject-server:
importance: Low → Wishlist
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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