changeset c11ebd904c42 in proteus:5.0 details: https://hg.tryton.org/proteus?cmd=changeset;node=c11ebd904c42 description: Do not send empty x2Many fields when saving
issue8588 review264091002 (grafted from 25198402e9f72c848b450c7ca6398fbbc442dcf2) diffstat: proteus/__init__.py | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) diffs (26 lines): diff -r c78254fff7df -r c11ebd904c42 proteus/__init__.py --- a/proteus/__init__.py Mon Apr 22 10:38:51 2019 +0200 +++ b/proteus/__init__.py Sat Aug 31 01:40:47 2019 +0200 @@ -885,8 +885,20 @@ 'Return dictionary values' if fields is None: fields = self._values.keys() - return dict((x, getattr(self, '__%s_value' % x)) for x in fields - if x not in ('id', '_timestamp')) + values = {} + for name in fields: + if name in ['id', '_timestamp']: + continue + definition = self._fields[name] + if definition.get('readonly') and definition['type'] != 'one2many': + continue + values[name] = getattr(self, '__%s_value' % name) + # Sending an empty X2Many fields breaks ModelFieldAccess.check + if (definition['type'] in {'one2many', 'many2many'} + and not values[name]): + breakpoint() + del values[name] + return values @property def _timestamp(self):