Skip to content

Commit

Permalink
Merge PR #778 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by simahawk
  • Loading branch information
OCA-git-bot committed Aug 11, 2023
2 parents d242fc1 + 74caa3a commit 0b5a9e9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions edi_oca/models/edi_exchange_consumer_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ class EDIExchangeConsumerMixin(models.AbstractModel):
default={},
)
edi_has_form_config = fields.Boolean(compute="_compute_edi_config")
# TODO: rename to `edi_disable_auto`
disable_edi_auto = fields.Boolean(
string="Disable auto",
help="When marked, EDI automatic processing will be avoided",
# Each extending module should override `states` as/if needed.
)

def _compute_edi_config(self):
for record in self:
Expand Down
22 changes: 22 additions & 0 deletions edi_oca/models/edi_exchange_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ class EDIExchangeType(models.Model):
help="When active, records of this type will be processed immediately "
"without waiting for the cron to pass by.",
)
partner_ids = fields.Many2many(
string="Enabled for partners",
comodel_name="res.partner",
help=(
"You can use this field to limit generating/processing exchanges "
"for specific partners. "
"Use it directly or within models rules (domain or snippet)."
),
)

_sql_constraints = [
(
Expand Down Expand Up @@ -218,3 +227,16 @@ def _get_record_name(self, exchange_record):
if hasattr(exchange_record.record, "_get_edi_exchange_record_name"):
return exchange_record.record._get_edi_exchange_record_name(exchange_record)
return slugify(exchange_record.record.display_name)

def is_partner_enabled(self, partner):
"""Check if given partner record is allowed for the current type.
You can leverage this in your own logic to trigger or not
certain exchanges for specific partners.
For instance: a customer might require an ORDRSP while another does not.
"""
exc_type = self.sudo()
if exc_type.partner_ids:
return partner.id in exc_type.partner_ids.ids
return True
1 change: 1 addition & 0 deletions edi_oca/views/edi_exchange_type_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<field name="exchange_file_auto_generate" />
<field name="ack_type_id" />
<field name="ack_for_type_ids" widget="many2many_tags" />
<field name="partner_ids" widget="many2many_tags" />
<field name="job_channel_id" />
<field name="quick_exec" />
</group>
Expand Down

0 comments on commit 0b5a9e9

Please sign in to comment.