[IMP] pos: correct journal for cash payments

(cherry-pick of 2b08443e0d28e96cbbc9a587cb9932319bd1ce10)
This commit is contained in:
Pankaj Joshi
2014-09-12 14:45:03 +02:00
committed by Richard Mathot
parent ff83b439c9
commit 5728fcd61e
2 changed files with 6 additions and 5 deletions
+2 -5
View File
@@ -25,6 +25,7 @@ import time
from openerp import tools
from openerp.osv import fields, osv
from openerp.tools.translate import _
from openerp.exceptions import Warning
import openerp.addons.decimal_precision as dp
import openerp.addons.product.product
@@ -589,11 +590,7 @@ class pos_order(osv.osv):
if order['amount_return']:
cash_journal = session.cash_journal_id
if not cash_journal:
cash_journal_ids = filter(lambda st: st.journal_id.type=='cash', session.statement_ids)
if not len(cash_journal_ids):
raise osv.except_osv( _('error!'),
_("No cash statement found for this session. Unable to record returned cash."))
cash_journal = cash_journal_ids[0].journal_id
raise Warning(_('No cash statement found with cash control enabled for this session. Unable to record returned cash.'))
self.add_payment(cr, uid, order_id, {
'amount': -order['amount_return'],
'payment_date': time.strftime('%Y-%m-%d %H:%M:%S'),
@@ -567,6 +567,10 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
return server_ids;
}).fail(function (error, event){
if(error.code === 200 ){ // Business Logic Error, not a connection problem
//if warning do not need to dispaly traceback!!
if(error.data.exception_type == 'warning'){
delete error.data.debug;
}
self.pos_widget.screen_selector.show_popup('error-traceback',{
message: error.data.message,
comment: error.data.debug