From 7614b407ee253fe389ea7c97cb57496446a4aad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 17 Dec 2023 23:39:16 +0100 Subject: [PATCH] Convert negative id value as None when set by the client Domain inversion may force a unique value based on the default value from PYSON evaluation. In such case it means that no record can be set. Closes #12799 (grafted from 48463dae759ea1473b258ed905ba2c15fe96e10c) --HG-- branch : 6.0 --- sao/src/model.js | 4 ++++ tryton/tryton/gui/window/view_form/model/field.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/sao/src/model.js b/sao/src/model.js index ba7f6439b8..5553cb08ca 100644 --- a/sao/src/model.js +++ b/sao/src/model.js @@ -2073,6 +2073,10 @@ rec_name = ''; } } + if ((value < 0) && (this.name != record.group.parent_name)) { + value = null; + rec_name = ''; + } Sao.setdefault( record._values, this.name + '.', {}).rec_name = rec_name; Sao.field.Many2One._super.set_client.call(this, record, value, diff --git a/tryton/tryton/gui/window/view_form/model/field.py b/tryton/tryton/gui/window/view_form/model/field.py index 656b843e02..c26989372a 100644 --- a/tryton/tryton/gui/window/view_form/model/field.py +++ b/tryton/tryton/gui/window/view_form/model/field.py @@ -490,6 +490,8 @@ class M2OField(Field): self.name + '.', {}).get('rec_name', '') else: rec_name = '' + if value and value < 0 and self.name != record.parent_name: + value, rec_name = None, '' record.value.setdefault(self.name + '.', {})['rec_name'] = rec_name super(M2OField, self).set_client(record, value, force_change=force_change)