Odoo Help


How to avoid "You have to provide an account for the write off/exchange difference entry." error when closing pos session? [Closed]

Pascal Tremblay
on 11/21/15, 6:48 PM 1,372 views

The Question has been closed for reason: not a real question

Pascal Tremblay
on 11/25/2015 21:28:57

Hello all,

Usually, when we created an invoice from the point of sale, with the "invoice" button, after we closed an validated the pos session and the invoice stayed not paid (open state). It was a problem for us.

I have used the _confirm_orders method at the end of this post : https://github.com/odoo/odoo/issues/6534

and now, after closing the pos session, all created invoices are in paid state. That's right!

But for some reasons, sometimes I get this error when trying to close the POS session :

    'You have to provide an account for the write off/exchange difference entry.'

How could I change my new _confirm_orders method to avoid this error?

Here is the code of the suggested in the github post _confirm_orders method :

class pos_session(osv.osv):
_inherit = 'pos.session'

def _confirm_orders(self, cr, uid, ids, context=None):

account_move_obj = self.pool.get('account.move')
account_move_line_obj = self.pool.get('account.move.line')
pos_order_obj = self.pool.get('pos.order')
for session in self.browse(cr, uid, ids, context=context):
local_context = dict(context or {}, force_company=session.config_id.journal_id.company_id.id)
order_ids = [order.id for order in session.order_ids if order.state == 'paid']

move_id = account_move_obj.create(cr, uid, {'ref' : session.name, 'journal_id' : session.config_id.journal_id.id, }, context=local_context)

pos_order_obj._create_account_move_line(cr, uid, order_ids, session, move_id, context=local_context)

for order in session.order_ids:
if order.state == 'done':
if order.state not in ('paid', 'invoiced'):
raise osv.except_osv(
_("You cannot confirm all orders of this session, because they have not the 'paid' status"))
pos_order_obj.signal_workflow(cr, uid, [order.id], 'done')
order_ids = self.pool.get('pos.order').search(cr, uid, [('session_id','=', session.id)])
for obj_order_id in self.pool.get('pos.order').browse(cr, uid, order_ids, context=context):
move_line = []

for move_line_id in obj_order_id.invoice_id.move_id.line_id:
if move_line_id.name == obj_order_id.name:


for statement_id in obj_order_id.statement_ids:
move_line_ids = account_move_line_obj.search(cr, uid, [('statement_id','=', statement_id.statement_id and statement_id.statement_id.id)])

for line in account_move_line_obj.browse(cr, uid, move_line_ids):

if line.credit and line.name.strip().strip(':') == obj_order_id.name:

ctx = context.copy()
ctx.update({'active_ids': move_line})
self.pool.get('account.move.line.reconcile').trans_rec_reconcile_full(cr, uid, [], ctx)
#move_line_ids = self.pool.get('account.move.line').search(cr, uid, [('name','=',obj_order_id.name)])
#print "@######move_line_id@@@@", move_line_ids

return True


With the above method "_confirm_orders" the customer must pay with the exact amount. If it has some change to give back to customer, you could not close an validate the pos session.

If just one order of the pos session have not been paid with the exact amount by the customer, I get this error : except_orm: (u'Warning!', u'You have to provide an account for the write off/exchange difference entry.')


Pascal Tremblay

--Pascal Tremblay--
| 5 3 7
Alma, Canada
--Pascal Tremblay--

Pascal Tremblay
On 11/22/15, 6:52 PM

We will finally hide the "validate" button in the pos interface.

We will only keep the "invoice" button.

So, in the CSS, we have this new line :

ul.pos-actionbar-button-list li:nth-child(2) {
display: none;


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 11/21/15, 6:48 PM
Seen: 1372 times
Last updated: 11/25/15, 9:28 PM