Odoo Help

Welcome!

This community 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.

0

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

By
Pascal Tremblay
on 11/21/15, 6:48 PM 781 views

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

by
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':
continue
if order.state not in ('paid', 'invoiced'):
raise osv.except_osv(
_('Error!'),
_("You cannot confirm all orders of this session, because they have not the 'paid' status"))
else:
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:

move_line.append(move_line_id.id)


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:
move_line.append(line.id)

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


UPDATE #1

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.')



0

Pascal Tremblay

--Pascal Tremblay--
1312
| 5 2 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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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