changeset 5f85e27900cf in modules/stock:default
details: https://hg.tryton.org/modules/stock?cmd=changeset&node=5f85e27900cf
description:
        Check for no move when changing product template

        issue10255
        review345781002
diffstat:

 product.py |  14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diffs (24 lines):

diff -r f40400645f64 -r 5f85e27900cf product.py
--- a/product.py        Mon Apr 12 19:43:05 2021 +0200
+++ b/product.py        Tue Apr 13 23:47:22 2021 +0200
@@ -65,6 +65,20 @@
                             raise AccessError(gettext(msg))
                         # No moves for those records
                         break
+
+                if not values.get('template'):
+                    continue
+                template = Template(values['template'])
+                for record in records:
+                    for field, msg in Template._modify_no_move:
+                        if isinstance(
+                                getattr(Template, field), fields.Function):
+                            continue
+                        if getattr(record, field) != getattr(template, field):
+                            if find_moves(cls, [record]):
+                                raise AccessError(gettext(msg))
+                            # No moves for this record
+                            break
         func(cls, *args)
     return decorator
 

Reply via email to