changeset c93c6a55b0cc in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset&node=c93c6a55b0cc
description:
Validate moves only once when modifying lines
The create and write methods of the line already validate the moves.
issue10519
review342511003
diffstat:
move.py | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diffs (41 lines):
diff -r 52bd514bd241 -r c93c6a55b0cc move.py
--- a/move.py Mon Jul 12 23:08:16 2021 +0200
+++ b/move.py Mon Jul 12 23:11:01 2021 +0200
@@ -251,7 +251,7 @@
@classmethod
def write(cls, *args):
actions = iter(args)
- all_moves = []
+ all_moves = set()
args = []
for moves, values in zip(actions, actions):
keys = list(values.keys())
@@ -261,9 +261,10 @@
if len(keys):
cls.check_modify(moves)
args.extend((moves, values))
- all_moves.extend(moves)
+ all_moves.update(moves)
super(Move, cls).write(*args)
- cls.validate_move(all_moves)
+ if not Transaction().context.get('_skip_validate_move', False):
+ cls.validate_move(cls.browse(all_moves))
@classmethod
def create(cls, vlist):
@@ -951,9 +952,12 @@
if not value:
return
Move = Pool().get('account.move')
- Move.write([line.move for line in lines], {
- name: value,
- })
+ moves = {line.move for line in lines}
+ moves = Move.browse(moves)
+ with Transaction().set_context(_skip_validate_move=True):
+ Move.write(moves, {
+ name: value,
+ })
@classmethod
def search_move_field(cls, name, clause):