Remove check_xml_record from ModelStorage

This commit is contained in:
Cédric Krier
2024-11-11 15:19:51 +01:00
parent f22c335057
commit 81f674082b
28 changed files with 101 additions and 124 deletions
+2
View File
@@ -113,6 +113,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="perm_delete" eval="True"/>
</record>
</data>
<data noupdate="1">
<record model="ir.cron" id="cron_invoice_send">
<field name="method">account.invoice.sii|send</field>
<field name="interval_number" eval="1"/>
+2
View File
@@ -96,6 +96,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="string">Update</field>
</record>
</data>
<data noupdate="1">
<record model="ir.cron" id="cron_invoice_send">
<field name="method">account.invoice.chorus|send</field>
<field name="interval_number" eval="15"/>
+37 -36
View File
@@ -121,18 +121,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="string">Braintree Pull</field>
</record>
<record model="ir.cron" id="cron_transact_payment">
<field name="method">account.payment|braintree_transact</field>
<field name="interval_number" eval="15"/>
<field name="interval_type">minutes</field>
</record>
<record model="ir.cron" id="cron_pull_payment">
<field name="method">account.payment|braintree_pull</field>
<field name="interval_number" eval="15"/>
<field name="interval_type">minutes</field>
</record>
<record model="ir.ui.view" id="refund_view_form">
<field name="model">account.payment.braintree.refund</field>
<field name="type">form</field>
@@ -229,18 +217,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="string">Approve</field>
</record>
<record model="ir.cron" id="cron_refund">
<field name="method">account.payment.braintree.refund|braintree_refund</field>
<field name="interval_number" eval="15"/>
<field name="interval_type">minutes</field>
</record>
<record model="ir.cron" id="cron_pull_refund">
<field name="method">account.payment.braintree.refund|braintree_pull</field>
<field name="interval_number" eval="15"/>
<field name="interval_type">minutes</field>
</record>
<record model="ir.ui.view" id="customer_view_form">
<field name="model">account.payment.braintree.customer</field>
<field name="type">form</field>
@@ -299,18 +275,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="string">Update</field>
</record>
<record model="ir.cron" id="cron_create_customer">
<field name="method">account.payment.braintree.customer|braintree_create</field>
<field name="interval_number" eval="1"/>
<field name="interval_type">hours</field>
</record>
<record model="ir.cron" id="cron_delete_customer">
<field name="method">account.payment.braintree.customer|braintree_delete</field>
<field name="interval_number" eval="1"/>
<field name="interval_type">hours</field>
</record>
<record model="ir.model.button" id="customer_payment_method_delete_button">
<field name="model">account.payment.braintree.customer</field>
<field name="name">delete_payment_method</field>
@@ -347,4 +311,41 @@ this repository contains the full copyright notices and license terms. -->
<field name="template_extension">html</field>
</record>
</data>
<data grouped="1" noupdate="1">
<record model="ir.cron" id="cron_transact_payment">
<field name="method">account.payment|braintree_transact</field>
<field name="interval_number" eval="15"/>
<field name="interval_type">minutes</field>
</record>
<record model="ir.cron" id="cron_pull_payment">
<field name="method">account.payment|braintree_pull</field>
<field name="interval_number" eval="15"/>
<field name="interval_type">minutes</field>
</record>
<record model="ir.cron" id="cron_refund">
<field name="method">account.payment.braintree.refund|braintree_refund</field>
<field name="interval_number" eval="15"/>
<field name="interval_type">minutes</field>
</record>
<record model="ir.cron" id="cron_pull_refund">
<field name="method">account.payment.braintree.refund|braintree_pull</field>
<field name="interval_number" eval="15"/>
<field name="interval_type">minutes</field>
</record>
<record model="ir.cron" id="cron_create_customer">
<field name="method">account.payment.braintree.customer|braintree_create</field>
<field name="interval_number" eval="1"/>
<field name="interval_type">hours</field>
</record>
<record model="ir.cron" id="cron_delete_customer">
<field name="method">account.payment.braintree.customer|braintree_delete</field>
<field name="interval_number" eval="1"/>
<field name="interval_type">hours</field>
</record>
</data>
</tryton>
+2 -1
View File
@@ -44,7 +44,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">succeed_wizard</field>
<field name="string">Succeed</field>
</record>
</data>
<data noupdate="1">
<record model="ir.cron" id="cron_post_clearing_moves">
<field name="method">account.payment.journal|cron_post_clearing_moves</field>
<field name="interval_number" eval="1"/>
+6 -5
View File
@@ -324,6 +324,12 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">customer_source_detach_ask_form</field>
</record>
<record model="ir.action.url" id="url_checkout">
<field name="name">Stripe Checkout</field>
<field name="url">%(http_host)s/%(database)s/account_payment_stripe/checkout/%(model)s/%(id)s</field>
</record>
</data>
<data grouped="1" noupdate="1">
<record model="ir.cron" id="cron_charge">
<field name="method">account.payment|stripe_charge</field>
<field name="interval_number" eval="15"/>
@@ -365,10 +371,5 @@ this repository contains the full copyright notices and license terms. -->
<field name="interval_number" eval="15"/>
<field name="interval_type">minutes</field>
</record>
<record model="ir.action.url" id="url_checkout">
<field name="name">Stripe Checkout</field>
<field name="url">%(http_host)s/%(database)s/account_payment_stripe/checkout/%(model)s/%(id)s</field>
</record>
</data>
</tryton>
-8
View File
@@ -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)
+2 -1
View File
@@ -138,7 +138,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">run</field>
<field name="string">Run</field>
</record>
</data>
<data noupdate="1">
<record model="ir.cron" id="cron_cron">
<field name="method">currency.cron|update</field>
<field name="interval_number" eval="1"/>
@@ -308,7 +308,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="report">marketing_automation/unsubscribe.html</field>
<field name="template_extension">html</field>
</record>
</data>
<data noupdate="1">
<record model="ir.cron" id="cron_scenario_trigger">
<field name="method">marketing.automation.scenario|trigger</field>
<field name="interval_number" eval="1"/>
@@ -319,6 +320,5 @@ this repository contains the full copyright notices and license terms. -->
<field name="interval_number" eval="15"/>
<field name="interval_type">minutes</field>
</record>
</data>
</tryton>
+2 -1
View File
@@ -208,7 +208,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="type">form</field>
<field name="name">send_test_form</field>
</record>
</data>
<data noupdate="1">
<record model="ir.cron" id="cron_send_messages">
<field name="method">marketing.email.message|process</field>
<field name="interval_number" eval="15"/>
-4
View File
@@ -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'
-4
View File
@@ -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
+1 -1
View File
@@ -2,7 +2,7 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<data noupdate="1">
<record model="ir.cron" id="cron_fill_cache">
<field name="method">product.price_list|fill_cache</field>
<field name="interval_number" eval="1"/>
+2 -1
View File
@@ -279,7 +279,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="wiz_name">stock.shipment.assign</field>
<field name="model">production</field>
</record>
</data>
<data noupdate="1">
<record model="ir.cron" id="cron_set_cost_from_moves">
<field name="method">production|set_cost_from_moves</field>
<field name="interval_number" eval="1"/>
@@ -49,7 +49,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
</data>
<data noupdate="1">
<record model="ir.cron" id="cron_product_association_rule_compute">
<field name="method">sale.product.association.rule|compute</field>
<field name="interval_number" eval="1"/>
+7 -7
View File
@@ -266,12 +266,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">line_consumption_create_start_form</field>
</record>
<record model="ir.cron" id="cron_generate_line_consumption">
<field name="method">sale.subscription.line|generate_consumption</field>
<field name="interval_number" eval="1"/>
<field name="interval_type">days</field>
</record>
<record model="ir.action.wizard" id="act_create_invoice">
<field name="name">Create Subscription Invoices</field>
<field name="wiz_name">sale.subscription.create_invoice</field>
@@ -293,12 +287,18 @@ this repository contains the full copyright notices and license terms. -->
<field name="type">form</field>
<field name="name">create_invoice_start_form</field>
</record>
</data>
<data noupdate="1">
<record model="ir.cron" id="cron_generate_line_consumption">
<field name="method">sale.subscription.line|generate_consumption</field>
<field name="interval_number" eval="1"/>
<field name="interval_type">days</field>
</record>
<record model="ir.cron" id="cron_generate_invoice">
<field name="method">sale.subscription|generate_invoice</field>
<field name="interval_number" eval="1"/>
<field name="interval_type">days</field>
</record>
</data>
</tryton>
-4
View File
@@ -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():
+7 -6
View File
@@ -31,12 +31,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">recompute_cost_price_start_form</field>
</record>
<record model="ir.cron" id="cron_recompute_cost_price_from_moves">
<field name="method">product.product|recompute_cost_price_from_moves</field>
<field name="interval_number" eval="1"/>
<field name="interval_type">days</field>
</record>
<record model="ir.ui.view" id="product_cost_price_revision_view_form">
<field name="model">product.cost_price.revision</field>
<field name="type">form</field>
@@ -412,4 +406,11 @@ this repository contains the full copyright notices and license terms. -->
<field name="perm_delete" eval="False"/>
</record>
</data>
<data noupdate="1">
<record model="ir.cron" id="cron_recompute_cost_price_from_moves">
<field name="method">product.product|recompute_cost_price_from_moves</field>
<field name="interval_number" eval="1"/>
<field name="interval_type">days</field>
</record>
</data>
</tryton>
+2 -1
View File
@@ -84,7 +84,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
</data>
<data noupdate="1">
<record model="ir.cron" id="cron_sync_roles">
<field name="method">res.user|sync_roles</field>
<field name="interval_number" eval="1"/>
+2 -1
View File
@@ -8,7 +8,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="inherit" ref="web_shop.shop_view_form"/>
<field name="name">shop_form</field>
</record>
</data>
<data noupdate="1">
<record model="ir.cron" id="cron_update">
<field name="method">web.shop|vsf_update</field>
<field name="interval_number" eval="1"/>
+1
View File
@@ -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
-12
View File
@@ -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.
-4
View File
@@ -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 [(
+1 -2
View File
@@ -2,8 +2,7 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<data noupdate="1">
<!--
lang_en is defined here to be in translation lang selection
-->
-5
View File
@@ -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:
+4 -1
View File
@@ -8,6 +8,8 @@ this repository contains the full copyright notices and license terms. -->
parent="menu_administration"
sequence="30"
id="menu_localization"/>
</data>
<data grouped="1" noupdate="1">
<record model="ir.lang" id="lang_bg">
<field name="code">bg</field>
<field name="name">Bulgarian</field>
@@ -556,7 +558,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="p_sep_by_space" eval="False"/>
<field name="n_sep_by_space" eval="False"/>
</record>
</data>
<data>
<record model="ir.ui.view" id="lang_view_tree">
<field name="model">ir.lang</field>
<field name="type">tree</field>
+3 -3
View File
@@ -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
+7 -6
View File
@@ -345,12 +345,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="rule_group" ref="rule_group_sequence_strict"/>
</record>
<record model="ir.cron" id="cron_trigger_time">
<field name="method">ir.trigger|trigger_time</field>
<field name="interval_number" eval="5"/>
<field name="interval_type">minutes</field>
</record>
<record model="ir.model.access" id="rule_default_view_tree_state">
<field name="model">ir.ui.view_tree_state</field>
<field name="perm_read" eval="False" />
@@ -459,4 +453,11 @@ this repository contains the full copyright notices and license terms. -->
<field name="perm_delete" eval="True"/>
</record>
</data>
<data noupdate="1">
<record model="ir.cron" id="cron_trigger_time">
<field name="method">ir.trigger|trigger_time</field>
<field name="interval_number" eval="5"/>
<field name="interval_type">minutes</field>
</record>
</data>
</tryton>
+7 -7
View File
@@ -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):