Merge lp:~florian-dacosta/ocb-addons/6.1_purchase_line_partner_fix into lp:ocb-addons/6.1

Proposed by Florian da Costa
Status: Work in progress
Proposed branch: lp:~florian-dacosta/ocb-addons/6.1_purchase_line_partner_fix
Merge into: lp:ocb-addons/6.1
Diff against target: 28 lines (+10/-1)
1 file modified
purchase/purchase.py (+10/-1)
To merge this branch: bzr merge lp:~florian-dacosta/ocb-addons/6.1_purchase_line_partner_fix
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Needs Fixing
Holger Brunn (Therp) code review Needs Fixing
Review via email: mp+185327@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

Please make _update_partner_from_purchase being able to cope with multiple ids (it only returns the last PO's order lines), something like

res += purchase['order_line']

in #12

review: Needs Fixing (code review)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Same comments than: https://code.launchpad.net/~florian-dacosta/ocb-addons/7.0_purchase_line_partner_fix/+merge/185331/comments/449347 :

l.11 The context must be propagated in the read.
l.24 No mutable in keyword argument: replace "c={}" by "c=None".

l.23-24 Indentation is dubious, see http://www.python.org/dev/peps/pep-0008/#indentation

review: Needs Fixing
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Setting to WIP after 3 months of inactivity.

Unmerged revisions

6788. By Florian da Costa

[FIX] Add function to recalculate the related field partner_id of purchase_order_line because it would not update when the purchase order's partner_id is updated

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'purchase/purchase.py'
2--- purchase/purchase.py 2012-10-26 15:32:12 +0000
3+++ purchase/purchase.py 2013-09-12 17:51:15 +0000
4@@ -655,6 +655,13 @@
5 except Exception, ex:
6 return False
7
8+ def _update_partner_from_purchase(self, cr, uid, ids, context=None):
9+ res = []
10+ obj_purchase = self.pool.get('purchase.order')
11+ for purchase in obj_purchase.read(cr, uid, ids, ['order_line']):
12+ res = purchase['order_line']
13+ return res
14+
15 _columns = {
16 'name': fields.char('Description', size=256, required=True),
17 'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product UoM'), required=True),
18@@ -677,7 +684,9 @@
19 \n* The \'Cancelled\' state is set automatically when user cancel purchase order.'),
20 'invoice_lines': fields.many2many('account.invoice.line', 'purchase_order_line_invoice_rel', 'order_line_id', 'invoice_id', 'Invoice Lines', readonly=True),
21 'invoiced': fields.boolean('Invoiced', readonly=True),
22- 'partner_id': fields.related('order_id','partner_id',string='Partner',readonly=True,type="many2one", relation="res.partner", store=True),
23+ 'partner_id': fields.related('order_id','partner_id',string='Partner',readonly=True,type="many2one", relation="res.partner",
24+ store = {'purchase.order.line': (lambda self, cr, uid, ids, c={}: ids, [], 10),
25+ 'purchase.order': (_update_partner_from_purchase, ['partner_id'], 10)}),
26 'date_order': fields.related('order_id','date_order',string='Order Date',readonly=True,type="date")
27
28 }

Subscribers

People subscribed via source and target branches