Merge lp:~openerp-dev/openobject-addons/trunk-bug-1188479-dharmraj into lp:openobject-addons

Proposed by Dharmraj Zala(OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-1188479-dharmraj
Merge into: lp:openobject-addons
Diff against target: 65 lines (+25/-1)
1 file modified
purchase/purchase.py (+25/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-1188479-dharmraj
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+167898@code.launchpad.net

Description of the change

Hello,

I have fixed both the issues . When Purchase order line is in confirmed state, the exception is raised on its deletion. And when we cancel the po and set it to the draft, its order lines' states also change accordingly.

Thanks,
Dharmraj.

To post a comment you must log in.

Unmerged revisions

8755. By Dharmraj Zala(OpenERP)

[FIX] improved the behavior by raising exception on polines deletion and setting state of polines

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-05-21 12:23:59 +0000
3+++ purchase/purchase.py 2013-06-07 07:07:28 +0000
4@@ -489,6 +489,12 @@
5 def action_cancel_draft(self, cr, uid, ids, context=None):
6 if not len(ids):
7 return False
8+ todo = []
9+ for orders in self.browse(cr, uid, ids, context=context):
10+ if orders.order_line:
11+ for lines in orders.order_line:
12+ todo.append(lines.id)
13+ self.pool.get('purchase.order.line').action_draft(cr, uid, todo, context)
14 self.write(cr, uid, ids, {'state':'draft','shipped':0})
15 for p_id in ids:
16 # Deleting the existing instance of workflow for PO
17@@ -574,7 +580,11 @@
18 return False
19
20 def action_cancel(self, cr, uid, ids, context=None):
21+ todo = []
22 for purchase in self.browse(cr, uid, ids, context=context):
23+ if purchase.order_line:
24+ for lines in purchase.order_line:
25+ todo.append(lines.id)
26 for pick in purchase.picking_ids:
27 if pick.state not in ('draft','cancel'):
28 raise osv.except_osv(
29@@ -590,6 +600,7 @@
30 self.pool.get('account.invoice') \
31 .signal_invoice_cancel(cr, uid, map(attrgetter('id'), purchase.invoice_ids))
32 self.write(cr,uid,ids,{'state':'cancel'})
33+ self.pool.get('purchase.order.line').action_cancel(cr, uid, todo, context)
34
35 self.signal_purchase_cancel(cr, uid, ids)
36 return True
37@@ -879,6 +890,12 @@
38 _table = 'purchase_order_line'
39 _name = 'purchase.order.line'
40 _description = 'Purchase Order Line'
41+
42+ def unlink(self, cr, uid, ids, context=None):
43+ for id in ids:
44+ if self.browse(cr,uid,id,context=context).state == 'confirmed':
45+ raise osv.except_osv(_('Error!'), _('You can not delete Purchase Order Lines which are confirmed!!'))
46+ return super(purchase_order_line, self).unlink(cr, uid, ids, context=context)
47
48 def copy_data(self, cr, uid, id, default=None, context=None):
49 if not default:
50@@ -1015,7 +1032,14 @@
51 def action_confirm(self, cr, uid, ids, context=None):
52 self.write(cr, uid, ids, {'state': 'confirmed'}, context=context)
53 return True
54-
55+
56+ def action_draft(self, cr, uid, ids, context=None):
57+ self.write(cr, uid, ids, {'state': 'draft'}, context=context)
58+ return True
59+
60+ def action_cancel(self, cr, uid, ids, context=None):
61+ self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
62+ return True
63
64 class procurement_order(osv.osv):
65 _inherit = 'procurement.order'

Subscribers

People subscribed via source and target branches

to all changes: