Cédric Krier pushed to branch branch/default at Tryton / Tryton
Commits:
470a2831 by Cédric Krier at 2023-06-30T00:18:00+02:00
Prevent None value in selection of MultiSelection
Closes #12313
- - - - -
3 changed files:
- modules/account_invoice_stock/stock.py
- modules/party/address.py
- trytond/trytond/tests/test_tryton.py
Changes:
=====================================
modules/account_invoice_stock/stock.py
=====================================
@@ -39,7 +39,7 @@
def get_invoice_types(cls):
pool = Pool()
Invoice = pool.get('account.invoice')
- return Invoice.fields_get(['type'])['type']['selection'] + [(None, '')]
+ return Invoice.fields_get(['type'])['type']['selection']
@fields.depends('from_location', 'to_location')
def on_change_with_invoice_types(self, name=None):
=====================================
modules/party/address.py
=====================================
@@ -250,7 +250,8 @@
def get_subdivision_types(cls):
pool = Pool()
Subdivision = pool.get('country.subdivision')
- return Subdivision.fields_get(['type'])['type']['selection']
+ selection = Subdivision.fields_get(['type'])['type']['selection']
+ return [(k, v) for k, v in selection if k is not None]
@fields.depends('country')
def on_change_with_subdivision_types(self, name=None):
@@ -422,7 +423,8 @@
def get_subdivision_types(cls):
pool = Pool()
Subdivision = pool.get('country.subdivision')
- return Subdivision.fields_get(['type'])['type']['selection']
+ selection = Subdivision.fields_get(['type'])['type']['selection']
+ return [(k, v) for k, v in selection if k is not None]
@classmethod
def create(cls, *args, **kwargs):
=====================================
trytond/trytond/tests/test_tryton.py
=====================================
@@ -749,6 +749,8 @@
'field': field_name,
'model': model.__name__,
})
+ if field._type == 'multiselection':
+ self.assertNotIn(None, dict(selection_values).keys())
@with_transaction()
def test_function_fields(self):
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/commit/470a28314f49c5c02112d17fa95f0ef5941626c0
--
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/commit/470a28314f49c5c02112d17fa95f0ef5941626c0
You're receiving this email because of your account on foss.heptapod.net.