Nimesh Contractor(Open ERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-cancel-po-atp-cancel_po_when_picking_done-nco
into lp:~openerp-dev/openobject-addons/trunk-cancel-po-atp.
Requested reviews:
Atul Patel(OpenERP) (atp-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-cancel-po-atp-cancel_po_when_picking_done-nco/+merge/122000
Hello sir,
Allow cancel po when picking Done and then return picking otherwise
gives the exception.
Allow cancel po when Invoice paid and then return payment otherwise
gives the exception.
Thanks,
NCO.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-cancel-po-atp-cancel_po_when_picking_done-nco/+merge/122000
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-cancel-po-atp.
=== modified file 'purchase/purchase.py'
--- purchase/purchase.py 2012-08-30 04:45:37 +0000
+++ purchase/purchase.py 2012-08-30 07:40:26 +0000
@@ -487,11 +487,14 @@
if order_line.product_id and order_line.product_id.product_tmpl_id.type in ('product', 'consu'):
return True
return False
-
+
def action_cancel(self, cr, uid, ids, context=None):
wf_service = netsvc.LocalService("workflow")
+ pick_out_obj = self.pool.get('stock.picking.out')
+ inv_obj = self.pool.get('account.invoice')
for purchase in self.browse(cr, uid, ids, context=context):
for pick in purchase.picking_ids:
+<<<<<<< TREE
if pick.state == 'done':
raise osv.except_osv(
_('Unable to cancel this purchase order.'),
@@ -499,13 +502,30 @@
else:
wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_cancel', cr)
+=======
+ picking_out_ids = pick_out_obj.search(cr, uid, [('origin', '=', pick.origin),('type','=','out'),('state','=','done')], context=context)
+ if pick.state == 'done':
+ if picking_out_ids:
+ wf_service.trg_validate(uid, 'purchase.order', purchase.id, 'purchase_cancel', cr)
+ else:
+ raise osv.except_osv(
+ _('Unable to cancel this purchase order.'),
+ _('As this order has already been received, you need to return the shipment before you can cancel it.'))
+ else:
+ wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_cancel', cr)
+>>>>>>> MERGE-SOURCE
for inv in purchase.invoice_ids:
- if inv and inv.state not in ('cancel','draft'):
- raise osv.except_osv(
- _('Unable to cancel this purchase order.'),
- _('You must first cancel all receptions related to this purchase order.'))
- if inv:
+ if inv.state == 'paid':
+ inv_ids = inv_obj.search(cr, uid, [('reference', '=', inv.origin),('type','=','in_refund'),('state','=','open')], context=context)
+ if inv_ids:
+ wf_service.trg_validate(uid, 'purchase.order', purchase.id, 'purchase_cancel', cr)
+ else:
+ raise osv.except_osv(
+ _('Unable to cancel this purchase order.'),
+ _('As this invoice has already been paid, you need to refund the invoice before you can cancel it.'))
+ else:
wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_cancel', cr)
+
self.write(cr,uid,ids,{'state':'cancel'})
for (id, name) in self.name_get(cr, uid, ids):
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp