Server ORM bug V5. Error in read function with inherited field. Maybe V6 is also impacted

Bug #673696 reported by Sébastien BEAU - http://www.akretion.com
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Low
OpenERP's Framework R&D
5.0
Won't Fix
Low
Anup(SerpentCS)

Bug Description

We are working on product_variant_multi and so using inherited fields.

If you add the field "name" to the object product.product, the "read" function on the object product.product will give you the result of the field "name" of the object product.template.

If you look at orm.py, line 2333 :
You will see that the ORM doesn't make any check on the existing fields in product.product before reading them in product.template.

I just added a check

- cols = intersect(self._inherit_fields.keys(), fields_to_read)
+ cols = [x for x in intersect(self._inherit_fields.keys(), fields_to_read) if x not in self._columns.keys()]

For information : "cols" is the variable which contains the fields that we have to read in the inherited object.

With this patch fields are only read in the inherited object if they are not found in the actual object.

Tags: maintenance
Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :
affects: openobject-addons → openobject-server
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Hello Sébastien,

I disagree with you here. Why would you need to add 'name' column to product_product table?
Product already _inherits Templates and it has 'name' already.

Adding the same field on product will be ambiguous I guess.

Correct me if I am wrong.
Thanks.

Changed in openobject-server:
status: New → Incomplete
Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

Let's me explain.

When we use product_variant_multi, we build various product from the product template. As product.product inherit product_template the name of the product is same as the product template.

The idea is to have field "name" (a function field) on product_product which build a correct name with the product template name and the product variants. (product name = product template name + product variants)

I made a lots of test and there is nothing ambigous because is you want to read :
the product_template name you just have to do self.pool.get('product.template').read(....)
and the product_product name you just have to do self.pool.get('product.product').read(....).

Making this change on the orm will only impact people who are trying to overwrite field on inherit object. For the moment there is only the module product_variant_multi in development version.

I know that it's a little dangerous to create the field "name" in product.product and the reason is because the code is not enough clean, the proof I found this bug.

Please think twice before not fixing it, because without this we will never have a powerfull ORM.

What do you think?

Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

Moreover only the read function have a bug. The write and create function work perfectly ;).

Changed in openobject-server:
status: Incomplete → New
Revision history for this message
Vinay Rana (OpenERP) (vra-openerp) wrote :

We Let the Framework team decide.

Thanks.

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
status: New → Triaged
Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

patch applied in trunk r3142

Changed in openobject-server:
status: Triaged → Fix Released
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Assigning to support team for backport to 5.0 if they think the risk is low enough and the bug is important enough..

tags: added: maintenance
Revision history for this message
Anup(SerpentCS) (anup-serpent) wrote :

Hello Sébastien,

      This is a new feature. It does not seem to be a blocking point, it does not break the system. IMHO it should be kept for the newer version(6.0).

Thanks.

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.