Merge pull request #2725 from expsa/Esraa_odex25-base
add new module ss_whatsapp_connector
|
|
@ -0,0 +1,2 @@
|
|||
from . import models
|
||||
from . import wizard
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
'name': 'Whatsapp Odoo Connector',
|
||||
'version': '14.0.0.1',
|
||||
'summary': 'Whatsapp Odoo Connector',
|
||||
'author': 'Saaragh Technologies Pte Ltd',
|
||||
'company': 'Saaragh Technologies Pte Ltd',
|
||||
'maintainer': 'Saaragh Technologies Pte Ltd',
|
||||
'images': ['static/description/Banner.png'],
|
||||
'sequence': 4,
|
||||
'license': 'OPL-1',
|
||||
'description': """Whatsapp Odoo Connector""",
|
||||
'category': 'Connector',
|
||||
'depends': [
|
||||
'base', 'contacts', 'sale', 'crm', 'stock', 'sale_management', 'account', 'purchase'
|
||||
],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'models/whatsapp_template.xml',
|
||||
'views/whatsapp_button_views.xml',
|
||||
'wizard/whatsapp_wizard.xml',
|
||||
],
|
||||
'demo': [],
|
||||
'qweb': [],
|
||||
'installable': True,
|
||||
'application': False,
|
||||
'auto_install': False,
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
from . import whatsapp_popup
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
from odoo import _, models
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
def contacts_whatsapp(self):
|
||||
return {'type': 'ir.actions.act_window',
|
||||
'name': _('Send Whatsapp Message'),
|
||||
'res_model': 'whatsapp.message.wizard',
|
||||
'target': 'new',
|
||||
'view_mode': 'form',
|
||||
'view_type': 'form',
|
||||
'context': {'default_user_id': self.id},
|
||||
}
|
||||
|
||||
class WhatsappCrm(models.Model):
|
||||
_inherit = 'crm.lead'
|
||||
|
||||
def crm_whatsapp(self):
|
||||
return {'type': 'ir.actions.act_window',
|
||||
'name': _('Send Whatsapp Message'),
|
||||
'res_model': 'whatsapp.message.wizard',
|
||||
'target': 'new',
|
||||
'view_mode': 'form',
|
||||
'view_type': 'form',
|
||||
'context': {'default_user_id': self.partner_id.id},
|
||||
}
|
||||
|
||||
class WhatsappInvoice(models.Model):
|
||||
_inherit = 'account.move'
|
||||
|
||||
def invoice_whatsapp(self):
|
||||
return {'type': 'ir.actions.act_window',
|
||||
'name': _('Send Whatsapp Message'),
|
||||
'res_model': 'whatsapp.message.wizard',
|
||||
'target': 'new',
|
||||
'view_mode': 'form',
|
||||
'view_type': 'form',
|
||||
'context': {'default_template_id': self.env.ref('ss_whatsapp_connector.whatsapp_invoice_template').id},
|
||||
}
|
||||
|
||||
class WhatsappPurchase(models.Model):
|
||||
_inherit = 'purchase.order'
|
||||
|
||||
def purchase_whatsapp(self):
|
||||
return {'type': 'ir.actions.act_window',
|
||||
'name': _('Send Whatsapp Message'),
|
||||
'res_model': 'whatsapp.message.wizard',
|
||||
'target': 'new',
|
||||
'view_mode': 'form',
|
||||
'view_type': 'form',
|
||||
'context': {'default_template_id': self.env.ref('ss_whatsapp_connector.whatsapp_purchase_template').id},
|
||||
}
|
||||
|
||||
class WhatsappSale(models.Model):
|
||||
_inherit = 'sale.order'
|
||||
|
||||
def sale_whatsapp(self):
|
||||
return {'type': 'ir.actions.act_window',
|
||||
'name': _('Send Whatsapp Message'),
|
||||
'res_model': 'whatsapp.message.wizard',
|
||||
'target': 'new',
|
||||
'view_mode': 'form',
|
||||
'view_type': 'form',
|
||||
'context': {'default_template_id': self.env.ref('ss_whatsapp_connector.whatsapp_sales_template').id},
|
||||
}
|
||||
|
||||
class WhatsappPurchase(models.Model):
|
||||
_inherit = 'stock.picking'
|
||||
|
||||
def stock_whatsapp(self):
|
||||
return {'type': 'ir.actions.act_window',
|
||||
'name': _('Send Whatsapp Message'),
|
||||
'res_model': 'whatsapp.message.wizard',
|
||||
'target': 'new',
|
||||
'view_mode': 'form',
|
||||
'view_type': 'form',
|
||||
'context': {'default_user_id': self.partner_id.id},
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
|
||||
<record id="whatsapp_sales_template" model="mail.template">
|
||||
<field name="name">Sales: Confirm Order</field>
|
||||
<field name="subject">Sales Confirm</field>
|
||||
<field name="model_id" ref="sale.model_sale_order"/>
|
||||
<field name="body_html"><![CDATA[<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px;">
|
||||
<p> Hello ${object.partner_id.name or ''},</p>
|
||||
Your order Number ${object.name} with amount ${format_amount(object.amount_total, object.currency_id)} is Confirmed.
|
||||
<br>
|
||||
Your order date and time is "${object.date_order}"
|
||||
<br>
|
||||
If you have any questions, please do not hesitate to contact us.
|
||||
<br>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="whatsapp_purchase_template" model="mail.template">
|
||||
<field name="name">Purchase: Confirm Order</field>
|
||||
<field name="subject">Purchase Order</field>
|
||||
<field name="model_id" ref="purchase.model_purchase_order"/>
|
||||
<field name="body_html"><![CDATA[<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px;">
|
||||
<p style="margin: 0px; padding: 0px; font-size: 13px;">
|
||||
Dear ${object.partner_id.name}
|
||||
% if object.partner_id.parent_id:
|
||||
(${object.partner_id.parent_id.name})
|
||||
% endif
|
||||
<br/><br/>
|
||||
This is about the purchase order <strong>${object.name}</strong>
|
||||
% if object.partner_ref:
|
||||
with reference: ${object.partner_ref}
|
||||
% endif
|
||||
with amount ${format_amount(object.amount_total, object.currency_id)}
|
||||
from ${object.company_id.name}.
|
||||
<br/>
|
||||
The order date and time is "${object.date_approve}"
|
||||
<br/>
|
||||
If you have any questions, please do not hesitate to contact us.
|
||||
<br/><br/>
|
||||
Best regards,
|
||||
</p>
|
||||
]]>
|
||||
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="whatsapp_invoice_template" model="mail.template">
|
||||
<field name="name">Invoice: Send by WhatsApp</field>
|
||||
<field name="model_id" ref="account.model_account_move"/>
|
||||
<field name="subject">Purchase Order</field>
|
||||
<field name="body_html"><![CDATA[<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px;">
|
||||
<p style="margin: 0px; padding: 0px; font-size: 13px;">
|
||||
Dear
|
||||
% if object.partner_id.parent_id:
|
||||
${object.partner_id.name} (${object.partner_id.parent_id.name}),
|
||||
% else:
|
||||
${object.partner_id.name},
|
||||
% endif
|
||||
<br /><br />
|
||||
Here is your
|
||||
% if object.name:
|
||||
invoice ${object.name}
|
||||
% else:
|
||||
invoice
|
||||
%endif
|
||||
% if object.invoice_origin:
|
||||
(with reference: ${object.invoice_origin})
|
||||
% endif
|
||||
with amount ${format_amount(object.amount_total, object.currency_id)}
|
||||
from ${object.company_id.name}.
|
||||
% if object.payment_state == 'paid':
|
||||
This invoice is already paid.
|
||||
% else:
|
||||
Please remit payment at your earliest convenience.
|
||||
% endif
|
||||
<br />
|
||||
The invoice date and time is "${object.invoice_date}"
|
||||
<br />
|
||||
Do not hesitate to contact us if you have any questions.
|
||||
% if object.invoice_user_id.signature:
|
||||
<br />
|
||||
${object.invoice_user_id.signature | safe}
|
||||
% endif
|
||||
</p>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_group_user,Access User,model_whatsapp_message_wizard,base.group_user,1,1,1,1
|
||||
|
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
|
@ -0,0 +1,196 @@
|
|||
<section class="oe_container oe_dark">
|
||||
<div>
|
||||
<h3 class="oe_slogan" style="background: #875A7B;padding: 10px 0px;text-transform: uppercase;color: black">
|
||||
<b>Whatsapp Odoo Connector</b>
|
||||
</h3>
|
||||
</div>
|
||||
</section>
|
||||
<section class="oe_container">
|
||||
<div class="col-md-12">
|
||||
<h2 class="oe_slogan" style="font-size: 25px;color:#000000"><b>You can now send Messages to customers and partners through WhatsApp with one click
|
||||
using Saaragh Technologie's WhatsApp Odoo Connector App. It is available in these
|
||||
modules: Contacts, CRM, Sales, Purchase, Invoice, and Inventory.
|
||||
</b></h2>
|
||||
</div>
|
||||
</section>
|
||||
<section class="oe_container">
|
||||
<div>
|
||||
<h3 class="oe_slogan" style="background: #6e6e6e;padding: 10px 0px;text-transform: uppercase;color: black">
|
||||
<b>Available In</b>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="row" style=" display: flex;justify-content: center;">
|
||||
<div class="col-md-2 text-center">
|
||||
<img class="img img-responsive" style="max-width:100%;" src="modules_icon/contacts.png"/>
|
||||
<h4 style="margin-top: 5px;font-size: 12px"><b>Contacts</b></h4>
|
||||
</div>
|
||||
<div class="col-md-2 text-center">
|
||||
<img class="img img-responsive" style="max-width:100%;" src="modules_icon/crm.png"/>
|
||||
<h4 style="margin-top: 5px;font-size: 12px"><b>CRM</b></h4>
|
||||
</div>
|
||||
<div class="col-md-2 text-center">
|
||||
<img class="img img-responsive" style="max-width:100%;" src="modules_icon/sale.png"/>
|
||||
<h4 style="margin-top: 5px;font-size: 12px"><b>Sales</b></h4>
|
||||
</div>
|
||||
<div class="col-md-2 text-center">
|
||||
<img class="img img-responsive" style="max-width:100%;" src="modules_icon/account.png"/>
|
||||
<h4 style="margin-top: 5px;font-size: 12px"><b>Invoice</b></h4>
|
||||
</div>
|
||||
<div class="col-md-2 text-center">
|
||||
<img class="img img-responsive" style="max-width:100%;" src="modules_icon/purchase.png"/>
|
||||
<h4 style="margin-top: 5px;font-size: 12px"><b>Purchase</b></h4>
|
||||
</div>
|
||||
<div class="col-md-2 text-center">
|
||||
<img class="img img-responsive" style="max-width:100%;" src="modules_icon/stock.png"/>
|
||||
<h4 style="margin-top: 5px;font-size: 12px"><b>Stock/Inventory</b></h4>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="oe_container apps">
|
||||
<div>
|
||||
<div>
|
||||
<h3 class="oe_slogan" style="background: #6e6e6e;padding: 10px 0px;text-transform: uppercase;color: black">
|
||||
<b>Features</b>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col" style="margin: 10px;">
|
||||
<div class="row" style="border-style: dotted">
|
||||
<div class="col-md-9">
|
||||
<h4><b>Contacts</b></h4>
|
||||
<span class="oe_slogan">- Use WhatsApp for communication with your customers and Vendors.<br/>
|
||||
- Chat directly with the contacts in the contacts module on Odoo through WhatsApp.</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col" style="margin: 10px;">
|
||||
<div class="row" style="border-style: dotted">
|
||||
<div class="col-md-9">
|
||||
<h4><b>CRM</b></h4>
|
||||
<span class="oe_slogan">- Using WhatsApp for Marketing & Promotion.<br/>
|
||||
- WhatsApp can be a very solid marketing tool. It is a good platform for direct communication. You can use WhatsApp to send details of your products and more. </span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col" style="margin: 10px;">
|
||||
<div class="row" style="border-style: dotted">
|
||||
<div class="col-md-9">
|
||||
<h4><b>Sales</b></h4>
|
||||
<span class="oe_slogan">- Creative usage of WhatsApp for business.<br/>
|
||||
- Grow your business profitably and creatively. Use WhatsApp as an extra sales channel.<br/>
|
||||
- Easy to send Quotations, Sales/Purchase Orders, etc. related details to corresponding partners.</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col" style="margin: 10px;">
|
||||
<div class="row" style="border-style: dotted">
|
||||
<div class="col-md-9">
|
||||
<h4><b>Invoice </b></h4>
|
||||
<span class="oe_slogan">- Using WhatsApp for payment reminder<br/>
|
||||
- Our Whatsapp Connector App for Odoo will help you send bills more conveniently, faster, and will also speed up your collection process.</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col" style="margin: 10px;">
|
||||
<div class="row" style="border-style: dotted">
|
||||
<div class="col-md-9">
|
||||
<h4><b>Purchase</b></h4>
|
||||
<span class="oe_slogan">- Quick payment of accounts payable, payment reminders.<br/>
|
||||
- Your purchase team will have an additional communication channel to streamline your accounts payable process.</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col" style="margin: 10px;">
|
||||
<div class="row" style="border-style: dotted">
|
||||
<div class="col-md-9">
|
||||
<h4><b> Stock/Inventory </b></h4>
|
||||
<span class="oe_slogan">- Use WhatsApp to stay updated about the current status of stock/inventory in your warehouse.<br/>
|
||||
- Speed up your purchase and decision making process by using Saaragh Technologie's WhatsApp Connector App for Odoo. </span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="oe_container exp">
|
||||
<div>
|
||||
<h3 class="oe_slogan" style="background: #6e6e6e;padding: 10px 0px;text-transform: uppercase;color: black">
|
||||
<b>Screenshots</b>
|
||||
</h3>
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<p class="oe_slogan" style="color: black;font-size: 22px;font-weight:bolder;"><u>Contacts</u></p>
|
||||
<br/>
|
||||
<img class="img-border img-responsive thumbnail mb16" style="border: 1px solid black;" width="1100px" src="screenshots/contact1.jpg">
|
||||
<img class="img-border img-responsive thumbnail mb16" style="border: 1px solid black;" width="1100px" src="screenshots/contact2.jpg">
|
||||
<img class="img-border img-responsive thumbnail mb16" style="border: 1px solid black;" width="1100px" src="screenshots/contact3.jpg">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="oe_container exp">
|
||||
<div>
|
||||
<div>
|
||||
<p class="oe_slogan" style="color: black;font-size: 22px;font-weight:bolder;"><u>CRM</u></p>
|
||||
<br/>
|
||||
<img class="img-border img-responsive thumbnail mb16" style="border: 1px solid black;" width="1100px" src="screenshots/crm1.jpg">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="oe_container exp">
|
||||
<div>
|
||||
<div>
|
||||
<p class="oe_slogan" style="color: black;font-size: 22px;font-weight:bolder;"><u>Sales</u></p>
|
||||
<br/>
|
||||
<img class="img-border img-responsive thumbnail mb16" style="border: 1px solid black;" width="1100px" src="screenshots/sale1.jpg">
|
||||
<img class="img-border img-responsive thumbnail mb16" style="border: 1px solid black;" width="1100px" src="screenshots/sale2.jpg">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="oe_container exp">
|
||||
<div>
|
||||
<div>
|
||||
<p class="oe_slogan" style="color: black;font-size: 22px;font-weight:bolder;"><u>Invoice</u></p>
|
||||
<br/>
|
||||
<img class="img-border img-responsive thumbnail mb16" style="border: 1px solid black;" width="1100px" src="screenshots/invoice1.jpg">
|
||||
<img class="img-border img-responsive thumbnail mb16" style="border: 1px solid black;" width="1100px" src="screenshots/invoice2.jpg">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="oe_container exp">
|
||||
<div>
|
||||
<div>
|
||||
<p class="oe_slogan" style="color: black;font-size: 22px;font-weight:bolder;"><u>Purchase</u></p>
|
||||
<br/>
|
||||
<img class="img-border img-responsive thumbnail mb16" style="border: 1px solid black;" width="1100px" src="screenshots/purchase1.jpg">
|
||||
<img class="img-border img-responsive thumbnail mb16" style="border: 1px solid black;" width="1100px" src="screenshots/purchase2.jpg">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="oe_container exp">
|
||||
<div>
|
||||
<div>
|
||||
<p class="oe_slogan" style="color: black;font-size: 22px;font-weight:bolder;"><u>Inventory</u></p>
|
||||
<br/>
|
||||
<img class="img-border img-responsive thumbnail mb16" style="border: 1px solid black;" width="1100px" src="screenshots/stock1.jpg">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<hr style="width: 100%;height: 2px;background: #000000">
|
||||
<section class="oe_container oe_dark">
|
||||
<div class="oe_row">
|
||||
<div class="oe_slogan text-center">
|
||||
<div>
|
||||
<h3 style="color:#000000;font-size: 25px;">If you have any queries or doubt feel free to contact us</h3><br>
|
||||
<h3 style="color:#000000;font-size: 20px;">Email: <a href="mailto:support@saaragh.com" target="_top">support@saaragh.com</a> <br></h3>
|
||||
<h3 style="color:#000000;font-size: 20px;">Website: <a href="https://saaragh.com" target="_blank">saaragh.com</a><br></h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<hr style="width: 100%;height: 2px;background: #000000">
|
||||
|
||||
|
After Width: | Height: | Size: 8.9 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 9.9 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 7.9 KiB |
|
After Width: | Height: | Size: 486 KiB |
|
After Width: | Height: | Size: 415 KiB |
|
After Width: | Height: | Size: 672 KiB |
|
After Width: | Height: | Size: 355 KiB |
|
After Width: | Height: | Size: 533 KiB |
|
After Width: | Height: | Size: 479 KiB |
|
After Width: | Height: | Size: 452 KiB |
|
After Width: | Height: | Size: 418 KiB |
|
After Width: | Height: | Size: 518 KiB |
|
After Width: | Height: | Size: 406 KiB |
|
After Width: | Height: | Size: 381 KiB |
|
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="whatsapp_res_view_form" model="ir.ui.view">
|
||||
<field name="name">whatsapp.view.form.inherit.res</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='image_1920']" position="before">
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button name="contacts_whatsapp" string="Whatsapp Message" type="object" class="oe_stat_button" icon="fa-whatsapp" style="background-color:#b7ff8a"/>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<record id="whatsapp_crm_view_form" model="ir.ui.view">
|
||||
<field name="name">whatsapp.view.form.inherit.crm</field>
|
||||
<field name="model">crm.lead</field>
|
||||
<field name="inherit_id" ref="crm.crm_lead_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<header>
|
||||
<button name="crm_whatsapp" string="Send Whatsapp" type="object" class="btn-secondary" icon="fa-whatsapp" style="background-color:#b7ff8a"/>
|
||||
</header>
|
||||
</field>
|
||||
</record>
|
||||
<record id="whatsapp_account_view_form" model="ir.ui.view">
|
||||
<field name="name">whatsapp.view.form.inherit.account</field>
|
||||
<field name="model">account.move</field>
|
||||
<field name="inherit_id" ref="account.view_move_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<header>
|
||||
<button name="invoice_whatsapp" string="Send Whatsapp" type="object" class="btn-secondary" icon="fa-whatsapp" context="{'default_user_id' : partner_id}" states="posted" style="background-color:#b7ff8a"/>
|
||||
</header>
|
||||
</field>
|
||||
</record>
|
||||
<record id="whatsapp_purchase_view_form" model="ir.ui.view">
|
||||
<field name="name">whatsapp.view.form.inherit.purchase</field>
|
||||
<field name="model">purchase.order</field>
|
||||
<field name="inherit_id" ref="purchase.purchase_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<header>
|
||||
<button name="purchase_whatsapp" string="Send Whatsapp" type="object" class="btn-secondary" icon="fa-whatsapp" context="{'default_user_id' : partner_id}" style="background-color:#b7ff8a"/>
|
||||
</header>
|
||||
</field>
|
||||
</record>
|
||||
<record id="whatsapp_sale_view_form" model="ir.ui.view">
|
||||
<field name="name">whatsapp.view.form.inherit.sale</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<header>
|
||||
<button name="sale_whatsapp" string="Send Whatsapp" type="object" class="btn-secondary" icon="fa-whatsapp" context="{'default_user_id' : partner_id}" style="background-color:#b7ff8a"/>
|
||||
</header>
|
||||
</field>
|
||||
</record>
|
||||
<record id="whatsapp_stock_view_form" model="ir.ui.view">
|
||||
<field name="name">whatsapp.view.form.inherit.stock</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<header>
|
||||
<button name="stock_whatsapp" string="Send Whatsapp" type="object" class="btn-secondary" icon="fa-whatsapp" style="background-color:#b7ff8a"/>
|
||||
</header>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1 @@
|
|||
from . import whatsapp_wizard
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
from odoo import api, fields, models
|
||||
import html2text
|
||||
|
||||
|
||||
class WhatsappSendMessage(models.TransientModel):
|
||||
_name = 'whatsapp.message.wizard'
|
||||
|
||||
user_id = fields.Many2one('res.partner', string="Recipient")
|
||||
mobile_number = fields.Char(related='user_id.mobile', required=True)
|
||||
message = fields.Text(string="Message")
|
||||
model = fields.Char('mail.template.model_id')
|
||||
template_id = fields.Many2one('mail.template', 'Use template', index=True,)
|
||||
|
||||
@api.onchange('template_id')
|
||||
def onchange_template_id_wrapper(self):
|
||||
self.ensure_one()
|
||||
res_id = self._context.get('active_id') or 1
|
||||
values = self.onchange_template_id(self.template_id.id, self.model, res_id)['value']
|
||||
for fname, value in values.items():
|
||||
setattr(self, fname, value)
|
||||
|
||||
def onchange_template_id(self, template_id, model, res_id):
|
||||
if template_id:
|
||||
values = self.generate_email_for_composer(template_id, [res_id])[res_id]
|
||||
else:
|
||||
default_values = self.with_context(default_model=model, default_res_id=res_id).default_get(
|
||||
['model', 'res_id', 'partner_ids', 'message'])
|
||||
values = dict((key, default_values[key]) for key in
|
||||
['body', 'partner_ids']
|
||||
if key in default_values)
|
||||
values = self._convert_to_write(values)
|
||||
return {'value': values}
|
||||
|
||||
def generate_email_for_composer(self, template_id, res_ids, fields=None):
|
||||
multi_mode = True
|
||||
if isinstance(res_ids, int):
|
||||
multi_mode = False
|
||||
res_ids = [res_ids]
|
||||
if fields is None:
|
||||
fields = ['body_html']
|
||||
returned_fields = fields + ['partner_ids']
|
||||
values = dict.fromkeys(res_ids, False)
|
||||
template_values = self.env['mail.template'].with_context(tpl_partners_only=True).browse(
|
||||
template_id).generate_email(res_ids, fields=fields)
|
||||
for res_id in res_ids:
|
||||
res_id_values = dict((field, template_values[res_id][field]) for field in returned_fields if
|
||||
template_values[res_id].get(field))
|
||||
res_id_values['message'] = html2text.html2text(res_id_values.pop('body_html', ''))
|
||||
values[res_id] = res_id_values
|
||||
|
||||
return multi_mode and values or values[res_ids[0]]
|
||||
|
||||
def send_message(self):
|
||||
if self.message and self.mobile_number:
|
||||
message_string = ''
|
||||
message = self.message.split(' ')
|
||||
for msg in message:
|
||||
message_string = message_string + msg + '%20'
|
||||
message_string = message_string[:(len(message_string) - 3)]
|
||||
number = self.user_id.mobile
|
||||
link = "https://web.whatsapp.com/send?phone=" + number
|
||||
send_msg = {
|
||||
'type': 'ir.actions.act_url',
|
||||
'url': link + "&text=" + message_string,
|
||||
'target': 'new',
|
||||
'res_id': self.id,
|
||||
}
|
||||
|
||||
return send_msg
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="whatsapp_message_wizard_form" model="ir.ui.view">
|
||||
<field name="name">whatsapp.message.wizard.form</field>
|
||||
<field name="model">whatsapp.message.wizard</field>
|
||||
<field name="priority" eval="8"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Send Whatsapp Message">
|
||||
<group>
|
||||
<group>
|
||||
<field name="user_id"/>
|
||||
<field name="message"/>
|
||||
</group>
|
||||
<field name="model" invisible="1"/>
|
||||
<group>
|
||||
<label for="mobile_number" string="Whatsapp Number" style="margin-left:25px !important;width:120px !important"/>
|
||||
<field name="mobile_number" nolabel="1"/>
|
||||
<field name="template_id" options="{'no_create': True, 'no_edit': True}" invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="send_message" string="Send" type="object" style="background-color:#7C7BAD;color:#FFFFFF"/>
|
||||
<button name="cancel" string="Cancel" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||