From 821a063837008820e439e3bde0225e0cdf56b90b Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Fri, 15 Nov 2024 09:41:19 +0100 Subject: [PATCH] fixup! edi_sale_ubl_oca: use edi.config --- edi_sale_ubl_oca/models/sale_order.py | 65 --------------------------- 1 file changed, 65 deletions(-) diff --git a/edi_sale_ubl_oca/models/sale_order.py b/edi_sale_ubl_oca/models/sale_order.py index 5d1b718779..73f2839798 100644 --- a/edi_sale_ubl_oca/models/sale_order.py +++ b/edi_sale_ubl_oca/models/sale_order.py @@ -83,71 +83,6 @@ def create(self, vals_list): .with_context(evt_from_create=None) ) - # FIXME: move to core - # TODO: test - def _edi_send_via_edi(self, exchange_type, force=False, **kw): - exchange_record = None - # If we are sending an ack, we must check if we can generate it - if exchange_type.ack_for_type_ids: - if self._edi_can_generate_ack(exchange_type): - __, exchange_record = self._edi_get_or_create_ack_record( - exchange_type, force=force - ) - else: - exchange_record = self._edi_create_exchange_record(exchange_type) - if exchange_record: - exchange_record.action_exchange_generate_send(**kw) - - def _edi_can_generate_ack(self, exchange_type, force=False): - """Have to generate ack for this exchange type? - - :param exchange_type: The exchange type to check. - - It should be generated if: - - automation is not disabled and not forced - - origin exchange record is set (means it was originated by another record) - - origin exchange type is compatible with the configured ack types - """ - if (self.disable_edi_auto and not force) or not self.origin_exchange_record_id: - return False - return self.origin_exchange_type_id in exchange_type.ack_for_type_ids - - def _edi_get_or_create_ack_record(self, exchange_type, force=False): - """ - Get or create a child record for the given exchange type. - - If the record has not been sent out yet for whatever reason - (job delayed, job failed, send failed, etc) - we still want to generate a new up to date record to be sent. - - :param exchange_type: The exchange type to create the record for. - :param force: If True, will force the creation of the record in case of ack type. - """ - if not self._edi_can_generate_ack(exchange_type, force=force): - return False, False - parent = self._edi_get_origin() - # Filter acks that are not valued yet. - exchange_record = self._get_exchange_record(exchange_type).filtered( - lambda x: not x.exchange_file - ) - created = False - # If the record has not been sent out yet for whatever reason - # (job delayed, job failed, send failed, etc) - # we still want to generate a new up to date record to be sent. - still_pending = exchange_record.edi_exchange_state in ( - "output_pending", - "output_error_on_send", - ) - if not exchange_record or still_pending: - vals = exchange_record._exchange_child_record_values() - vals["parent_id"] = parent.id - # NOTE: to fully automatize this, - # is recommended to enable `quick_exec` on the type - # otherwise records will have to wait for the cron to pass by. - exchange_record = self._edi_create_exchange_record(exchange_type, vals=vals) - created = True - return created, exchange_record - class SaleOrderLine(models.Model): _name = "sale.order.line"