Skip to content

Commit 821a063

Browse files
committed
fixup! edi_sale_ubl_oca: use edi.config
1 parent 43bfc5a commit 821a063

File tree

1 file changed

+0
-65
lines changed

1 file changed

+0
-65
lines changed

edi_sale_ubl_oca/models/sale_order.py

-65
Original file line numberDiff line numberDiff line change
@@ -83,71 +83,6 @@ def create(self, vals_list):
8383
.with_context(evt_from_create=None)
8484
)
8585

86-
# FIXME: move to core
87-
# TODO: test
88-
def _edi_send_via_edi(self, exchange_type, force=False, **kw):
89-
exchange_record = None
90-
# If we are sending an ack, we must check if we can generate it
91-
if exchange_type.ack_for_type_ids:
92-
if self._edi_can_generate_ack(exchange_type):
93-
__, exchange_record = self._edi_get_or_create_ack_record(
94-
exchange_type, force=force
95-
)
96-
else:
97-
exchange_record = self._edi_create_exchange_record(exchange_type)
98-
if exchange_record:
99-
exchange_record.action_exchange_generate_send(**kw)
100-
101-
def _edi_can_generate_ack(self, exchange_type, force=False):
102-
"""Have to generate ack for this exchange type?
103-
104-
:param exchange_type: The exchange type to check.
105-
106-
It should be generated if:
107-
- automation is not disabled and not forced
108-
- origin exchange record is set (means it was originated by another record)
109-
- origin exchange type is compatible with the configured ack types
110-
"""
111-
if (self.disable_edi_auto and not force) or not self.origin_exchange_record_id:
112-
return False
113-
return self.origin_exchange_type_id in exchange_type.ack_for_type_ids
114-
115-
def _edi_get_or_create_ack_record(self, exchange_type, force=False):
116-
"""
117-
Get or create a child record for the given exchange type.
118-
119-
If the record has not been sent out yet for whatever reason
120-
(job delayed, job failed, send failed, etc)
121-
we still want to generate a new up to date record to be sent.
122-
123-
:param exchange_type: The exchange type to create the record for.
124-
:param force: If True, will force the creation of the record in case of ack type.
125-
"""
126-
if not self._edi_can_generate_ack(exchange_type, force=force):
127-
return False, False
128-
parent = self._edi_get_origin()
129-
# Filter acks that are not valued yet.
130-
exchange_record = self._get_exchange_record(exchange_type).filtered(
131-
lambda x: not x.exchange_file
132-
)
133-
created = False
134-
# If the record has not been sent out yet for whatever reason
135-
# (job delayed, job failed, send failed, etc)
136-
# we still want to generate a new up to date record to be sent.
137-
still_pending = exchange_record.edi_exchange_state in (
138-
"output_pending",
139-
"output_error_on_send",
140-
)
141-
if not exchange_record or still_pending:
142-
vals = exchange_record._exchange_child_record_values()
143-
vals["parent_id"] = parent.id
144-
# NOTE: to fully automatize this,
145-
# is recommended to enable `quick_exec` on the type
146-
# otherwise records will have to wait for the cron to pass by.
147-
exchange_record = self._edi_create_exchange_record(exchange_type, vals=vals)
148-
created = True
149-
return created, exchange_record
150-
15186

15287
class SaleOrderLine(models.Model):
15388
_name = "sale.order.line"

0 commit comments

Comments
 (0)