← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 727727] Re: Orm.create() should not drop nonexisting fields in passed values

 

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.

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/727727

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

Status in OpenERP Server:
  Incomplete

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.



References