Merge PR #205 into 12.0

Signed-off-by pedrobaeza
This commit is contained in:
OCA-git-bot
2021-03-09 14:55:56 +00:00
3 changed files with 24 additions and 3 deletions

View File

@@ -7,6 +7,12 @@
<field name="default" eval="False"/> <field name="default" eval="False"/>
<field name="description">RMA in draft state</field> <field name="description">RMA in draft state</field>
</record> </record>
<record id="mt_rma_notification" model="mail.message.subtype">
<field name="name">RMA Notificatoin</field>
<field name="res_model">rma</field>
<field name="default" eval="False"/>
<field name="description">RMA automatic customer notifications</field>
</record>
<!-- rma_team-related subtypes for messaging / Chatter --> <!-- rma_team-related subtypes for messaging / Chatter -->
<record id="mt_rma_team_rma_draft" model="mail.message.subtype"> <record id="mt_rma_team_rma_draft" model="mail.message.subtype">
<field name="name">Draft RMA</field> <field name="name">Draft RMA</field>
@@ -16,6 +22,14 @@
<field name="parent_id" eval="ref('rma.mt_rma_draft')"/> <field name="parent_id" eval="ref('rma.mt_rma_draft')"/>
<field name="relation_field">team_id</field> <field name="relation_field">team_id</field>
</record> </record>
<record id="mt_rma_team_rma_notification" model="mail.message.subtype">
<field name="name">RMA Notification</field>
<field name="sequence">20</field>
<field name="res_model">rma.team</field>
<field name="default" eval="True"/>
<field name="parent_id" eval="ref('rma.mt_rma_notification')"/>
<field name="relation_field">team_id</field>
</record>
<!--RMA email template --> <!--RMA email template -->
<record id="mail_template_rma_notification" model="mail.template"> <record id="mail_template_rma_notification" model="mail.template">
<field name="name">RMA Notification</field> <field name="name">RMA Notification</field>

View File

@@ -536,7 +536,8 @@ class Rma(models.Model):
) )
rma.with_context( rma.with_context(
force_send=True, force_send=True,
mark_rma_as_sent=True mark_rma_as_sent=True,
default_subtype_id=self.env.ref('rma.mt_rma_notification').id,
).message_post_with_template(rma_template_id) ).message_post_with_template(rma_template_id)
# Action methods # Action methods
@@ -548,6 +549,7 @@ class Rma(models.Model):
form = self.env.ref('mail.email_compose_message_wizard_form', False) form = self.env.ref('mail.email_compose_message_wizard_form', False)
ctx = { ctx = {
'default_model': 'rma', 'default_model': 'rma',
'default_subtype_id': self.env.ref('rma.mt_rma_notification').id,
'default_res_id': self.ids[0], 'default_res_id': self.ids[0],
'default_use_template': bool(template), 'default_use_template': bool(template),
'default_template_id': template and template.id or False, 'default_template_id': template and template.id or False,
@@ -1133,8 +1135,11 @@ class Rma(models.Model):
# Mail business methods # Mail business methods
def _track_subtype(self, init_values): def _track_subtype(self, init_values):
self.ensure_one() self.ensure_one()
if 'state' in init_values and self.state == 'draft': if 'state' in init_values:
if self.state == 'draft':
return 'rma.mt_rma_draft' return 'rma.mt_rma_draft'
elif self.state == 'confirmed':
return 'rma.mt_rma_notification'
return super()._track_subtype(init_values) return super()._track_subtype(init_values)
def message_new(self, msg_dict, custom_values=None): def message_new(self, msg_dict, custom_values=None):

View File

@@ -686,3 +686,5 @@ class TestRma(SavepointCase):
) )
self.assertTrue(rma.name in mail.subject) self.assertTrue(rma.name in mail.subject)
self.assertTrue(rma.name in mail.body) self.assertTrue(rma.name in mail.body)
self.assertEqual(
self.env.ref("rma.mt_rma_notification"), mail.subtype_id)