Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions purchase_blanket_order/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"views/purchase_order_views.xml",
"report/templates.xml",
"report/report.xml",
"data/mail_template_blanket_order.xml",
],
"installable": True,
}
39 changes: 39 additions & 0 deletions purchase_blanket_order/data/mail_template_blanket_order.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright (C) 2026 Akretion (<http://www.akretion.com>).
@author Kévin Roche <kevin.roche@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="email_template_blanket_order" model="mail.template">
<field name="name">Purchase Blanket Order: Send by Email</field>
<field
name="model_id"
ref="purchase_blanket_order.model_purchase_blanket_order"
/>
<field name="subject">{{ object.name }}</field>
<field name="partner_to">{{ object.partner_id.id }}</field>
<field name="body_html" type="html">
<div>
<tbody>
<tr>
<td style="padding:15px 20px 10px 20px;">
<p>Dear <strong><t
t-out="object.partner_id.name"
/></strong>,</p>
<p>Please find attached the blanket order <strong><t
t-out="object.name"
/></strong>.</p>
<p>Best regards,<br /><t t-out="object.user_id.name" /></p>
</td>
</tr>
</tbody>
</div>
</field>
<field
name="report_template"
ref="purchase_blanket_order.report_blanket_order"
/>
<field name="report_name">Blanket_Order_{{ object.name }}</field>
<field name="lang">{{ object.partner_id.lang }}</field>
<field name="auto_delete" eval="True" />
</record>
</odoo>
24 changes: 24 additions & 0 deletions purchase_blanket_order/models/blanket_orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,30 @@ def _search_remaining_uom_qty(self, operator, value):
res.append(("id", "in", order_ids.ids))
return res

def action_send_email(self):
self.ensure_one()
template = self.env.ref(
"purchase_blanket_order.email_template_blanket_order",
raise_if_not_found=False,
)
ctx = {
"default_model": "purchase.blanket.order",
"default_res_id": self.id,
"default_use_template": bool(template),
"default_template_id": template and template.id or False,
"default_composition_mode": "comment",
"force_email": True,
}
return {
"type": "ir.actions.act_window",
"view_mode": "form",
"res_model": "mail.compose.message",
"views": [(False, "form")],
"view_id": False,
"target": "new",
"context": ctx,
}


class BlanketOrderLine(models.Model):
_name = "purchase.blanket.order.line"
Expand Down
2 changes: 1 addition & 1 deletion purchase_blanket_order/report/templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<t t-foreach="doc.line_ids" t-as="l">
<tr>
<td name="td_name" class="text-left">
<span t-field="l.product_id" />
<span t-field="l.name" />
</td>
<td class="text-right">
<span t-field="l.price_unit" />
Expand Down
9 changes: 9 additions & 0 deletions purchase_blanket_order/views/purchase_blanket_order_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@
class="btn-primary o_purchase_confirm"
type="object"
/>
<button
name="action_send_email"
string="Send Email"
type="object"
class="btn-secondary"
attrs="{'invisible': [('state', 'in', ['draft', 'expired'])]}"
icon="fa-envelope"
/>
<field
name="state"
widget="statusbar"
Expand Down Expand Up @@ -144,6 +152,7 @@
name="product_id"
context="{'partner_id':parent.partner_id, 'quantity':original_uom_qty, 'company_id': parent.company_id}"
/>
<field name="name" />
<field
name="original_uom_qty"
string="Original Qty"
Expand Down
1 change: 0 additions & 1 deletion purchase_blanket_order/wizard/create_purchase_orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def create_purchase_order(self):

vals = {
"product_id": line.product_id.id,
"name": line.product_id.name,
"date_planned": date_planned
if date_planned
else line.blanket_line_id.order_id.date_start,
Expand Down
Loading