From b10180887e7bdcada1c30dd2892ef1cb28886bc2 Mon Sep 17 00:00:00 2001 From: Rucha Dave Date: Thu, 1 Jan 2015 12:24:41 +0530 Subject: [PATCH] [FIX] stock_account: set current date for accounting entries The accounting entries generated (during confirmation of moves on real time products) were based on the move date. This is correct but the creation of the entries (from quants_move) is done before the change of state of the move (which set the date of the move to now). Instead of using the date of move that is changed a few steps laters, use directly the current date for account move date. Fixes #4147, opw 619902 --- addons/stock_account/stock_account.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/stock_account/stock_account.py b/addons/stock_account/stock_account.py index 7ff3f3001b8..06745a02f28 100644 --- a/addons/stock_account/stock_account.py +++ b/addons/stock_account/stock_account.py @@ -22,6 +22,8 @@ from openerp.osv import fields, osv from openerp.tools.translate import _ from openerp import SUPERUSER_ID, api +from openerp.tools import DEFAULT_SERVER_DATE_FORMAT +import time import logging _logger = logging.getLogger(__name__) @@ -245,11 +247,11 @@ class stock_quant(osv.osv): move_obj = self.pool.get('account.move') for cost, qty in quant_cost_qty.items(): move_lines = self._prepare_account_move_line(cr, uid, move, qty, cost, credit_account_id, debit_account_id, context=context) - period_id = context.get('force_period', self.pool.get('account.period').find(cr, uid, move.date, context=context)[0]) + period_id = context.get('force_period', self.pool.get('account.period').find(cr, uid, context=context)[0]) move_obj.create(cr, uid, {'journal_id': journal_id, 'line_id': move_lines, 'period_id': period_id, - 'date': move.date, + 'date': time.strftime(DEFAULT_SERVER_DATE_FORMAT), 'ref': move.picking_id.name}, context=context) #def _reconcile_single_negative_quant(self, cr, uid, to_solve_quant, quant, quant_neg, qty, context=None):