From e8dafbec28f649e370efeee24b77c2d130753f996acf6876456d6b420aa79d4c Mon Sep 17 00:00:00 2001
From: Axel Braun <axel.braun@gmx.de>
Date: Wed, 27 Oct 2021 16:18:24 +0000
Subject: [PATCH] Accepting request 927821 from Application:ERP:GNUHealth:3.8

- Update_changed_fields.diff added to force update of XML files

OBS-URL: https://build.opensuse.org/request/show/927821
OBS-URL: https://build.opensuse.org/package/show/Application:ERP:GNUHealth:Factory/trytond?expand=0&rev=131
---
 Update_changed_fields.diff | 47 ++++++++++++++++++++++++++++++++++++++
 trytond.changes            |  5 ++++
 trytond.spec               |  2 ++
 3 files changed, 54 insertions(+)
 create mode 100644 Update_changed_fields.diff

diff --git a/Update_changed_fields.diff b/Update_changed_fields.diff
new file mode 100644
index 0000000..93bd3d4
--- /dev/null
+++ b/Update_changed_fields.diff
@@ -0,0 +1,47 @@
+diff --git a/trytond/convert.py b/trytond/convert.py
+index c1dde99f19ae579d3d84d0e9f75272ea857f86f1..b57f1c710aefb7579d4edd9d07baad30df23ba8b 100644
+--- a/trytond/convert.py
++++ b/trytond/convert.py
+@@ -9,6 +9,8 @@ import re
+ from collections import defaultdict
+ from decimal import Decimal
+ 
++from trytond.config import config
++
+ from . import __version__
+ from .tools import grouped_slice
+ from .transaction import Transaction
+@@ -19,6 +21,9 @@ logger = logging.getLogger(__name__)
+ CDATA_START = re.compile('^\s*\<\!\[cdata\[', re.IGNORECASE)
+ CDATA_END = re.compile('\]\]\>\s*$', re.IGNORECASE)
+ 
++_update_changed_fields = config.getboolean('optional',
++    'update_changed_fields', default=True)
++
+ 
+ class DummyTagHandler:
+     """Dubhandler implementing empty methods. Will be used when whe
+@@ -668,11 +673,18 @@ class TrytondXmlHandler(sax.handler.ContentHandler):
+                 # if they are not false in a boolean context (ie None,
+                 # False, {} or [])
+                 if db_field != expected_value and (db_field or expected_value):
+-                    logger.warning(
+-                        "Field %s of %s@%s not updated (id: %s), because "
+-                        "it has changed since the last update",
+-                        key, record.id, model, fs_id)
+-                    continue
++                    if _update_changed_fields:
++                        logger.warning(
++                            "Field %s of %s@%s (id: %s) "
++                            "has changed since the last update\n"
++                            "It will be nevertheless updated",
++                            key, record.id, model, fs_id)
++                    else:
++                        logger.warning(
++                            "Field %s of %s@%s not updated (id: %s), because "
++                            "it has changed since the last update",
++                            key, record.id, model, fs_id)
++                        continue
+ 
+                 # so, the field in the fs and in the db are different,
+                 # and no user changed the value in the db:
diff --git a/trytond.changes b/trytond.changes
index 21dd5b5..f20c7dd 100644
--- a/trytond.changes
+++ b/trytond.changes
@@ -1,3 +1,8 @@
+-------------------------------------------------------------------
+Wed Oct 27 16:15:35 UTC 2021 - Axel Braun <axel.braun@gmx.de>
+
+- Update_changed_fields.diff added to force update of XML files
+
 -------------------------------------------------------------------
 Tue Jul 27 14:04:30 UTC 2021 - Axel Braun <axel.braun@gmx.de>
 
diff --git a/trytond.spec b/trytond.spec
index 99bef9f..05a4e8e 100644
--- a/trytond.spec
+++ b/trytond.spec
@@ -37,6 +37,7 @@ Source20:       %{name}.service
 Patch0:         fix_werkzeug.patch
 Patch1:         revert_werkzeug_setup.patch
 Patch2:         fix_werkzeug_2.x.patch
+Patch3:         Update_changed_fields.diff
 BuildRequires:  fdupes
 BuildRequires:  python3-Werkzeug
 BuildRequires:  python3-bcrypt
@@ -84,6 +85,7 @@ cp %{SOURCE1} .
 cp %{SOURCE2} .
 %patch0 -p1
 %patch1 -p1
+%patch3 -p1
 
 #Werkzeug2 is not compatible with Werkzeug 1.x, so we need a conditional patch
 echo 0%{?suse_version}