Merge lp:~camptocamp/openerp-humanitarian-ngo/purchase-wkfl-fix_copy_origin-rde into lp:openerp-humanitarian-ngo/purchase-wkfl

Proposed by Romain Deheele - Camptocamp
Status: Merged
Merged at revision: 71
Proposed branch: lp:~camptocamp/openerp-humanitarian-ngo/purchase-wkfl-fix_copy_origin-rde
Merge into: lp:openerp-humanitarian-ngo/purchase-wkfl
Diff against target: 29 lines (+12/-0)
1 file modified
purchase_requisition_extended/model/purchase_order.py (+12/-0)
To merge this branch: bzr merge lp:~camptocamp/openerp-humanitarian-ngo/purchase-wkfl-fix_copy_origin-rde
Reviewer Review Type Date Requested Status
Joël Grand-Guillaume @ camptocamp code review + no tests Approve
Nicolas Bessi - Camptocamp (community) code review, no test Approve
Leonardo Pistone code review Needs Fixing
Review via email: mp+203584@code.launchpad.net

Description of the change

Hi,

When a cost estimate is confirmed, a copy of chosen rfq is duplicated to create a PO in draftpo state.
The problem was that during this operation the origin is lost, because openerp original orm method copy clears the origin field.
This MP overwrites purchase.order copy to pick origin if PO comes from requisition.

To post a comment you must log in.
Revision history for this message
Leonardo Pistone (lepistone) wrote :

Romain,

I suggest doing that another way, that I find more clear.

if default is None:
    default = {}

initial_origin = default.get('origin')

...super...

if initial_origin:
   ...write...

thanks!

review: Needs Fixing (code review)
72. By Romain Deheele - Camptocamp

[IMP] improve origin checking

Revision history for this message
Romain Deheele - Camptocamp (romaindeheele) wrote :

I doubt about this MP utility.
It seems that rev 12 in lp:openerp-humanitarian-ngo/addons-backport has introduced
origin cleaning in purchase addon, def copy.
Actually, in stable/ocb addons, origin cleaning in purchase addon is not present.

Romain

Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

Check on requisition id is missing

review: Needs Fixing
73. By Romain Deheele - Camptocamp

[FIX] forget a condition : only set origin if the PO comes from requisition

Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

LGTM thanks

review: Approve (code review + no tests)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'purchase_requisition_extended/model/purchase_order.py'
2--- purchase_requisition_extended/model/purchase_order.py 2013-11-01 11:44:19 +0000
3+++ purchase_requisition_extended/model/purchase_order.py 2014-02-06 09:48:29 +0000
4@@ -1,6 +1,7 @@
5 # -*- coding: utf-8 -*-
6
7 from openerp.osv import fields, orm
8+from openerp import SUPERUSER_ID
9
10
11 class purchase_order(orm.Model):
12@@ -63,6 +64,17 @@
13 })
14 return values
15
16+ def copy(self, cr, uid, id, default=None, context=None):
17+ """ Need to set origin after copy because original copy clears origin """
18+ if default is None:
19+ default = {}
20+ initial_origin = default.get('origin')
21+ newid = super(purchase_order, self).copy(cr, uid, id, default=default,
22+ context=context)
23+ if initial_origin and 'requisition_id' in default:
24+ self.write(cr, SUPERUSER_ID, [newid], {'origin': origin}, context=context)
25+ return newid
26+
27
28 class purchase_order_line(orm.Model):
29 _inherit = 'purchase.order.line'

Subscribers

People subscribed via source and target branches