From d7600ad56e9298e917869026a4eaf814b2df4042 Mon Sep 17 00:00:00 2001 From: "Ravi Gohil (OpenERP)" Date: Thu, 21 Mar 2013 18:58:24 +0530 Subject: [PATCH] [FIX] point_of_sale: Return product from POS previous session should be linked to current opened session, if not found an active session then raise a warning message. (Maintenance Case: 589810) lp bug: https://launchpad.net/bugs/1123575 fixed bzr revid: rgo@tinyerp.com-20130321132824-9lvtpbu7yse3cupl --- addons/point_of_sale/point_of_sale.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 44139f7a499..188906a4942 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -772,9 +772,14 @@ class pos_order(osv.osv): """Create a copy of order for refund order""" clone_list = [] line_obj = self.pool.get('pos.order.line') - for order in self.browse(cr, uid, ids, context=context): + pos_orders = self.browse(cr, uid, ids, context=context) + current_session = self.pool.get('pos.session').search(cr, uid, [('config_id', '=', pos_orders[0].session_id.config_id.id), ('state', '!=', 'closed')]) + if not current_session: + raise osv.except_osv(_('Error!'), _('To return product(s), you need to open a session that belongs to the same "Point of Sale" as of the product(s) to be returned.')) + for order in pos_orders: clone_id = self.copy(cr, uid, order.id, { 'name': order.name + ' REFUND', + 'session_id': current_session[0] }, context=context) clone_list.append(clone_id)