product.name_get() ignores _rec_name

Bug #1168001 reported by PabloCM
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
In Progress
Low
OpenERP R&D Addons Team 2

Bug Description

OpenERP 7.0 nightly build: 20130410-232405

Description:
The name_get() orm method redefined by product.product (product/product.py:619) retrieves the product name from the column "name" ignoring any _rec_name attribute set by classes inheriting from product.product.

if sellers:
    for s in sellers:
        mydict = {
                  'id': product.id,
                  'name': s.product_name or product.name,
                  'default_code': s.product_code or product.default_code,
                  'variants': product.variants
                  }
        result.append(_name_get(mydict))
else:
    mydict = {
              'id': product.id,
              'name': product.name,
              'default_code': product.default_code,
              'variants': product.variants
              }

It should instead call to super().name_get() or at least manage the _rec_name attribute as osv.osv does (osv/orm.py:2356)
I am aware you can redefine name_get in your class, but doing so to copy/paste the method and change 2 lines is not a good solution.

Steps to reproduce:
1- Create a class that "_inherit" from product.product with equal "_name" and adds a new field to be used as name.
2- Set _rec_name to that new field
3- Create a new database install any module that uses products (e.g. sale), the module with your class and populate it with products.
4- Go to any view that retrieves the name through name_get (e.g. Sales->Products->Products)

Result observed:
The produc names displayed are the ones stored in the field "name", not your new field.

Result expected:
The names you defined in your new field should appear in the view.

Revision history for this message
Amit Parik (amit-parik) wrote :

Agreed !! We have to call super name_get.

Thank you!

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Low
status: New → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress
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.