Skip to content

Commit

Permalink
Compute balance after move line creation + add automatic field in mov…
Browse files Browse the repository at this point in the history
…e liens values
  • Loading branch information
florian-dacosta committed Mar 2, 2017
1 parent 81f4cd4 commit 7df7208
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions account_move_base_import/models/account_journal.py
Expand Up @@ -7,6 +7,7 @@
import sys
import traceback
import os
from datetime import datetime
from openerp import _, api, fields, models
from ..parser.parser import new_move_parser
from openerp.exceptions import UserError, ValidationError
Expand Down Expand Up @@ -233,6 +234,13 @@ def prepare_move_line_vals(self, parser_vals, move):
values['company_currency_id'] = self.company_id.currency_id.id
values['journal_id'] = self.id
values['move_id'] = move.id
# Add automatic field since we by pass create method
datetime_now = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
user_id = self.env.uid
values['create_date'] = datetime_now
values['write_date'] = datetime_now
values['create_uid'] = user_id
values['write_uid'] = user_id
if not values.get('account_id', False):
values['account_id'] = self.receivable_account_id.id
values = move_line_obj._add_missing_default_values(values)
Expand Down Expand Up @@ -305,6 +313,7 @@ def _move_import(self, parser, file_stream, ftype="csv"):
# Hack to bypass ORM poor perfomance. Sob...
move_line_obj._insert_lines(move_store)
self.env.invalidate_all()
move.line_ids._store_balance()
self._write_extra_move_lines(parser, move)
if self.create_counterpart:
self._create_counterpart(parser, move)
Expand Down

0 comments on commit 7df7208

Please sign in to comment.