From 70f6e847f3001edb3aee08aff078930fcc093ac4 Mon Sep 17 00:00:00 2001 From: Rifakat Date: Mon, 24 Sep 2012 13:10:36 +0530 Subject: [PATCH] [FIX] stock: wrong stock accounting entries while doing return of any purchase/sales Accounting entries should be reverse while doing any return bzr revid: rha@tinyerp.com-20120924074036-0h7sybkwaegvg4tz --- addons/stock/stock.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 329159494d3..332a21895f2 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2300,7 +2300,11 @@ class stock_move(osv.osv): or move.location_id.company_id != move.location_dest_id.company_id): journal_id, acc_src, acc_dest, acc_valuation = self._get_accounting_data_for_valuation(cr, uid, move, src_company_ctx) reference_amount, reference_currency_id = self._get_reference_accounting_values_for_valuation(cr, uid, move, src_company_ctx) - account_moves += [(journal_id, self._create_account_move_line(cr, uid, move, acc_valuation, acc_dest, reference_amount, reference_currency_id, context))] + #returning goods to supplier + if move.location_dest_id.usage == 'supplier': + account_moves += [(journal_id, self._create_account_move_line(cr, uid, move, acc_valuation, acc_src, reference_amount, reference_currency_id, context))] + else: + account_moves += [(journal_id, self._create_account_move_line(cr, uid, move, acc_valuation, acc_dest, reference_amount, reference_currency_id, context))] # Incoming moves (or cross-company input part) if move.location_dest_id.company_id \ @@ -2308,7 +2312,11 @@ class stock_move(osv.osv): or move.location_id.company_id != move.location_dest_id.company_id): journal_id, acc_src, acc_dest, acc_valuation = self._get_accounting_data_for_valuation(cr, uid, move, dest_company_ctx) reference_amount, reference_currency_id = self._get_reference_accounting_values_for_valuation(cr, uid, move, src_company_ctx) - account_moves += [(journal_id, self._create_account_move_line(cr, uid, move, acc_src, acc_valuation, reference_amount, reference_currency_id, context))] + #goods return from customer + if move.location_id.usage == 'customer': + account_moves += [(journal_id, self._create_account_move_line(cr, uid, move, acc_dest, acc_valuation, reference_amount, reference_currency_id, context))] + else: + account_moves += [(journal_id, self._create_account_move_line(cr, uid, move, acc_src, acc_valuation, reference_amount, reference_currency_id, context))] move_obj = self.pool.get('account.move') for j_id, move_lines in account_moves: