[FIX] mail_gateway: dummy compatibility with m2m fields

Other OCA modules extending the composer add m2m fields with fixed
relations. To avoid a glue module we try for the moment to add those
manually.

TT51108
pull/1489/head
David 2024-11-07 12:21:17 +01:00
parent 34d02e4a39
commit 8b6e6c4f41
3 changed files with 31 additions and 2 deletions

View File

@ -67,6 +67,8 @@ class ResPartnerGatewayChannel(models.Model):
)
def name_get(self):
# Be able to tell to which partner belongs the gateway partner channel
# e.g.: picking it from a selector
result = []
origin = super().name_get()
if not self.env.context.get("mail_gateway_partner_info", False):

View File

@ -28,7 +28,6 @@ class MailComposeGatewayMessage(models.TransientModel):
"attachment_id",
"Attachments",
)
partner_ids = fields.Many2many(
"res.partner",
"mail_compose_gateway_message_res_partner_rel",
@ -37,6 +36,30 @@ class MailComposeGatewayMessage(models.TransientModel):
"Additional Contacts",
domain=lambda r: r._partner_ids_domain(),
)
# Dummy compatibility with other OCA modules
# OCA/mail_attach_existing_attachment
object_attachment_ids = fields.Many2many(
comodel_name="ir.attachment",
relation="mail_compose_gateway_message_ir_attachments_object_rel",
column1="wizard_id",
column2="attachment_id",
string="Object Attachments",
)
# OCA/mail_composer_cc_bcc
partner_cc_ids = fields.Many2many(
comodel_name="res.partner",
relation="mail_compose_gateway_message_res_partner_cc_rel",
column1="wizard_id",
column2="partner_id",
string="Cc",
)
partner_bcc_ids = fields.Many2many(
comodel_name="res.partner",
relation="mail_compose_gateway_message_res_partner_bcc_rel",
column1="wizard_id",
column2="partner_id",
string="Bcc",
)
def get_mail_values(self, res_ids):
self.ensure_one()

View File

@ -8,13 +8,17 @@
<field name="inherit_id" ref="mail.email_compose_message_wizard_form" />
<field name="mode">primary</field>
<field name="arch" type="xml">
<label for="partner_ids" position="attributes">
<attribute name="invisible">1</attribute>
</label>
<field name="partner_ids" position="attributes">
<attribute name="invisible">1</attribute>
</field>
<field name="body" position="before">
<field name="subject" position="before">
<field name="wizard_partner_ids" invisible="1" />
<field
name="wizard_channel_ids"
string="Gateways"
widget="many2many_tags"
context="{'mail_gateway_partner_info': 1}"
domain="[('partner_id', 'in', wizard_partner_ids)]"