changeset f1d1748d1db1 in modules/production_work:default
details:
https://hg.tryton.org/modules/production_work?cmd=changeset&node=f1d1748d1db1
description:
Update production work state on write
Writing on the One2Many cycles may modify the state of the work.
issue11823
review426021003
diffstat:
work.py | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diffs (27 lines):
diff -r 40c5931f211e -r f1d1748d1db1 work.py
--- a/work.py Sun Oct 16 14:14:11 2022 +0200
+++ b/work.py Fri Oct 28 00:35:20 2022 +0200
@@ -227,7 +227,9 @@
@classmethod
def set_state(cls, works):
for work in works:
- work.state = work._state
+ state = work._state
+ if work.state != state:
+ work.state = state
cls.save(works)
def get_rec_name(self, name):
@@ -251,6 +253,12 @@
return works
@classmethod
+ def write(cls, *args):
+ super().write(*args)
+ works = sum(args[0:None:2], [])
+ cls.set_state(works)
+
+ @classmethod
def delete(cls, works):
for work in works:
if work.state not in {'request', 'draft'}: