Can delete a pricelist still linked to a partner

Bug #692891 reported by Robin (www.cgbs.com.au)
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Low
OpenERP's Framework R&D

Bug Description

Can be replicated as follows:

Create a new database using demo data and install the CRM and Sales applications.
With that you get two default price lists, one for sales and one for purchases.
Create a new price list and an associated price list version.
Go to an existing customer and associate the new price list with them.
Then go and create an order for the same customer, which will default to the new price list.
Save the order and then go and delete the price list linked to the customer and the order.
The system will complain saying that a sales order is linked, therefore you cannot delete the price list.
On the sales order, change the price list to the default one supplied by the system, and now go and delete the price list you created.

The system will let you do it, even though it is still linked to a customer.

Now try and open the customer form to modify. The system does not allow you to.

This is the error:

[2010-12-21 16:21:35,288][rwg_test_picelist] ERROR:web-services:Uncaught exception
Traceback (most recent call last):
  File "/home/openerp/openerp/openerp-server/bin/osv/osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/openerp/openerp/openerp-server/bin/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/openerp/openerp/openerp-server/bin/osv/osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/openerp/openerp/openerp-server/bin/osv/orm.py", line 3063, in read
    result = self._read_flat(cr, user, select, fields, context, load)
  File "/home/openerp/openerp/openerp-server/bin/osv/orm.py", line 3174, in _read_flat
    res2 = self._columns[val[0]].get(cr, self, ids, val, user, context=context, values=res)
  File "/home/openerp/openerp/openerp-server/bin/osv/fields.py", line 785, in get
    res = self._fnct(obj, cr, user, ids, name, self._arg, context)
  File "/home/openerp/openerp/openerp-server/bin/osv/fields.py", line 1058, in _fnct_read
    replaces[rep] = dict(obj.pool.get(rep).name_get(cr, uid, replaces[rep].keys(), context=context))
  File "/home/openerp/openerp/addons/product/pricelist.py", line 112, in name_get
    name = pl.name + ' ('+ pl.currency_id.name + ')'
  File "/home/openerp/openerp/openerp-server/bin/osv/orm.py", line 287, in __getattr__
    raise AttributeError(e)
AttributeError: 'Field name not found in browse_record(product.pricelist, 3)'

I would have expected that maybe I would not be allowed to delete a price list linked to a customer, and if so, at least to have the ability to modify the customer to put them on another price list.

Using Linux platform, trunk version 6, addons revision 4033, server revision 3137.

.

Related branches

Amit Parik (amit-parik)
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
qdp (OpenERP) (qdp) wrote :

i fear this problem is affecting all reference fields, and thus is more appropriate for the framework team.

good luck!

Changed in openobject-addons:
assignee: OpenERP R&D Addons Team 2 (openerp-dev-addons2) → OpenERP's Framework R&D (openerp-dev-framework)
Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

it relates to property fields, no references fields.

Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

fixed in r3163

Changed in openobject-addons:
status: Confirmed → Fix Released
Revision history for this message
Robin (www.cgbs.com.au) (robin-cgbs) wrote :

Tested this fix release.

I followed exactly how I had replicated it before.

I then looked at the customer and it had no default price-list specified (as now expected with this bug fix).

However, without modifying anything on the customer form (leaving the default price-list as blank), I then went to create a new sales order for the customer.

When entering the customer for a new sales order, the following error occurs:

Environment Information :
System : Linux-2.6.32-26-generic-i686-with-Ubuntu-10.04-lucid
OS Name : posix
Distributor ID: Ubuntu
Description: Ubuntu 10.04.1 LTS
Release: 10.04
Codename: lucid
Operating System Release : 2.6.32-26-generic
Operating System Version : #48-Ubuntu SMP Wed Nov 24 09:00:03 UTC 2010
Operating System Architecture : 32bit
Operating System Locale : en_AU.UTF8
Python Version : 2.6.5
OpenERP-Client Version : 6.0.0-rc1-1
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
  File "/home/openerp/openerp/openerp-server/bin/netsvc.py", line 489, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth, params)
  File "/home/openerp/openerp/openerp-server/bin/service/web_services.py", line 598, in dispatch
    res = fn(db, uid, *params)
  File "/home/openerp/openerp/openerp-server/bin/osv/osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/openerp/openerp/openerp-server/bin/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/openerp/openerp/openerp-server/bin/osv/osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/openerp/openerp/addons/product/pricelist.py", line 112, in name_get
    name = pl.name + ' ('+ pl.currency_id.name + ')'
  File "/home/openerp/openerp/openerp-server/bin/osv/orm.py", line 287, in __getattr__
    raise AttributeError(e)
AttributeError: 'Field name not found in browse_record(product.pricelist, 2)'

Revision history for this message
Robin (www.cgbs.com.au) (robin-cgbs) wrote :

This appears to me to be issue why error occurs:

This is the property record in the database.

    97;1;"2010-12-29 12:24:04.50833";"";;"";;"property_product_pricelist";;"many2one";1;1132;"";"<binary data>";"product.pricelist,2";"res.partner,3"

As can be seen, the property record still exists for product.pricelist with an id of 2, when in fact product.pricelist id 2 has been removed from database.

It appears as if these property records (ir_property) handling database table relationships need to managed as if real relationships existed in the database. (eg. ondelete:'set null', 'cascade', etc.)

Amit Parik (amit-parik)
Changed in openobject-addons:
status: Fix Released → Confirmed
affects: openobject-addons → openobject-server
Changed in openobject-server:
status: Confirmed → In Progress
Revision history for this message
Yogesh (SerpentCS) (yogesh-serpentcs) wrote :

Hello,

It has been fixed into https://code.launchpad.net/~openerp-dev/openobject-server/ysa-server-framework branch by:
Revision ID: <email address hidden>
Revno: 3049

Thanks.

Changed in openobject-server:
status: In Progress → Fix Released
Changed in openobject-server:
milestone: none → 6.0
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.