Skip to content

Commit ec1e7f2

Browse files
[IMP] rma: Send label by email
1 parent a577b09 commit ec1e7f2

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

rma/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"data/rma_sequence.xml",
1818
"data/stock_data.xml",
1919
"data/rma_operation.xml",
20+
"data/mail_template_rma_return_label.xml",
2021
"report/rma_report.xml",
2122
"report/rma_report_templates.xml",
2223
"report/report_deliveryslip.xml",
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<record id="email_template_rma_return_label" model="mail.template">
4+
<field name="name">RMA: Send Return Label</field>
5+
<field name="model_id" ref="rma.model_rma_order_line" />
6+
<field name="subject">Return Label for RMA {{ object.name }}</field>
7+
<field
8+
name="email_from"
9+
>{{ (object.assigned_to.email_formatted or object.company_id.email_formatted or user.email_formatted) }}</field>
10+
<field name="partner_to">{{ object.partner_id.id }}</field>
11+
<field name="body_html" type="html">
12+
<div style="margin: 0px; padding: 0px;">
13+
<p style="margin: 0px; padding: 0px; font-size: 13px;">
14+
Hello <t t-out="object.partner_id.name or ''">Customer</t>,
15+
<br /><br />
16+
Please find attached the return label for your RMA <span
17+
style="font-weight: bold;"
18+
t-out="object.name or ''"
19+
>RMA/0001</span>.
20+
<br /><br />
21+
Please print the label, include one copy inside the package, and attach another copy to the outside of the box before shipping the item(s) back to us.
22+
<t t-if="object.product_id">
23+
<br />
24+
<br />
25+
<strong>Product:</strong>
26+
<t t-out="object.product_id.display_name or ''" />
27+
<t t-if="object.lot_id">
28+
&amp;nbsp;— <strong>Lot/Serial:</strong> <t
29+
t-out="object.lot_id.name or ''"
30+
/>
31+
</t>
32+
</t>
33+
<br /><br />
34+
Do not hesitate to contact us if you have any questions.
35+
<t t-if="not is_html_empty(object.assigned_to.signature)">
36+
<br />
37+
<br />
38+
<t t-out="object.assigned_to.signature or ''" />
39+
</t>
40+
<br /><br />
41+
</p>
42+
</div>
43+
</field>
44+
<field
45+
name="report_template_ids"
46+
eval="[(4, ref('rma.rma_order_line_return_label_report'))]"
47+
/>
48+
<field name="lang">{{ object.partner_id.lang }}</field>
49+
<field name="auto_delete" eval="True" />
50+
</record>
51+
</odoo>

rma/models/rma_order_line.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,28 @@ def _get_price_unit(self):
697697
price_unit = self.product_id.with_company(self.company_id).standard_price
698698
return price_unit
699699

700+
def action_send_return_label(self):
701+
self.ensure_one()
702+
template = self.env.ref(
703+
"rma.email_template_rma_return_label", raise_if_not_found=False
704+
)
705+
ctx = {
706+
"default_model": "rma.order.line",
707+
"default_res_ids": self.ids,
708+
"default_composition_mode": "comment",
709+
"default_template_id": template.id if template else False,
710+
"force_email": True,
711+
}
712+
return {
713+
"type": "ir.actions.act_window",
714+
"view_mode": "form",
715+
"res_model": "mail.compose.message",
716+
"views": [(False, "form")],
717+
"view_id": False,
718+
"target": "new",
719+
"context": ctx,
720+
}
721+
700722
@api.onchange("product_id")
701723
def _onchange_product_id(self):
702724
result = {}

rma/views/rma_order_line_view.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@
107107
invisible="type != 'customer' or state != 'approved'"
108108
type="action"
109109
/>
110+
<button
111+
name="action_send_return_label"
112+
type="object"
113+
string="Send Return Label"
114+
invisible="type != 'customer' or state not in ('approved', 'done')"
115+
icon="fa-envelope"
116+
groups="rma.group_rma_customer_user"
117+
/>
110118
<field
111119
name="state"
112120
widget="statusbar"

0 commit comments

Comments
 (0)