[6.1/7.0/trunk][purchase] changing PO partner_id after order is saved keeps corrupted partner_id at order_line level (fields.related)

Bug #1215578 reported by Raphaël Valyi - http://www.akretion.com
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Confirmed
Medium
OpenERP R&D Addons Team 2
OpenERP Community Backports (Addons)
Status tracked in 7.0
6.1
Fix Committed
Medium
OpenERP Community Backports
7.0
Fix Committed
Medium
OpenERP Community Backports

Bug Description

How to reproduce:

on new install with demo data on head v7:

Create a new purchase order with one purchase order line.
Save the purchase order.
Take the purchase order id X from the URL and look at the result of this SQL query:
select partner_id from purchase_order_line where order_id=X;

This gives you Y the partner_id of the purchase order which is expected.

Now edit the purchase order again, change the partner and save it. Run the same SQL query again.
KABOOM! this gives you the old partner_id id which is now corrupted!

I think the problem comes from the fact this is a fields.related with store=True and no proper cache invalidation function. This is a crazy bug because all SQL or ORM using that related field will give corrupted results once you change a purchase order partner, which is something pretty common.

Related branches

Revision history for this message
Twinkle Christian(OpenERP) (tch-openerp) wrote :
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Medium
status: New → Confirmed
summary: - [6.1][7.0][purchase] changing PO partner_id after order is saved keeps
- corrupted partner_id at order_line level (fields.related)
+ [6.1/7.0/trunk][purchase] changing PO partner_id after order is saved
+ keeps corrupted partner_id at order_line level (fields.related)
Revision history for this message
Yann Papouin (yann-papouin) wrote :

SQL Query to fix existing data:

UPDATE purchase_order_line
   SET partner_id = purchase_order.partner_id
  FROM purchase_order
 WHERE purchase_order_line.order_id = purchase_order.id
   AND purchase_order_line.partner_id <> purchase_order.partner_id;

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

Hello, as a note, a similar issue has been reported for sale order lines on Github: https://github.com/odoo/odoo/issues/1629

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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