From 81f674082beebbeec4d7ed238c2d8a02a02e630b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 11 Nov 2024 15:19:51 +0100 Subject: [PATCH] Remove check_xml_record from ModelStorage --- modules/account_es_sii/account.xml | 2 + modules/account_fr_chorus/account.xml | 2 + modules/account_payment_braintree/account.xml | 73 ++++++++++--------- modules/account_payment_clearing/payment.xml | 3 +- modules/account_payment_stripe/payment.xml | 11 +-- modules/currency/currency.py | 8 -- modules/currency/currency.xml | 3 +- .../marketing_automation.xml | 4 +- modules/marketing_email/marketing.xml | 3 +- modules/party/configuration.py | 4 - modules/product/uom.py | 4 - modules/product_price_list_cache/product.xml | 2 +- modules/production/production.xml | 3 +- .../sale.xml | 3 +- modules/sale_subscription/subscription.xml | 14 ++-- modules/stock/location.py | 4 - modules/stock/product.xml | 13 ++-- modules/user_role/res.xml | 3 +- modules/web_shop_vue_storefront/web.xml | 3 +- trytond/CHANGELOG | 1 + trytond/doc/ref/models.rst | 12 --- trytond/trytond/ir/cron.py | 4 - trytond/trytond/ir/ir.xml | 3 +- trytond/trytond/ir/lang.py | 5 -- trytond/trytond/ir/lang.xml | 5 +- trytond/trytond/model/modelstorage.py | 6 +- trytond/trytond/res/ir.xml | 13 ++-- trytond/trytond/tests/test_modelstorage.py | 14 ++-- 28 files changed, 101 insertions(+), 124 deletions(-) diff --git a/modules/account_es_sii/account.xml b/modules/account_es_sii/account.xml index 7ec2834b1f..75dd2393af 100644 --- a/modules/account_es_sii/account.xml +++ b/modules/account_es_sii/account.xml @@ -113,6 +113,8 @@ this repository contains the full copyright notices and license terms. --> + + account.invoice.sii|send diff --git a/modules/account_fr_chorus/account.xml b/modules/account_fr_chorus/account.xml index 1bcd3fa313..626de08bc7 100644 --- a/modules/account_fr_chorus/account.xml +++ b/modules/account_fr_chorus/account.xml @@ -96,6 +96,8 @@ this repository contains the full copyright notices and license terms. --> Update + + account.invoice.chorus|send diff --git a/modules/account_payment_braintree/account.xml b/modules/account_payment_braintree/account.xml index ac32d3b946..4617ca2eba 100644 --- a/modules/account_payment_braintree/account.xml +++ b/modules/account_payment_braintree/account.xml @@ -121,18 +121,6 @@ this repository contains the full copyright notices and license terms. --> Braintree Pull - - account.payment|braintree_transact - - minutes - - - - account.payment|braintree_pull - - minutes - - account.payment.braintree.refund form @@ -229,18 +217,6 @@ this repository contains the full copyright notices and license terms. --> Approve - - account.payment.braintree.refund|braintree_refund - - minutes - - - - account.payment.braintree.refund|braintree_pull - - minutes - - account.payment.braintree.customer form @@ -299,18 +275,6 @@ this repository contains the full copyright notices and license terms. --> Update - - account.payment.braintree.customer|braintree_create - - hours - - - - account.payment.braintree.customer|braintree_delete - - hours - - account.payment.braintree.customer delete_payment_method @@ -347,4 +311,41 @@ this repository contains the full copyright notices and license terms. --> html + + + account.payment|braintree_transact + + minutes + + + + account.payment|braintree_pull + + minutes + + + + account.payment.braintree.refund|braintree_refund + + minutes + + + + account.payment.braintree.refund|braintree_pull + + minutes + + + + account.payment.braintree.customer|braintree_create + + hours + + + + account.payment.braintree.customer|braintree_delete + + hours + + diff --git a/modules/account_payment_clearing/payment.xml b/modules/account_payment_clearing/payment.xml index b080cd98b7..5642beedf1 100644 --- a/modules/account_payment_clearing/payment.xml +++ b/modules/account_payment_clearing/payment.xml @@ -44,7 +44,8 @@ this repository contains the full copyright notices and license terms. --> succeed_wizard Succeed - + + account.payment.journal|cron_post_clearing_moves diff --git a/modules/account_payment_stripe/payment.xml b/modules/account_payment_stripe/payment.xml index c710b4e8c3..08fb822a13 100644 --- a/modules/account_payment_stripe/payment.xml +++ b/modules/account_payment_stripe/payment.xml @@ -324,6 +324,12 @@ this repository contains the full copyright notices and license terms. --> customer_source_detach_ask_form + + Stripe Checkout + %(http_host)s/%(database)s/account_payment_stripe/checkout/%(model)s/%(id)s + + + account.payment|stripe_charge @@ -365,10 +371,5 @@ this repository contains the full copyright notices and license terms. --> minutes - - - Stripe Checkout - %(http_host)s/%(database)s/account_payment_stripe/checkout/%(model)s/%(id)s - diff --git a/modules/currency/currency.py b/modules/currency/currency.py index 39043933e3..abc83e5ffd 100644 --- a/modules/currency/currency.py +++ b/modules/currency/currency.py @@ -99,10 +99,6 @@ class Currency( def default_digits(): return 2 - @classmethod - def check_xml_record(cls, records, values): - pass - @classmethod def search_global(cls, text): for record, rec_name, icon in super(Currency, cls).search_global(text): @@ -311,10 +307,6 @@ class CurrencyRate(ModelSQL, ModelView): Date = Pool().get('ir.date') return Date.today() - @classmethod - def check_xml_record(cls, records, values): - pass - def get_rec_name(self, name): return str(self.date) diff --git a/modules/currency/currency.xml b/modules/currency/currency.xml index b9ca2458ae..4ca83eef83 100644 --- a/modules/currency/currency.xml +++ b/modules/currency/currency.xml @@ -138,7 +138,8 @@ this repository contains the full copyright notices and license terms. --> run Run - + + currency.cron|update diff --git a/modules/marketing_automation/marketing_automation.xml b/modules/marketing_automation/marketing_automation.xml index 49fa7a7bf3..282ffe80e6 100644 --- a/modules/marketing_automation/marketing_automation.xml +++ b/modules/marketing_automation/marketing_automation.xml @@ -308,7 +308,8 @@ this repository contains the full copyright notices and license terms. --> marketing_automation/unsubscribe.html html - + + marketing.automation.scenario|trigger @@ -319,6 +320,5 @@ this repository contains the full copyright notices and license terms. --> minutes - diff --git a/modules/marketing_email/marketing.xml b/modules/marketing_email/marketing.xml index c74290e88c..5802672fc6 100644 --- a/modules/marketing_email/marketing.xml +++ b/modules/marketing_email/marketing.xml @@ -208,7 +208,8 @@ this repository contains the full copyright notices and license terms. --> form send_test_form - + + marketing.email.message|process diff --git a/modules/party/configuration.py b/modules/party/configuration.py index daee05dfdb..fc95571d90 100644 --- a/modules/party/configuration.py +++ b/modules/party/configuration.py @@ -110,10 +110,6 @@ class ConfigurationSequence(ModelSQL, ValueMixin): __name__ = 'party.configuration.party_sequence' party_sequence = party_sequence - @classmethod - def check_xml_record(cls, records, values): - pass - class ConfigurationLang(ModelSQL, ValueMixin): __name__ = 'party.configuration.party_lang' diff --git a/modules/product/uom.py b/modules/product/uom.py index e56a036d38..c80196bbc3 100644 --- a/modules/product/uom.py +++ b/modules/product/uom.py @@ -77,10 +77,6 @@ class Uom(SymbolMixin, DigitsMixin, DeactivableMixin, ModelSQL, ModelView): ] cls._order.insert(0, ('name', 'ASC')) - @classmethod - def check_xml_record(cls, records, values): - pass - @staticmethod def default_rate(): return 1.0 diff --git a/modules/product_price_list_cache/product.xml b/modules/product_price_list_cache/product.xml index 738d3e4bdb..5f93c144a2 100644 --- a/modules/product_price_list_cache/product.xml +++ b/modules/product_price_list_cache/product.xml @@ -2,7 +2,7 @@ - + product.price_list|fill_cache diff --git a/modules/production/production.xml b/modules/production/production.xml index 07530934eb..01de6e3d61 100644 --- a/modules/production/production.xml +++ b/modules/production/production.xml @@ -279,7 +279,8 @@ this repository contains the full copyright notices and license terms. --> stock.shipment.assign production - + + production|set_cost_from_moves diff --git a/modules/sale_product_recommendation_association_rule/sale.xml b/modules/sale_product_recommendation_association_rule/sale.xml index 3c5a46618e..308aa1c5c2 100644 --- a/modules/sale_product_recommendation_association_rule/sale.xml +++ b/modules/sale_product_recommendation_association_rule/sale.xml @@ -49,7 +49,8 @@ this repository contains the full copyright notices and license terms. --> - + + sale.product.association.rule|compute diff --git a/modules/sale_subscription/subscription.xml b/modules/sale_subscription/subscription.xml index d197eb240c..7d539a6ee2 100644 --- a/modules/sale_subscription/subscription.xml +++ b/modules/sale_subscription/subscription.xml @@ -266,12 +266,6 @@ this repository contains the full copyright notices and license terms. --> line_consumption_create_start_form - - sale.subscription.line|generate_consumption - - days - - Create Subscription Invoices sale.subscription.create_invoice @@ -293,12 +287,18 @@ this repository contains the full copyright notices and license terms. --> form create_invoice_start_form + + + + sale.subscription.line|generate_consumption + + days + sale.subscription|generate_invoice days - diff --git a/modules/stock/location.py b/modules/stock/location.py index f8388feb03..a56237c009 100644 --- a/modules/stock/location.py +++ b/modules/stock/location.py @@ -330,10 +330,6 @@ class Location(DeactivableMixin, tree(), ModelSQL, ModelView): def default_type(): return 'storage' - @classmethod - def check_xml_record(cls, records, values): - pass - def get_warehouse(self, name): # Order by descending left to get the first one in the tree with inactive_records(): diff --git a/modules/stock/product.xml b/modules/stock/product.xml index cc542c667e..44433ceaa1 100644 --- a/modules/stock/product.xml +++ b/modules/stock/product.xml @@ -31,12 +31,6 @@ this repository contains the full copyright notices and license terms. --> recompute_cost_price_start_form - - product.product|recompute_cost_price_from_moves - - days - - product.cost_price.revision form @@ -412,4 +406,11 @@ this repository contains the full copyright notices and license terms. --> + + + product.product|recompute_cost_price_from_moves + + days + + diff --git a/modules/user_role/res.xml b/modules/user_role/res.xml index 836a81a74b..ac550fde30 100644 --- a/modules/user_role/res.xml +++ b/modules/user_role/res.xml @@ -84,7 +84,8 @@ this repository contains the full copyright notices and license terms. --> - + + res.user|sync_roles diff --git a/modules/web_shop_vue_storefront/web.xml b/modules/web_shop_vue_storefront/web.xml index fd8f6375dd..820015ab6c 100644 --- a/modules/web_shop_vue_storefront/web.xml +++ b/modules/web_shop_vue_storefront/web.xml @@ -8,7 +8,8 @@ this repository contains the full copyright notices and license terms. --> shop_form - + + web.shop|vsf_update diff --git a/trytond/CHANGELOG b/trytond/CHANGELOG index 5403bf910a..fa391ffc9c 100644 --- a/trytond/CHANGELOG +++ b/trytond/CHANGELOG @@ -1,3 +1,4 @@ +* Remove check_xml_record from ModelStorage * Always synchronize XML data with database * Convert None as empty string when searching on Char or Text * Support instances as default value diff --git a/trytond/doc/ref/models.rst b/trytond/doc/ref/models.rst index 43431ae295..72077470ef 100644 --- a/trytond/doc/ref/models.rst +++ b/trytond/doc/ref/models.rst @@ -538,18 +538,6 @@ Class methods: The field names of values must be defined in ``fields_names``. It returns the number of imported records. -.. classmethod:: ModelStorage.check_xml_record(records, values) - - Raise an :exc:`~trytond.model.exceptions.AccessError` if the records can not - be modified because they originate from XML data. - ``values`` is a dictionary of written values or ``None`` for deletion. - - It is used by :meth:`~ModelStorage.write` and :meth:`~ModelStorage.delete` - to prevent modification of data coming from XML files. - - .. note:: - This method must be overiden to change this behavior. - .. classmethod:: ModelStorage.validate(records) Validate the integrity of records after creation and modification. diff --git a/trytond/trytond/ir/cron.py b/trytond/trytond/ir/cron.py index c9b8daf1fc..775f63b9f1 100644 --- a/trytond/trytond/ir/cron.py +++ b/trytond/trytond/ir/cron.py @@ -160,10 +160,6 @@ class Cron(DeactivableMixin, ModelSQL, ModelView): (i, True) for i in ids if i not in not_running) return running - @classmethod - def check_xml_record(cls, crons, values): - pass - @classmethod def view_attributes(cls): return [( diff --git a/trytond/trytond/ir/ir.xml b/trytond/trytond/ir/ir.xml index 4eefc3c9fe..a92d62f38c 100644 --- a/trytond/trytond/ir/ir.xml +++ b/trytond/trytond/ir/ir.xml @@ -2,8 +2,7 @@ - - + diff --git a/trytond/trytond/ir/lang.py b/trytond/trytond/ir/lang.py index 74604fdcb4..8fa74ad9a6 100644 --- a/trytond/trytond/ir/lang.py +++ b/trytond/trytond/ir/lang.py @@ -385,11 +385,6 @@ class Lang(DeactivableMixin, ModelSQL, ModelView): n=n, exception=exception)) from exception - @classmethod - def check_xml_record(cls, langs, values): - pass - - @classmethod def get_translatable_languages(cls): res = cls._lang_cache.get('translatable_languages') if res is None: diff --git a/trytond/trytond/ir/lang.xml b/trytond/trytond/ir/lang.xml index 57296244a7..e8fcc01631 100644 --- a/trytond/trytond/ir/lang.xml +++ b/trytond/trytond/ir/lang.xml @@ -8,6 +8,8 @@ this repository contains the full copyright notices and license terms. --> parent="menu_administration" sequence="30" id="menu_localization"/> + + bg Bulgarian @@ -556,7 +558,8 @@ this repository contains the full copyright notices and license terms. --> - + + ir.lang tree diff --git a/trytond/trytond/model/modelstorage.py b/trytond/trytond/model/modelstorage.py index 113715c6d6..6f14016112 100644 --- a/trytond/trytond/model/modelstorage.py +++ b/trytond/trytond/model/modelstorage.py @@ -265,7 +265,7 @@ class ModelStorage(Model): all_records = [] all_fields = set() for records, values in zip(actions, actions): - cls.check_xml_record(records, values) + cls.__check_xml_record(records, values) all_records += records all_fields.update(values.keys()) if transaction.check_access and values: @@ -332,7 +332,7 @@ class ModelStorage(Model): transaction = Transaction() ModelAccess.check(cls.__name__, 'delete') - cls.check_xml_record(records, None) + cls.__check_xml_record(records, None) if ModelData.has_model(cls.__name__): ModelData.clean(records) @@ -1174,7 +1174,7 @@ class ModelStorage(Model): return count @classmethod - def check_xml_record(cls, records, values): + def __check_xml_record(cls, records, values): ModelData = Pool().get('ir.model.data') # Allow root user to update/delete if (Transaction().user == 0 diff --git a/trytond/trytond/res/ir.xml b/trytond/trytond/res/ir.xml index d843066d27..c0064f92ce 100644 --- a/trytond/trytond/res/ir.xml +++ b/trytond/trytond/res/ir.xml @@ -345,12 +345,6 @@ this repository contains the full copyright notices and license terms. --> - - ir.trigger|trigger_time - - minutes - - ir.ui.view_tree_state @@ -459,4 +453,11 @@ this repository contains the full copyright notices and license terms. --> + + + ir.trigger|trigger_time + + minutes + + diff --git a/trytond/trytond/tests/test_modelstorage.py b/trytond/trytond/tests/test_modelstorage.py index d267780129..69626efe9f 100644 --- a/trytond/trytond/tests/test_modelstorage.py +++ b/trytond/trytond/tests/test_modelstorage.py @@ -615,7 +615,7 @@ class ModelStorageTestCase(TestCase): Model = pool.get('test.modelstorage') record, = Model.create([{}]) - Model.check_xml_record([record], {'name': "Test"}) + Model.write([record], {'name': "Test"}) @with_transaction() def test_check_xml_record_with_record_no_matching_fields(self): @@ -633,7 +633,7 @@ class ModelStorageTestCase(TestCase): 'noupdate': False, }]) - Model.check_xml_record([record], {'name': "Test"}) + Model.write([record], {'name': "Test"}) @with_transaction() def test_check_xml_record_with_record_matching_fields(self): @@ -652,7 +652,7 @@ class ModelStorageTestCase(TestCase): }]) with self.assertRaises(AccessError): - Model.check_xml_record([record], {'name': "Bar"}) + Model.write([record], {'name': "Bar"}) @with_transaction() def test_check_xml_record_with_record_matching_fields_noupdate(self): @@ -670,7 +670,7 @@ class ModelStorageTestCase(TestCase): 'noupdate': True, }]) - Model.check_xml_record([record], {'name': "Bar"}) + Model.write([record], {'name': "Bar"}) @with_transaction(user=0) def test_check_xml_record_with_record_matching_fields_root(self): @@ -688,7 +688,7 @@ class ModelStorageTestCase(TestCase): 'noupdate': False, }]) - Model.check_xml_record([record], {'name': "Bar"}) + Model.write([record], {'name': "Bar"}) @with_transaction() def test_check_xml_record_with_record_no_fields(self): @@ -707,7 +707,7 @@ class ModelStorageTestCase(TestCase): }]) with self.assertRaises(AccessError): - Model.check_xml_record([record], None) + Model.delete([record]) @with_transaction() def test_check_xml_record_with_record_no_fields_noupdate(self): @@ -725,7 +725,7 @@ class ModelStorageTestCase(TestCase): 'noupdate': True, }]) - Model.check_xml_record([record], None) + Model.delete([record]) @with_transaction() def test_delete_clear_db_id_model_data_noupdate(self):