From 7dd544af8993df8c8946d4e1aa2e652fec3ce3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 25 Jul 2012 15:33:19 +0200 Subject: [PATCH] Use root to create account move issue2714 review428001 --- stock.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/stock.py b/stock.py index aaf0ec0bf9..8433ed732b 100644 --- a/stock.py +++ b/stock.py @@ -3,6 +3,7 @@ from decimal import Decimal from trytond.model import Model, fields from trytond.pool import Pool +from trytond.transaction import Transaction class Move(Model): @@ -137,12 +138,13 @@ class Move(Model): if move_line: account_move_lines.append(move_line) - account_move_id = account_move_obj.create( - self._get_account_stock_move(move, account_move_lines)) + with Transaction().set_user(0, set_context=True): + account_move_id = account_move_obj.create( + self._get_account_stock_move(move, account_move_lines)) + account_move_obj.post(account_move_id) self.write(move.id, { 'account_move': account_move_id, }) - account_move_obj.post(account_move_id) return account_move_id def copy(self, ids, default=None):