details: https://code.tryton.org/tryton/commit/ff894a8408bb
branch: 7.6
user: Cédric Krier <[email protected]>
date: Fri Nov 21 11:50:54 2025 +0100
description:
Test if field_names is None instead of empty in ModelStorage hooks
Closes #14382
(grafted from 7e6bbca989319d7b34e438f529783c316eb21cfc)
diffstat:
modules/account_payment/payment.py | 2 +-
modules/account_stock_eu/stock.py | 4 ++--
modules/attendance/attendance.py | 2 +-
modules/bank/bank.py | 2 +-
modules/company/company.py | 2 +-
modules/party/contact_mechanism.py | 2 +-
modules/project_plan/work.py | 6 +++---
modules/stock/move.py | 2 +-
modules/stock/shipment.py | 2 +-
modules/stock_product_location_place/stock.py | 6 ++++--
modules/stock_shipment_measurements/stock.py | 4 ++--
trytond/trytond/ir/email_.py | 2 +-
trytond/trytond/tests/modelstorage.py | 2 +-
13 files changed, 20 insertions(+), 18 deletions(-)
diffs (187 lines):
diff -r df7409d417d4 -r ff894a8408bb modules/account_payment/payment.py
--- a/modules/account_payment/payment.py Tue Dec 02 13:39:07 2025 +0100
+++ b/modules/account_payment/payment.py Fri Nov 21 11:50:54 2025 +0100
@@ -639,7 +639,7 @@
Line = pool.get('account.move.line')
super().on_modification(mode, payments, field_names=field_names)
if mode in {'create', 'write'}:
- if not field_names or 'line' in field_names:
+ if field_names is None or 'line' in field_names:
if lines := Line.browse({p.line for p in payments if p.line}):
Line.set_payment_amount(lines)
diff -r df7409d417d4 -r ff894a8408bb modules/account_stock_eu/stock.py
--- a/modules/account_stock_eu/stock.py Tue Dec 02 13:39:07 2025 +0100
+++ b/modules/account_stock_eu/stock.py Fri Nov 21 11:50:54 2025 +0100
@@ -186,12 +186,12 @@
cls = self.__class__
values = super().compute_fields(field_names=field_names)
if (self.state not in {'done', 'cancelled'}
- and (not field_names
+ and (field_names is None
or (cls.intrastat_type.on_change_with & field_names))):
intrastat_type = self.on_change_with_intrastat_type()
if getattr(self, 'intrastat_type', None) != intrastat_type:
values['intrastat_type'] = intrastat_type
- if (not field_names
+ if (field_names is None
or (cls.intrastat_value.on_change_with & field_names)):
intrastat_value = self.on_change_with_intrastat_value()
if getattr(self, 'intrastat_value', None) != intrastat_value:
diff -r df7409d417d4 -r ff894a8408bb modules/attendance/attendance.py
--- a/modules/attendance/attendance.py Tue Dec 02 13:39:07 2025 +0100
+++ b/modules/attendance/attendance.py Fri Nov 21 11:50:54 2025 +0100
@@ -90,7 +90,7 @@
def compute_fields(self, field_names=None):
cls = self.__class__
values = super().compute_fields(field_names=field_names)
- if (not field_names
+ if (field_names is None
or (cls.date.on_change_with & field_names)):
date = self.on_change_with_date()
if getattr(self, 'date', None) != date:
diff -r df7409d417d4 -r ff894a8408bb modules/bank/bank.py
--- a/modules/bank/bank.py Tue Dec 02 13:39:07 2025 +0100
+++ b/modules/bank/bank.py Fri Nov 21 11:50:54 2025 +0100
@@ -263,7 +263,7 @@
def compute_fields(self, field_names=None):
values = super().compute_fields(field_names=field_names)
- if ((not field_names or {'type', 'number'} & field_names)
+ if ((field_names is None or {'type', 'number'} & field_names)
and getattr(self, 'type', None) == 'iban'):
number = getattr(self, 'number', None)
if number:
diff -r df7409d417d4 -r ff894a8408bb modules/company/company.py
--- a/modules/company/company.py Tue Dec 02 13:39:07 2025 +0100
+++ b/modules/company/company.py Fri Nov 21 11:50:54 2025 +0100
@@ -111,7 +111,7 @@
Rule = pool.get('ir.rule')
super().on_modification(mode, companies, field_names=field_names)
if mode == 'write':
- if not field_names or 'logo' in field_names:
+ if field_names is None or 'logo' in field_names:
cls._logo_clear_cache(companies)
Rule._domain_get_cache.clear()
diff -r df7409d417d4 -r ff894a8408bb modules/party/contact_mechanism.py
--- a/modules/party/contact_mechanism.py Tue Dec 02 13:39:07 2025 +0100
+++ b/modules/party/contact_mechanism.py Fri Nov 21 11:50:54 2025 +0100
@@ -273,7 +273,7 @@
def compute_fields(self, field_names=None):
values = super().compute_fields(field_names=field_names)
- if not field_names or {'value', 'type'} & field_names:
+ if field_names is None or {'value', 'type'} & field_names:
if getattr(self, 'value', None) and getattr(self, 'type', None):
value = self.format_value(value=self.value, type_=self.type)
if self.value != value:
diff -r df7409d417d4 -r ff894a8408bb modules/project_plan/work.py
--- a/modules/project_plan/work.py Tue Dec 02 13:39:07 2025 +0100
+++ b/modules/project_plan/work.py Fri Nov 21 11:50:54 2025 +0100
@@ -554,9 +554,9 @@
super().on_modification(mode, works, field_names=field_names)
if mode in {'create', 'write'}:
for work in works:
- if not field_names or 'effort' in field_names:
+ if field_names is None or 'effort' in field_names:
work.reset_leveling()
- if not field_names or field_names & {
+ if field_names is None or field_names & {
'constraint_start_time', 'constraint_finish_time',
'effort'}:
work.compute_dates()
@@ -590,7 +590,7 @@
def on_modification(cls, mode, records, field_names=None):
super().on_modification(mode, records, field_names=field_names)
if mode == 'create':
- if not field_names or field_names & {
+ if field_names is None or field_names & {
'predecessor', 'successor', 'parent'}:
for record in records:
record.predecessor.reset_leveling()
diff -r df7409d417d4 -r ff894a8408bb modules/stock/move.py
--- a/modules/stock/move.py Tue Dec 02 13:39:07 2025 +0100
+++ b/modules/stock/move.py Fri Nov 21 11:50:54 2025 +0100
@@ -983,7 +983,7 @@
def compute_fields(self, field_names=None):
cls = self.__class__
values = super().compute_fields(field_names=field_names)
- if (not field_names
+ if (field_names is None
or (cls.internal_quantity.on_change_with & field_names)):
internal_quantity = self.on_change_with_internal_quantity()
if getattr(self, 'internal_quantity', None) != internal_quantity:
diff -r df7409d417d4 -r ff894a8408bb modules/stock/shipment.py
--- a/modules/stock/shipment.py Tue Dec 02 13:39:07 2025 +0100
+++ b/modules/stock/shipment.py Fri Nov 21 11:50:54 2025 +0100
@@ -154,7 +154,7 @@
Move = pool.get('stock.move')
super().on_modification(mode, shipments, field_names=field_names)
if (mode in {'create', 'write'}
- and (not field_names or 'planned_date' in field_names)):
+ and (field_names is None or 'planned_date' in field_names)):
cls._set_move_planned_date(shipments)
elif mode == 'delete':
if hasattr(cls, 'moves'):
diff -r df7409d417d4 -r ff894a8408bb
modules/stock_product_location_place/stock.py
--- a/modules/stock_product_location_place/stock.py Tue Dec 02 13:39:07
2025 +0100
+++ b/modules/stock_product_location_place/stock.py Fri Nov 21 11:50:54
2025 +0100
@@ -127,11 +127,13 @@
cls = self.__class__
values = super().compute_fields(field_names=field_names)
if getattr(self, 'state', None) not in {'done', 'cancelled'}:
- if not field_names or cls.from_place.on_change_with & field_names:
+ if (field_names is None
+ or cls.from_place.on_change_with & field_names):
from_place = self.on_change_with_from_place()
if getattr(self, 'from_place', None) != from_place:
values['from_place'] = from_place
- if not field_names or cls.to_place.on_change_with & field_names:
+ if (field_names is None
+ or cls.to_place.on_change_with & field_names):
to_place = self.on_change_with_to_place()
if getattr(self, 'to_place', None) != to_place:
values['to_place'] = to_place
diff -r df7409d417d4 -r ff894a8408bb
modules/stock_shipment_measurements/stock.py
--- a/modules/stock_shipment_measurements/stock.py Tue Dec 02 13:39:07
2025 +0100
+++ b/modules/stock_shipment_measurements/stock.py Fri Nov 21 11:50:54
2025 +0100
@@ -136,12 +136,12 @@
def compute_fields(self, field_names=None):
cls = self.__class__
values = super().compute_fields(field_names=field_names)
- if (not field_names
+ if (field_names is None
or (cls.internal_weight.on_change_with & field_names)):
internal_weight = self.on_change_with_internal_weight()
if self.internal_weight != internal_weight:
values['internal_weight'] = internal_weight
- if (not field_names
+ if (field_names is None
or (cls.internal_volume.on_change_with & field_names)):
internal_volume = self.on_change_with_internal_volume()
if getattr(self, 'internal_volume', None) != internal_volume:
diff -r df7409d417d4 -r ff894a8408bb trytond/trytond/ir/email_.py
--- a/trytond/trytond/ir/email_.py Tue Dec 02 13:39:07 2025 +0100
+++ b/trytond/trytond/ir/email_.py Fri Nov 21 11:50:54 2025 +0100
@@ -564,7 +564,7 @@
@classmethod
def on_modification(cls, mode, records, field_names=None):
super().on_modification(mode, records, field_names=field_names)
- if not field_names or {'name', 'model'} & set(field_names):
+ if field_names is None or {'name', 'model'} & set(field_names):
ModelView._view_toolbar_get_cache.clear()
diff -r df7409d417d4 -r ff894a8408bb trytond/trytond/tests/modelstorage.py
--- a/trytond/trytond/tests/modelstorage.py Tue Dec 02 13:39:07 2025 +0100
+++ b/trytond/trytond/tests/modelstorage.py Fri Nov 21 11:50:54 2025 +0100
@@ -192,7 +192,7 @@
def compute_fields(self, field_names=None):
values = super().compute_fields(field_names=field_names)
- if not field_names or 'value' in field_names:
+ if field_names is None or 'value' in field_names:
values['computed_value'] = self.value + 1
return values