diff --git a/addons/product_email_template/__openerp__.py b/addons/product_email_template/__openerp__.py index 676dcd9ce32..a74b53c4384 100644 --- a/addons/product_email_template/__openerp__.py +++ b/addons/product_email_template/__openerp__.py @@ -15,9 +15,7 @@ For instance when invoicing a training, the training agenda and materials will a 'data/product_demo.xml', ], 'data': [ - 'views/product_view.xml', - 'views/email_template_view.xml', - ], - 'installable': True, - 'auto_install': False, + 'views/product_views.xml', + 'views/mail_template_views.xml', + ] } diff --git a/addons/product_email_template/data/product_demo.xml b/addons/product_email_template/data/product_demo.xml index 565141b3ffd..4e1a833a48c 100644 --- a/addons/product_email_template/data/product_demo.xml +++ b/addons/product_email_template/data/product_demo.xml @@ -1,6 +1,5 @@ - - + Online Training Online Training @@ -8,13 +7,12 @@ - Online Training + Certification + Online Training
These courses feature the same high quality course content found in our traditional classroom trainings, supplemented with modular sessions and cloud-based labs. Many of our online learning courses also include dozens of recorded webinars and live - sessions by our senior instructors. At the end of the training, you can pass the Odoo Certification exam in one of the 5000+ - Pearson VUE test centers worldwide. + sessions by our senior instructors.
Your advantages @@ -23,7 +21,6 @@
  • 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)

  • @@ -66,57 +63,27 @@ Each day of the week is dedicated to specific applications in Odoo as per the following planning: -
    - - - - - - - - - - - - - - - - -
    EnglishEnglishSpanish
    EuropeUSA & CanadaUSA & Latin America
    RegisterRegisterRegister
    -

    Content of the Training @@ -642,5 +609,4 @@ - - + \ No newline at end of file diff --git a/addons/product_email_template/models/__init__.py b/addons/product_email_template/models/__init__.py index 2edb825574d..5067404a32c 100644 --- a/addons/product_email_template/models/__init__.py +++ b/addons/product_email_template/models/__init__.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- import product -import invoice +import account_invoice \ No newline at end of file diff --git a/addons/product_email_template/models/account_invoice.py b/addons/product_email_template/models/account_invoice.py new file mode 100644 index 00000000000..82c0dfbbea0 --- /dev/null +++ b/addons/product_email_template/models/account_invoice.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +from odoo import api, models + + +class AccountInvoice(models.Model): + _inherit = 'account.invoice' + + def invoice_validate_send_email(self): + for invoice in self.filtered(lambda x: x.type == 'out_invoice'): + # send template only on customer invoice + # subscribe the partner to the invoice + if invoice.partner_id not in invoice.message_partner_ids: + 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 + + @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/invoice.py b/addons/product_email_template/models/invoice.py deleted file mode 100644 index c93b3901fc0..00000000000 --- a/addons/product_email_template/models/invoice.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- - -from openerp.osv import osv - - -class account_invoice(osv.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): - # 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) - 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) - 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/email_template_view.xml b/addons/product_email_template/views/mail_template_views.xml similarity index 81% rename from addons/product_email_template/views/email_template_view.xml rename to addons/product_email_template/views/mail_template_views.xml index 3c45ff8aafe..60aa1a2d3b7 100644 --- a/addons/product_email_template/views/email_template_view.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_view.xml b/addons/product_email_template/views/product_views.xml similarity index 91% rename from addons/product_email_template/views/product_view.xml rename to addons/product_email_template/views/product_views.xml index 5d7f17ab6ff..2d01945d582 100644 --- a/addons/product_email_template/views/product_view.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 @@ - - +