diff --git a/edi_oca/tests/fake_components.py b/edi_oca/tests/fake_components.py index 1602547f529..449ded4b614 100644 --- a/edi_oca/tests/fake_components.py +++ b/edi_oca/tests/fake_components.py @@ -141,22 +141,16 @@ class FakeConfigurationListener(FakeComponentMixin): _inherit = "base.event.listener" _apply_on = ["edi.exchange.consumer.test"] - def on_record_write_configuration(self, record, fields=None, **kwargs): + def on_record_write(self, record, fields=None, **kwargs): trigger = "on_record_write" - if kwargs.get("vals", False): - for rec in record: - confs = record.edi_config_ids.edi_get_conf(trigger) - for conf in confs: - conf.edi_exec_snippet_do(rec, **kwargs) + confs = record.edi_config_ids.edi_get_conf(trigger) + for conf in confs: + conf.edi_exec_snippet_do(record, **kwargs) return True - def on_record_create_configuration(self, record, fields=None, **kwargs): + def on_record_create(self, record, fields=None, **kwargs): trigger = "on_record_create" - val_list = kwargs.get("vals", False) - if val_list: - for rec, vals in zip(record, val_list): - kwargs["vals"] = {rec.id: vals} - confs = rec.edi_config_ids.edi_get_conf(trigger) - for conf in confs: - conf.edi_exec_snippet_do(rec, **kwargs) + confs = record.edi_config_ids.edi_get_conf(trigger) + for conf in confs: + conf.edi_exec_snippet_do(record, **kwargs) return True diff --git a/edi_oca/tests/fake_models.py b/edi_oca/tests/fake_models.py index cb878903678..364c84faeff 100644 --- a/edi_oca/tests/fake_models.py +++ b/edi_oca/tests/fake_models.py @@ -2,7 +2,7 @@ # @author: Enric Tobella # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -from odoo import api, fields, models +from odoo import fields, models class EdiExchangeConsumerTest(models.Model): @@ -22,60 +22,3 @@ class EdiExchangeConsumerTest(models.Model): def _get_edi_exchange_record_name(self, exchange_record): return self.id - - @api.model_create_multi - def create(self, vals_list): - records = super().create(vals_list) - operation = "create" - - new_records = self.browse() - new_vals_list = [] - - for rec, vals in zip(records, vals_list): - if not rec._edi_configuration_skip(operation): - new_records |= rec - new_vals_list.append(vals) - - if new_records: - self._event("on_record_create_configuration").notify( - new_records, - operation=operation, - vals=new_vals_list, - ) - return records - - def write(self, vals): - operation = "write" - new_records = self.browse() - - for rec in self: - if not rec._edi_configuration_skip(operation): - new_records |= rec - - old_vals = {} - for record in new_records: - old_vals[record.id] = {field: record[field] for field in vals.keys()} - - res = super().write(vals) - - new_values = {} - for record in new_records: - new_values[record.id] = {field: record[field] for field in vals.keys()} - - if new_values: - self._event("on_record_write_configuration").notify( - new_records, - operation=operation, - old_vals=old_vals, - vals=new_values, - ) - return res - - def _edi_configuration_skip(self, operation): - skip_reason = None - if self.env.context.get("edi_skip_configuration"): - skip_reason = "edi_skip_configuration ctx key found" - # TODO: Add more skip cases - if skip_reason: - return True - return False