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

        issue10255
        review345781002
        (grafted from 5f85e27900cf58846b64cb6d36eeb78d0d53f88d)
diffstat:

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

diffs (24 lines):

diff -r 46381c324754 -r 2f4b2fab2e73 product.py
--- a/product.py        Mon Feb 01 23:07:55 2021 +0100
+++ b/product.py        Tue Apr 13 23:47:22 2021 +0200
@@ -59,6 +59,20 @@
                             Template.raise_user_error(error)
                         # 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