From 7f18dfc9edac895f6dde5d2e1a0b18281d0f6134 Mon Sep 17 00:00:00 2001 From: Prashant Panchal Date: Mon, 24 Aug 2015 17:00:39 +0530 Subject: [PATCH] [REF] product_email_template: migration to the new API --- addons/product_email_template/__openerp__.py | 4 +- .../data/product_demo.xml | 46 +++++++++---------- .../models/account_invoice.py | 20 ++++---- .../product_email_template/models/product.py | 15 +++--- .../views/mail_template_views.xml | 10 ++-- .../views/product_views.xml | 8 ++-- 6 files changed, 46 insertions(+), 57 deletions(-) diff --git a/addons/product_email_template/__openerp__.py b/addons/product_email_template/__openerp__.py index ad9de0b724c..a74b53c4384 100644 --- a/addons/product_email_template/__openerp__.py +++ b/addons/product_email_template/__openerp__.py @@ -17,7 +17,5 @@ For instance when invoicing a training, the training agenda and materials will a 'data': [ 'views/product_views.xml', 'views/mail_template_views.xml', - ], - 'installable': True, - 'auto_install': False, + ] } diff --git a/addons/product_email_template/data/product_demo.xml b/addons/product_email_template/data/product_demo.xml index 205af922212..a0eb8b2b2a6 100644 --- a/addons/product_email_template/data/product_demo.xml +++ b/addons/product_email_template/data/product_demo.xml @@ -22,7 +22,7 @@
  • New interactive learning experience
  • Lower training budget for the same quality courses
  • Better comfort to facilitate your learning process
  • -
  • Odoo Certification Exam included (Pre-Ordered, available as of November 1st, 2013)
  • +
  • Odoo Certification Exam included (Pre-Ordered, available as of November 1st, 2013)

  • @@ -65,35 +65,35 @@ Each day of the week is dedicated to specific applications in Odoo as per the following planning: @@ -625,7 +625,7 @@ - + ]]> diff --git a/addons/product_email_template/models/account_invoice.py b/addons/product_email_template/models/account_invoice.py index c93b3901fc0..82c0dfbbea0 100644 --- a/addons/product_email_template/models/account_invoice.py +++ b/addons/product_email_template/models/account_invoice.py @@ -1,26 +1,24 @@ # -*- coding: utf-8 -*- -from openerp.osv import osv +from odoo import api, models -class account_invoice(osv.Model): +class AccountInvoice(models.Model): _inherit = 'account.invoice' - def invoice_validate_send_email(self, cr, uid, ids, context=None): - Composer = self.pool['mail.compose.message'] - for invoice in self.browse(cr, uid, ids, context=context): + def invoice_validate_send_email(self): + for invoice in self.filtered(lambda x: x.type == 'out_invoice'): # send template only on customer invoice - if invoice.type != 'out_invoice': - continue # subscribe the partner to the invoice if invoice.partner_id not in invoice.message_partner_ids: - self.message_subscribe(cr, uid, [invoice.id], [invoice.partner_id.id], context=context) + invoice.message_subscribe([invoice.partner_id.id]) for line in invoice.invoice_line_ids: if line.product_id.email_template_id: invoice.message_post_with_template(line.product_id.email_template_id.id, composition_mode='comment') return True - def invoice_validate(self, cr, uid, ids, context=None): - res = super(account_invoice, self).invoice_validate(cr, uid, ids, context=context) - self.invoice_validate_send_email(cr, uid, ids, context=context) + @api.multi + def invoice_validate(self): + res = super(AccountInvoice, self).invoice_validate() + self.invoice_validate_send_email() return res diff --git a/addons/product_email_template/models/product.py b/addons/product_email_template/models/product.py index bd45a1c3f39..83583c3a237 100644 --- a/addons/product_email_template/models/product.py +++ b/addons/product_email_template/models/product.py @@ -1,19 +1,16 @@ # -*- coding: utf-8 -*- -from openerp.osv import fields, osv +from odoo import fields, models -class product_template(osv.Model): +class ProductTemplate(models.Model): """ Product Template inheritance to add an optional email.template to a product.template. When validating an invoice, an email will be send to the customer based on this template. The customer will receive an email for each product linked to an email template. """ _inherit = "product.template" - _columns = { - 'email_template_id': fields.many2one( - 'mail.template', 'Product Email Template', - help='When validating an invoice, an email will be sent to the customer ' - 'based on this template. The customer will receive an email for each ' - 'product linked to an email template.'), - } + email_template_id = fields.Many2one('mail.template', string='Product Email Template', + help='When validating an invoice, an email will be sent to the customer ' + 'based on this template. The customer will receive an email for each ' + 'product linked to an email template.') diff --git a/addons/product_email_template/views/mail_template_views.xml b/addons/product_email_template/views/mail_template_views.xml index 3c45ff8aafe..60aa1a2d3b7 100644 --- a/addons/product_email_template/views/mail_template_views.xml +++ b/addons/product_email_template/views/mail_template_views.xml @@ -1,8 +1,7 @@ - - - - email.template.form.simplified + + + mail.template.form.simplified mail.template 100 @@ -19,5 +18,4 @@ - - + diff --git a/addons/product_email_template/views/product_views.xml b/addons/product_email_template/views/product_views.xml index 5d7f17ab6ff..2d01945d582 100644 --- a/addons/product_email_template/views/product_views.xml +++ b/addons/product_email_template/views/product_views.xml @@ -1,8 +1,7 @@ - - + - product.template.form.inherit + product.template.form.inherit.email.template product.template @@ -23,5 +22,4 @@ - - +