From b91315af9785626dfa4a7a79fdd4aa980eb11dea Mon Sep 17 00:00:00 2001 From: Mansi Gandhi Date: Wed, 22 Mar 2017 15:24:28 +0100 Subject: [PATCH] [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. --- addons/mrp_repair/__manifest__.py | 3 +- addons/mrp_repair/data/mrp_repair_data.xml | 31 ++++++++++++++++++++ addons/mrp_repair/models/mrp_repair.py | 23 +++++++++++++-- addons/mrp_repair/views/mrp_repair_views.xml | 1 + 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 addons/mrp_repair/data/mrp_repair_data.xml diff --git a/addons/mrp_repair/__manifest__.py b/addons/mrp_repair/__manifest__.py index a6adb2bd019..c059e8a8865 100644 --- a/addons/mrp_repair/__manifest__.py +++ b/addons/mrp_repair/__manifest__.py @@ -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': [], diff --git a/addons/mrp_repair/data/mrp_repair_data.xml b/addons/mrp_repair/data/mrp_repair_data.xml new file mode 100644 index 00000000000..839b5729e23 --- /dev/null +++ b/addons/mrp_repair/data/mrp_repair_data.xml @@ -0,0 +1,31 @@ + + + + + + + Mrp Repair Quotation - Send by Email + ${(object.create_uid.email and '%s <%s>' % (object.create_uid.name, object.create_uid.email) or '')|safe} + ${object.partner_id.name} Repair Orders (Ref ${object.name or 'n/a' }) + ${object.partner_id.id} + + + ${(object.name or '').replace('/','_')} + ${object.partner_id.lang} + +

Dear ${object.partner_id.name}

+

+ Here is your repair order ${doc_name} ${object.name} + % if object.origin: + (with reference: ${object.origin} ) + % endif + % if object.invoice_method != 'none': + amounting in ${object.amount_total} ${object.pricelist_id.currency_id.name}. + % endif +

+

You can reply to this email if you have any questions.

+

Thank you,

+
+
+
+
diff --git a/addons/mrp_repair/models/mrp_repair.py b/addons/mrp_repair/models/mrp_repair.py index b78e72e394b..dbcb70a9fee 100644 --- a/addons/mrp_repair/models/mrp_repair.py +++ b/addons/mrp_repair/models/mrp_repair.py @@ -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 diff --git a/addons/mrp_repair/views/mrp_repair_views.xml b/addons/mrp_repair/views/mrp_repair_views.xml index bf0fdddf36f..505f2d3abec 100644 --- a/addons/mrp_repair/views/mrp_repair_views.xml +++ b/addons/mrp_repair/views/mrp_repair_views.xml @@ -26,6 +26,7 @@
+