[MERGE] OPW 576829: pos: fix creation of payment line when pos order have multiple payment methods + return
partial trunk backport revid: fp@openerp.com-20120811143309-pd44zfw6l67j7x7l, odo@openerp.com-20121105111609-yuaw6wu6jd1ar2a1 bzr revid: xal@openerp.com-20121116153508-tkill5ov1f3ar75s
This commit is contained in:
@@ -62,15 +62,31 @@ class pos_order(osv.osv):
|
||||
statement_ids = order.pop('statement_ids')
|
||||
order_id = self.create(cr, uid, order, context)
|
||||
list.append(order_id)
|
||||
# call add_payment; refer to wizard/pos_payment for data structure
|
||||
# add_payment launches the 'paid' signal to advance the workflow to the 'paid' state
|
||||
data = {
|
||||
'journal': statement_ids[0][2]['journal_id'],
|
||||
'amount': order['amount_paid'],
|
||||
'payment_name': order['name'],
|
||||
'payment_date': statement_ids[0][2]['name'],
|
||||
}
|
||||
order_obj.add_payment(cr, uid, order_id, data, context=context)
|
||||
for payments in statement_ids:
|
||||
# call add_payment; refer to wizard/pos_payment for data structure
|
||||
# add_payment launches the 'paid' signal to advance the workflow to the 'paid' state
|
||||
payment = payments[2]
|
||||
order_obj.add_payment(cr, uid, order_id, {
|
||||
'amount': payment['amount'],
|
||||
'payment_name': order['name'],
|
||||
'payment_date': payment['name'],
|
||||
'journal': payment['journal_id'],
|
||||
}, context=context)
|
||||
if order['amount_return']:
|
||||
# search for open cash register of 'cash' journal
|
||||
statement_obj = self.pool.get('account.bank.statement')
|
||||
cash_registers_domain = [('state','=','open'),('user_id','=',uid),('journal_id.type','=','cash')]
|
||||
cash_register_ids = statement_obj.search(cr, uid, cash_registers_domain, context=context)
|
||||
if not len(cash_register_ids):
|
||||
raise osv.except_osv( _('Error!'),
|
||||
_("No cash statement found for this session. Unable to record returned cash."))
|
||||
cash_register = statement_obj.browse(cr, uid, cash_register_ids[0], context=context)
|
||||
self.add_payment(cr, uid, order_id, {
|
||||
'amount': -order['amount_return'],
|
||||
'payment_date': time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'payment_name': _('return'),
|
||||
'journal': cash_register.journal_id.id,
|
||||
}, context=context)
|
||||
return list
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
|
||||
Reference in New Issue
Block a user