Merge lp:~openerp-dev/openobject-addons/7.0-opw-595298-fka into lp:openobject-addons/7.0

Proposed by Foram Katharotiya (OpenERP)
Status: Rejected
Rejected by: Denis Ledoux (OpenERP)
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-595298-fka
Merge into: lp:openobject-addons/7.0
Diff against target: 33 lines (+17/-1)
1 file modified
purchase/purchase.py (+17/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-595298-fka
Reviewer Review Type Date Requested Status
Stefan Rijnhart (Opener) (community) Abstain
Vinay Rana (OpenERP) Pending
Naresh(OpenERP) Pending
Review via email: mp+192283@code.launchpad.net

Description of the change

Hello,

I have fix the issue of the state of a purchase order always stay on approved state even if incoming shipment has been received and invoice has been paid when invoice method is set to the 'Based on purchase order lines' or 'Based on incoming shipment' in purchase order.

Thanks,
FKA

To post a comment you must log in.
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Foram Katharotiya,

thank you very much for your work! I confirm that this patch fixes the problem, at least in my use case. According to code standards (PEP8), you would need to add some spaces to line 31, changing it from

    purchase_order_obj.write(cr, uid, po_id.id,{'state':'done'}, context=context)

to

    purchase_order_obj.write(cr, uid, po_id.id, {'state': 'done'}, context=context)

Another space is missing in line 13, after 'shipped'. You may even want to consider writing "'shipped': True" instead of "'shipped': 1" as I believe the former is more standard.

review: Needs Fixing
9529. By Foram Katharotiya (OpenERP)

[MERGE] with 7.0

9530. By Foram Katharotiya (OpenERP)

[IMP] add spaces

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

On second thoughts, it occurred to me that you do not use the workflow here. When I receive the products, the workflow is done even if the invoice has not yet been paid and the purchase order state is not yet 'done'.

 After testing and reading the competing fix, https://code.launchpad.net/~csierra-h/openobject-addons/7.0/+merge/163556, it seems that this branch fixes the problem too, but using the workflow engine to follow the purchase order right up until setting it to 'done'.

I would therefore favour the other solution, but maybe there is a reason why you chose to bypass the workflow engine in your solution? Please let us know.

review: Needs Information
Revision history for this message
Foram Katharotiya (OpenERP) (fka-openerp) wrote :

Hello Stefan Rijnhart,

We can not merge workflow activities changes in stable version as per our policy so i need to chose this bypass.
And in this branch https://code.launchpad.net/~csierra-h/openobject-addons/7.0/+merge/163556, add activities in purchase order workflow which is not work yet properly. In this branch purchase order is mark as 'done' when invoice has been validate not paid.

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

Thank you for your quick response! I see that you are correct, and that the orders in the alternative solution get done before the invoices are paid. Given the restriction of the stable version, I think this is an acceptable solution but I am afraid that if it gets merged in 7.0, it will end up in 8.0 eventually. So for that reason I will review with 'abstain'. But again, thanks a lot!

review: Abstain
9531. By Foram Katharotiya (OpenERP)

[MERGE] with 7.0

Revision history for this message
Denis Ledoux (OpenERP) (dle-openerp) wrote :

This fix mark the purchase order as done, indeed, but does not end the workflow itself.
If you active the developer mode, and print the workflow in the developer selection menu ("Print Workflow"), you will see that the 'Done' state is not colored in Red, the transition just before done is.

Unmerged revisions

9531. By Foram Katharotiya (OpenERP)

[MERGE] with 7.0

9530. By Foram Katharotiya (OpenERP)

[IMP] add spaces

9529. By Foram Katharotiya (OpenERP)

[MERGE] with 7.0

9528. By Foram Katharotiya (OpenERP)

[MERGE] with 7.0

9527. By Foram Katharotiya (OpenERP)

[FIX] The state of a purchase order always stay on approved state even if incoming shipment has been received and invoice has been paid when invoice method is set to the 'Based on purchase order lines' or 'Based on incoming shipment' in purchase order

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 2013-10-17 10:44:26 +0000
3+++ purchase/purchase.py 2013-11-13 04:51:32 +0000
4@@ -705,7 +705,11 @@
5 return picking_ids[0] if picking_ids else False
6
7 def picking_done(self, cr, uid, ids, context=None):
8- self.write(cr, uid, ids, {'shipped':1,'state':'approved'}, context=context)
9+ state = 'approved'
10+ for po_id in self.browse(cr, uid, ids, context=context):
11+ if po_id.invoiced:
12+ state = 'done'
13+ self.write(cr, uid, po_id.id, {'shipped': True, 'state': state}, context=context)
14 return True
15
16 def copy(self, cr, uid, id, default=None, context=None):
17@@ -1221,4 +1225,16 @@
18 wf_service.trg_validate(uid, 'purchase.order', context['default_res_id'], 'send_rfq', cr)
19 return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context)
20
21+class account_invoice(osv.Model):
22+ _inherit = 'account.invoice'
23+
24+ def confirm_paid(self, cr, uid, ids, context=None):
25+ res = super(account_invoice, self).confirm_paid(cr, uid, ids, context=context)
26+ purchase_order_obj = self.pool.get('purchase.order')
27+ po_ids = purchase_order_obj.search(cr, uid, [('invoice_ids', 'in', ids)], context=context)
28+ if po_ids:
29+ for po_id in purchase_order_obj.browse(cr, uid, po_ids, context=context):
30+ if po_id.shipped and po_id.invoiced:
31+ purchase_order_obj.write(cr, uid, po_id.id, {'state':'done'}, context=context)
32+ return res
33 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: