[FIX] pos: correctly link refund order to a current session and set to today's date (opw 589810)

lp bug: https://launchpad.net/bugs/1123575 fixed

bzr revid: mat@openerp.com-20130828123940-ik9gvx7flywia0oe
This commit is contained in:
Martin Trigaux 2013-08-28 14:39:40 +02:00
commit 3b549486e9
1 changed files with 10 additions and 1 deletions

View File

@ -798,9 +798,18 @@ 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):
current_session_ids = self.pool.get('pos.session').search(cr, uid, [
('state', '!=', 'closed'),
('user_id', '=', uid)], context=context)
if not current_session_ids:
raise osv.except_osv(_('Error!'), _('To return product(s), you need to open a session that will be used to register the refund.'))
clone_id = self.copy(cr, uid, order.id, {
'name': order.name + ' REFUND',
'name': order.name + ' REFUND', # not used, name forced by create
'session_id': current_session_ids[0],
'date_order': time.strftime('%Y-%m-%d %H:%M:%S'),
}, context=context)
clone_list.append(clone_id)