← Back to team overview

openerp-community team mailing list archive

[Merge] lp:~openerp-community/sale-wkfl/6.1-mail_quotation into lp:sale-wkfl

 

Maxime Chambreuil (http://www.savoirfairelinux.com) has proposed merging lp:~openerp-community/sale-wkfl/6.1-mail_quotation into lp:sale-wkfl.

Commit message:
[MRG] Allow sending quotation by email.

Requested reviews:
  Sale Core Editors (sale-core-editors)

For more details, see:
https://code.launchpad.net/~openerp-community/sale-wkfl/6.1-mail_quotation/+merge/135731
-- 
https://code.launchpad.net/~openerp-community/sale-wkfl/6.1-mail_quotation/+merge/135731
Your team OpenERP Community is subscribed to branch lp:~openerp-community/sale-wkfl/6.1-mail_quotation.
=== added directory 'mail_quotation'
=== added file 'mail_quotation/__init__.py'
--- mail_quotation/__init__.py	1970-01-01 00:00:00 +0000
+++ mail_quotation/__init__.py	2012-11-22 16:14:23 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#    
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2012 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
+#
+##############################################################################
+
+import sale

=== added file 'mail_quotation/__openerp__.py'
--- mail_quotation/__openerp__.py	1970-01-01 00:00:00 +0000
+++ mail_quotation/__openerp__.py	2012-11-22 16:14:23 +0000
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#    
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2012 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
+#
+##############################################################################
+
+{
+    "name" : "Mail quotation",
+    "version" : "0.1",
+    "author" : "Savoir-faire Linux",
+    "website" : "http://www.savoirfairelinux.com";,
+    "license" : "AGPL-3",
+    "category" : "Mail",
+    "description" : """
+This module adds a server action, an email template and a button on the sales order form to 
+send quotation by email.
+    """,
+    "images" : [],
+    "depends" : ["sale"],
+    "demo" : [],
+    "test" : [],
+    "data" : [
+        "quotation_action_data.xml",
+        "sale_order_view.xml",
+    ],
+    "installable": True,
+    "complexity": "easy",
+}

=== added file 'mail_quotation/quotation_action_data.xml'
--- mail_quotation/quotation_action_data.xml	1970-01-01 00:00:00 +0000
+++ mail_quotation/quotation_action_data.xml	2012-11-22 16:14:23 +0000
@@ -0,0 +1,142 @@
+<?xml version="1.0" ?>
+<openerp>
+    <data>
+        <!-- EDI Export + Send email Action  -->
+        <record id="ir_actions_server_edi_quotation" model="ir.actions.server">
+            <field name="code">if not object.partner_id.opt_out: object.edi_export_and_email(template_ext_id='mail_quotation.email_template_edi_quotation', context=context)</field>
+            <field name="state">code</field>
+            <field name="type">ir.actions.server</field>
+            <field name="model_id" ref="sale.model_sale_order"/>
+            <field name="condition">True</field>
+            <field name="name">Email quotations</field>
+        </record>
+
+    </data>
+
+
+    <!-- Mail template and workflow bindings are done in a NOUPDATE block
+         so users can freely customize/delete them -->
+    <data noupdate="1">
+
+        <!--Email template -->
+        <record id="email_template_edi_quotation" model="email.template">
+            <field name="name">Quotation Mail</field>
+            <field name="email_from">${object.user_id.user_email or ''}</field>
+            <field name="subject">${object.company_id.name} Quotation (Ref ${object.name or 'n/a' })</field>
+            <field name="email_to">${object.partner_invoice_id.email}</field>
+            <field name="model_id" ref="sale.model_sale_order"/>
+            <field name="report_template" ref="sale.report_sale_order"/>
+            <field name="report_name">${object.name or 'Quotation'}</field>
+            <field name="auto_delete" eval="True"/>
+            <field name="lang">${object.partner_id.lang}</field>
+            <field name="body_html"><![CDATA[
+<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">
+
+    <p>Hello${object.partner_order_id.name and ' ' or ''}${object.partner_order_id.name or ''},</p>
+    
+    <p>Here is your quotation for ${object.partner_id.name}: </p>
+    
+    <p style="border-left: 1px solid #8e0000; margin-left: 30px;">
+       &nbsp;&nbsp;<strong>REFERENCES</strong><br />
+       &nbsp;&nbsp;Quotation number: <strong>${object.name}</strong><br />
+       &nbsp;&nbsp;Quotation total: <strong>${object.amount_total} ${object.pricelist_id.currency_id.name}</strong><br />
+       &nbsp;&nbsp;Quotation date: ${object.date_order}<br />
+       % if object.origin:
+       &nbsp;&nbsp;Quotation reference: ${object.origin}<br />
+       % endif
+       % if object.client_order_ref:
+       &nbsp;&nbsp;Your reference: ${object.client_order_ref}<br />
+       % endif
+       &nbsp;&nbsp;Your contact: <a href="mailto:${object.user_id.user_email or ''}?subject=Order%20${object.name}">${object.user_id.name}</a>
+    </p>
+
+    <p>
+    You can view the quotation document and download it using the following link:
+    </p>
+            <a style="display:block; width: 150px; height:20px; margin-left: 120px; color: #DDD; font-family: 'Lucida Grande', Helvetica, Arial, sans-serif; font-size: 13px; font-weight: bold; text-align: center; text-decoration: none !important; line-height: 1; padding: 5px 0px 0px 0px; background-color: #8E0000; border-radius: 5px 5px; background-repeat: repeat no-repeat;"
+               href="${ctx.get('edi_web_url_view') or ''}">View Quotation</a>
+
+    <br/>
+    <p>If you have any question, do not hesitate to contact us.</p>
+    <p>Thank you for choosing ${object.company_id.name or 'us'}!</p>
+    <br/>
+    <br/>
+    <div style="width: 375px; margin: 0px; padding: 0px; background-color: #8E0000; border-top-left-radius: 5px 5px; border-top-right-radius: 5px 5px; background-repeat: repeat no-repeat;">
+        <h3 style="margin: 0px; padding: 2px 14px; font-size: 12px; color: #DDD;">
+            <strong style="text-transform:uppercase;">${object.company_id.name}</strong></h3>
+    </div>
+    <div style="width: 347px; margin: 0px; padding: 5px 14px; line-height: 16px; background-color: #F2F2F2;">
+        <span style="color: #222; margin-bottom: 5px; display: block; ">
+        % if object.company_id.street:
+            ${object.company_id.street}<br/>
+        % endif
+        % if object.company_id.street2:
+            ${object.company_id.street2}<br/>
+        % endif
+        % if object.company_id.city or object.company_id.zip:
+            ${object.company_id.zip} ${object.company_id.city}<br/>
+        % endif
+        % if object.company_id.country_id:
+            ${object.company_id.state_id and ('%s, ' % object.company_id.state_id.name) or ''} ${object.company_id.country_id.name or ''}<br/>
+        % endif
+        </span>
+        % if object.company_id.phone:
+            <div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
+                Phone:&nbsp; ${object.company_id.phone}
+            </div>
+        % endif
+        % if object.company_id.website:
+            <div>
+                Web :&nbsp;<a href="${object.company_id.website}">${object.company_id.website}</a>
+            </div>
+        %endif
+        <p></p>
+    </div>
+</div>
+            ]]></field>
+            <field name="body_text"><![CDATA[
+Hello${object.partner_order_id.name and ' ' or ''}${object.partner_order_id.name or ''},
+
+Here is your quotation for ${object.partner_id.name}:
+       | Quotation number: *${object.name}*
+       | Quotation total: *${object.amount_total} ${object.pricelist_id.currency_id.name}*
+       | Quotation date: ${object.date_order}
+       % if object.origin:
+       | Quotation reference: ${object.origin}
+       % endif
+       % if object.client_order_ref:
+       | Your reference: ${object.client_order_ref}<br />
+       % endif
+       | Your contact: ${object.user_id.name} ${object.user_id.user_email and '<%s>'%(object.user_id.user_email) or ''}
+
+You can view the quotation and download it using the following link:
+    ${ctx.get('edi_web_url_view') or 'n/a'}
+
+If you have any question, do not hesitate to contact us.
+
+Thank you for choosing ${object.company_id.name}!
+--
+${object.user_id.name} ${object.user_id.user_email and '<%s>'%(object.user_id.user_email) or ''}
+${object.company_id.name}
+% if object.company_id.street:
+${object.company_id.street or ''}
+% endif
+% if object.company_id.street2:
+${object.company_id.street2}
+% endif
+% if object.company_id.city or object.company_id.zip:
+${object.company_id.zip or ''} ${object.company_id.city or ''}
+% endif
+% if object.company_id.country_id:
+${object.company_id.state_id and ('%s, ' % object.company_id.state_id.name) or ''} ${object.company_id.country_id.name or ''}
+% endif
+% if object.company_id.phone:
+Phone: ${object.company_id.phone}
+% endif
+% if object.company_id.website:
+${object.company_id.website or ''}
+% endif
+            ]]></field>
+        </record>
+    </data>
+</openerp>

=== added file 'mail_quotation/sale.py'
--- mail_quotation/sale.py	1970-01-01 00:00:00 +0000
+++ mail_quotation/sale.py	2012-11-22 16:14:23 +0000
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+#    
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2012 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
+#
+###############################################################################
+
+from osv import fields, osv
+
+class sale_order(osv.osv):
+    _name = 'sale.order'
+    _inherit = 'sale.order'
+
+    def edi_export(self, cr, uid, records, edi_struct=None, context=None):
+       return super(sale_order, self).edi_export(cr, uid, records, edi_struct,
+              context)
+
+
+sale_order()

=== added file 'mail_quotation/sale_order_view.xml'
--- mail_quotation/sale_order_view.xml	1970-01-01 00:00:00 +0000
+++ mail_quotation/sale_order_view.xml	2012-11-22 16:14:23 +0000
@@ -0,0 +1,27 @@
+<?xml version="1.0" ?>
+<openerp>
+    <data>
+
+        <record id="view_sale_order" model="ir.ui.view">
+	    <field name="name">sale.order.form.mail_quotation</field>
+	    <field name="model">sale.order</field>
+	    <field name="inherit_id" ref="sale.view_order_form"/>
+	    <field name="type">form</field>
+	    <field name="arch" type="xml">
+	        <data>
+
+                    <xpath expr="//button[@string='Print Quotation']"
+	  	           position="after">
+	                <button name="%(ir_actions_server_edi_quotation)d" 
+		                string="Send Quotation" 
+		                type="action" 
+		                icon="terp-mail-message-new"
+		                states="draft"/>
+	            </xpath>
+
+                </data>
+            </field>
+        </record>
+
+    </data>
+</openerp>


Follow ups