changeset 041413ff5ba3 in modules/stock:5.8
details: https://hg.tryton.org/modules/stock?cmd=changeset&node=041413ff5ba3
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 35bec217b0fc -r 041413ff5ba3 product.py
--- a/product.py        Fri Apr 16 19:11:49 2021 +0200
+++ b/product.py        Tue Apr 13 23:47:22 2021 +0200
@@ -62,6 +62,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