[IMP] mrp_repair: send quotation and mail template

When you send a quotation, you have a mail template mentionning the
quotation and its price if there is an invoice method, with the quotaion
in attachment.
This commit is contained in:
Mansi Gandhi
2017-03-22 16:56:04 +01:00
committed by Pierre Masereel
parent 140c0e2203
commit b91315af97
4 changed files with 55 additions and 3 deletions
+2 -1
View File
@@ -26,12 +26,13 @@ The following topics are covered by this module:
'data': [
'security/ir.model.access.csv',
'security/mrp_repair_security.xml',
'data/ir_sequence_data.xml',
'wizard/mrp_repair_cancel_views.xml',
'wizard/mrp_repair_make_invoice_views.xml',
'views/mrp_repair_views.xml',
'report/mrp_repair_reports.xml',
'report/mrp_repair_templates_repair_order.xml',
'data/ir_sequence_data.xml',
'data/mrp_repair_data.xml',
],
'demo': ['data/mrp_repair_demo.yml'],
'test': [],
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!--Email template -->
<record id="mail_template_mrp_repair_quotation" model="mail.template">
<field name="name">Mrp Repair Quotation - Send by Email</field>
<field name="email_from">${(object.create_uid.email and '%s &lt;%s&gt;' % (object.create_uid.name, object.create_uid.email) or '')|safe}</field>
<field name="subject">${object.partner_id.name} Repair Orders (Ref ${object.name or 'n/a' })</field>
<field name="partner_to">${object.partner_id.id}</field>
<field name="model_id" ref="mrp_repair.model_mrp_repair"/>
<field name="report_template" ref="action_report_mrp_repair_order"/>
<field name="report_name">${(object.name or '').replace('/','_')}</field>
<field name="lang">${object.partner_id.lang}</field>
<field name="body_html" type="xml">
<p>Dear ${object.partner_id.name}</p>
<p>
Here is your repair order ${doc_name} <strong>${object.name}</strong>
% if object.origin:
(with reference: ${object.origin} )
% endif
% if object.invoice_method != 'none':
amounting in <strong>${object.amount_total} ${object.pricelist_id.currency_id.name}.</strong>
% endif
</p>
<p>You can reply to this email if you have any questions.</p>
<p>Thank you,</p>
</field>
</record>
</data>
</odoo>
+21 -2
View File
@@ -224,6 +224,26 @@ class Repair(models.Model):
self.mapped('operations').write({'state': 'cancel'})
return self.write({'state': 'cancel'})
@api.multi
def action_send_mail(self):
self.ensure_one()
template_id = self.env.ref('mrp_repair.mail_template_mrp_repair_quotation').id
ctx = {
'default_model': 'mrp.repair',
'default_res_id': self.id,
'default_use_template': bool(template_id),
'default_template_id': template_id,
'default_composition_mode': 'comment'
}
return {
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'target': 'new',
'context': ctx,
}
@api.multi
def print_repair_order(self):
return self.env['report'].get_action(self, 'mrp_repair.report_mrprepairorder')
@@ -480,8 +500,7 @@ class RepairLine(models.Model):
self.location_id = False
self.location_dest_id = False
elif self.type == 'add':
if self.repair_id.partner_id and self.product_id:
self.tax_id = self.repair_id.partner_id.property_account_position_id.map_tax(self.product_id.taxes_id, self.product_id, self.repair_id.partner_id).ids
self.onchange_product_id()
args = self.repair_id.company_id and [('company_id', '=', self.repair_id.company_id.id)] or []
warehouse = self.env['stock.warehouse'].search(args, limit=1)
self.location_id = warehouse.lot_stock_id
@@ -26,6 +26,7 @@
<field name="arch" type="xml">
<form string="Repair Order">
<header>
<button name="action_send_mail" states="draft" string="Send Quotation" type="object"/>
<button name="print_repair_order" states="draft" string="Print Quotation" type="object"/>
<button name="action_repair_confirm" states="draft" type="object" string="Confirm Repair" class="oe_highlight"/>
<button name="action_repair_start" attrs="{'invisible': ['&amp;', ('state','!=','confirmed'), '!', '&amp;', ('state','=','ready'), ('invoice_method','=','b4repair')]}"