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
=== modified file 'purchase/purchase.py'
--- purchase/purchase.py 2013-05-21 12:23:59 +0000
+++ purchase/purchase.py 2013-06-07 07:07:28 +0000
@@ -489,6 +489,12 @@
489 def action_cancel_draft(self, cr, uid, ids, context=None):489 def action_cancel_draft(self, cr, uid, ids, context=None):
490 if not len(ids):490 if not len(ids):
491 return False491 return False
492 todo = []
493 for orders in self.browse(cr, uid, ids, context=context):
494 if orders.order_line:
495 for lines in orders.order_line:
496 todo.append(lines.id)
497 self.pool.get('purchase.order.line').action_draft(cr, uid, todo, context)
492 self.write(cr, uid, ids, {'state':'draft','shipped':0})498 self.write(cr, uid, ids, {'state':'draft','shipped':0})
493 for p_id in ids:499 for p_id in ids:
494 # Deleting the existing instance of workflow for PO500 # Deleting the existing instance of workflow for PO
@@ -574,7 +580,11 @@
574 return False580 return False
575581
576 def action_cancel(self, cr, uid, ids, context=None):582 def action_cancel(self, cr, uid, ids, context=None):
583 todo = []
577 for purchase in self.browse(cr, uid, ids, context=context):584 for purchase in self.browse(cr, uid, ids, context=context):
585 if purchase.order_line:
586 for lines in purchase.order_line:
587 todo.append(lines.id)
578 for pick in purchase.picking_ids:588 for pick in purchase.picking_ids:
579 if pick.state not in ('draft','cancel'):589 if pick.state not in ('draft','cancel'):
580 raise osv.except_osv(590 raise osv.except_osv(
@@ -590,6 +600,7 @@
590 self.pool.get('account.invoice') \600 self.pool.get('account.invoice') \
591 .signal_invoice_cancel(cr, uid, map(attrgetter('id'), purchase.invoice_ids))601 .signal_invoice_cancel(cr, uid, map(attrgetter('id'), purchase.invoice_ids))
592 self.write(cr,uid,ids,{'state':'cancel'})602 self.write(cr,uid,ids,{'state':'cancel'})
603 self.pool.get('purchase.order.line').action_cancel(cr, uid, todo, context)
593604
594 self.signal_purchase_cancel(cr, uid, ids)605 self.signal_purchase_cancel(cr, uid, ids)
595 return True606 return True
@@ -879,6 +890,12 @@
879 _table = 'purchase_order_line'890 _table = 'purchase_order_line'
880 _name = 'purchase.order.line'891 _name = 'purchase.order.line'
881 _description = 'Purchase Order Line'892 _description = 'Purchase Order Line'
893
894 def unlink(self, cr, uid, ids, context=None):
895 for id in ids:
896 if self.browse(cr,uid,id,context=context).state == 'confirmed':
897 raise osv.except_osv(_('Error!'), _('You can not delete Purchase Order Lines which are confirmed!!'))
898 return super(purchase_order_line, self).unlink(cr, uid, ids, context=context)
882899
883 def copy_data(self, cr, uid, id, default=None, context=None):900 def copy_data(self, cr, uid, id, default=None, context=None):
884 if not default:901 if not default:
@@ -1015,7 +1032,14 @@
1015 def action_confirm(self, cr, uid, ids, context=None):1032 def action_confirm(self, cr, uid, ids, context=None):
1016 self.write(cr, uid, ids, {'state': 'confirmed'}, context=context)1033 self.write(cr, uid, ids, {'state': 'confirmed'}, context=context)
1017 return True1034 return True
10181035
1036 def action_draft(self, cr, uid, ids, context=None):
1037 self.write(cr, uid, ids, {'state': 'draft'}, context=context)
1038 return True
1039
1040 def action_cancel(self, cr, uid, ids, context=None):
1041 self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
1042 return True
10191043
1020class procurement_order(osv.osv):1044class procurement_order(osv.osv):
1021 _inherit = 'procurement.order'1045 _inherit = 'procurement.order'

Subscribers

People subscribed via source and target branches

to all changes: