mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
[IMP] rma: automatic notification subtypes
TT28344
This commit is contained in:
committed by
Nikolaus Weingartmair
parent
abbc70cdab
commit
8d86315406
@@ -503,7 +503,9 @@ class Rma(models.Model):
|
||||
for rma in self.filtered(lambda p: p.company_id.send_rma_confirmation):
|
||||
rma_template_id = rma.company_id.rma_mail_confirmation_template_id.id
|
||||
rma.with_context(
|
||||
force_send=True, mark_rma_as_sent=True
|
||||
force_send=True,
|
||||
mark_rma_as_sent=True,
|
||||
default_subtype_id=self.env.ref("rma.mt_rma_notification").id,
|
||||
).message_post_with_template(rma_template_id)
|
||||
|
||||
# Action methods
|
||||
@@ -514,6 +516,7 @@ class Rma(models.Model):
|
||||
form = self.env.ref("mail.email_compose_message_wizard_form", False)
|
||||
ctx = {
|
||||
"default_model": "rma",
|
||||
"default_subtype_id": self.env.ref("rma.mt_rma_notification").id,
|
||||
"default_res_id": self.ids[0],
|
||||
"default_use_template": bool(template),
|
||||
"default_template_id": template and template.id or False,
|
||||
@@ -1110,11 +1113,20 @@ class Rma(models.Model):
|
||||
|
||||
# Mail business methods
|
||||
def _creation_subtype(self):
|
||||
if self.state in ("draft", "confirmed"):
|
||||
if self.state in ("draft"):
|
||||
return self.env.ref("rma.mt_rma_draft")
|
||||
else:
|
||||
return super()._creation_subtype()
|
||||
|
||||
def _track_subtype(self, init_values):
|
||||
self.ensure_one()
|
||||
if "state" in init_values:
|
||||
if self.state == "draft":
|
||||
return self.env.ref("rma.mt_rma_draft")
|
||||
elif self.state == "confirmed":
|
||||
return self.env.ref("rma.mt_rma_notification")
|
||||
return super()._track_subtype(init_values)
|
||||
|
||||
def message_new(self, msg_dict, custom_values=None):
|
||||
"""Extract the needed values from an incoming rma emails data-set
|
||||
to be used to create an RMA.
|
||||
|
||||
Reference in New Issue
Block a user