Browse Source

May 20: [FIX] Bug Fixed 'whatsapp_mail_messaging'

pull/320/head
RisvanaCybro 11 months ago
parent
commit
dbe34cb1b6
  1. 10
      enhanced_document_management/doc/RELEASE_NOTES.md
  2. 13
      enhanced_document_management/static/src/css/kanban.css
  3. 5
      whatsapp_mail_messaging/__manifest__.py
  4. 7
      whatsapp_mail_messaging/doc/changelog.md
  5. 3
      whatsapp_mail_messaging/model/__init__.py
  6. 4
      whatsapp_mail_messaging/model/account_move.py
  7. 32
      whatsapp_mail_messaging/model/res_company.py
  8. 33
      whatsapp_mail_messaging/model/res_config_settings.py
  9. 4
      whatsapp_mail_messaging/model/sale_order.py
  10. 9
      whatsapp_mail_messaging/model/selection_messages.py
  11. 2
      whatsapp_mail_messaging/security/ir.model.access.csv
  12. BIN
      whatsapp_mail_messaging/static/description/assets/screenshots/23.png
  13. 6
      whatsapp_mail_messaging/static/description/index.html
  14. 16
      whatsapp_mail_messaging/views/res_company_views.xml
  15. 31
      whatsapp_mail_messaging/views/res_config_settings_views.xml
  16. 55
      whatsapp_mail_messaging/views/selection_messages_views.xml
  17. 16
      whatsapp_mail_messaging/wizard/wh_message_wizard.py
  18. 12
      whatsapp_mail_messaging/wizard/wh_message_wizard.xml

10
enhanced_document_management/doc/RELEASE_NOTES.md

@ -5,3 +5,13 @@
#### ADD
- Initial commit for Document Management
## Module <enhanced_document_management>
#### 19.05.2024
#### Version 16.0.1.0.1
#### BUG FIX
- fixed the issue of contact name overrides the outline and unaligned delete
button in export page.

13
enhanced_document_management/static/src/css/kanban.css

@ -10,19 +10,6 @@
height: 140px;
align-items: center;
}
.o_kanban_record_title{
margin-bottom: 4px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
width: 100%;
}
.fa {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: 15px;
text-rendering: auto;
}
.check_box{
margin-left:90%;
}

5
whatsapp_mail_messaging/__manifest__.py

@ -21,7 +21,7 @@
#############################################################################
{
'name': 'Odoo Whatsapp Connector',
'version': '16.0.0.1.0',
'version': '16.0.1.1.0',
'category': 'Extra Tools',
'summary': """Odoo Whatsapp Connector For Sales, Invoice, and Floating button in Website""",
'description': """Added options for sending Whatsapp messages and Mails in systray bar,sale order, invoices,
@ -34,11 +34,12 @@
'depends': ['sale', 'account', 'website','sale_management'],
'data': [
'security/ir.model.access.csv',
'views/selection_messages_views.xml',
'views/portal_whatsapp_view.xml',
'views/sale_order_inherited.xml',
'views/account_move_inherited.xml',
'views/website_inherited.xml',
'views/res_config_settings_views.xml',
'views/res_company_views.xml',
'wizard/wh_message_wizard.xml',
'wizard/portal_share_inherited.xml',
],

7
whatsapp_mail_messaging/doc/changelog.md

@ -7,6 +7,11 @@
#### 29.11.2023
#### Version 16.0.0.1.0
#### Version 16.0.1.0.1
#### BUGFIX
- Added Default Message functionality where users can save message templates and use these templates for sending Whatsapp Message.
#### 20.05.2024
#### Version 16.0.1.1.0
#### UPDT
- Added new message template feature.

3
whatsapp_mail_messaging/model/__init__.py

@ -22,4 +22,5 @@
from . import website
from . import sale_order
from . import account_move
from . import selection_messages
from . import res_config_settings
from . import res_company

4
whatsapp_mail_messaging/model/account_move.py

@ -32,9 +32,11 @@ class Account(models.Model):
compose_form_id = self.env.ref(
'whatsapp_mail_messaging.whatsapp_message_wizard_form').id
ctx = dict(self.env.context)
message = "Hi" + " " + self.partner_id.name + ',' + '\n' + "Here is your invoice" + ' ' + self.name + ' ' + "amounting" + ' ' + str(
message_template = self.company_id.whatsapp_message
default_message = "Hi" + " " + self.partner_id.name + ',' + '\n' + "Here is your invoice" + ' ' + self.name + ' ' + "amounting" + ' ' + str(
self.amount_total) + self.currency_id.symbol + ' ' + "from " + self.company_id.name + ". Please remit payment at your earliest convenience. " + '\n' + \
"Please use the following communication for your payment" + ' ' + self.name
message = message_template if message_template else default_message
ctx.update({
'default_message': message,
'default_partner_id': self.partner_id.id,

32
whatsapp_mail_messaging/model/res_company.py

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2021-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from odoo import fields, models
class ResCompany(models.Model):
"""
Extends the 'res.company' model to include WhatsApp message template.
"""
_inherit = 'res.company'
whatsapp_message = fields.Text(string="Message Template",
help="whatsapp message template")

33
whatsapp_mail_messaging/model/res_config_settings.py

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2021-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
"""
Extends the 'res.config.settings' model to include additional configuration settings.
"""
_inherit = 'res.config.settings'
whatsapp_message = fields.Text(string="Message Template",
related='company_id.whatsapp_message',
readonly=False)

4
whatsapp_mail_messaging/model/sale_order.py

@ -32,8 +32,10 @@ class Sale(models.Model):
def action_send_whatsapp(self):
compose_form_id = self.env.ref('whatsapp_mail_messaging.whatsapp_message_wizard_form').id
ctx = dict(self.env.context)
message = "Hi" + " " + self.partner_id.name + ',' + '\n' + "Your quotation" + ' ' + self.name + ' ' + "amounting" + ' ' + str(
message_template = self.company_id.whatsapp_message
default_message = "Hi" + " " + self.partner_id.name + ',' + '\n' + "Your quotation" + ' ' + self.name + ' ' + "amounting" + ' ' + str(
self.amount_total) + self.currency_id.symbol + ' ' + "is ready for review.Do not hesitate to contact us if you have any questions."
message = message_template if message_template else default_message
ctx.update({
'default_message': message,
'default_partner_id': self.partner_id.id,

9
whatsapp_mail_messaging/model/selection_messages.py

@ -1,9 +0,0 @@
from odoo import fields, models
class SelectionMessages(models.Model):
_name = 'selection.messages'
name = fields.Char(string='Name of the Message Template')
message = fields.Text(string="Message", required=True)

2
whatsapp_mail_messaging/security/ir.model.access.csv

@ -1,4 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_whatsapp_message_wizard,access.whatsapp.message.wizard,model_whatsapp_message_wizard,base.group_user,1,1,1,1
access_selection_messages,access.selection.messages,model_selection_messages,base.group_user,1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_whatsapp_message_wizard access.whatsapp.message.wizard model_whatsapp_message_wizard base.group_user 1 1 1 1
access_selection_messages access.selection.messages model_selection_messages base.group_user 1 1 1 1

BIN
whatsapp_mail_messaging/static/description/assets/screenshots/23.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

6
whatsapp_mail_messaging/static/description/index.html

@ -242,7 +242,11 @@
<h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">The message will redirect to the whatsapp web with the details in the popup. </h3>
<img src="assets/screenshots/14.png" class="img-thumbnail">
</div>
<div style="display: block; margin: 30px auto;">
<h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">Whatsapp Message Template</h3>
<p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;">Create whatsapp message template for sales orders and invoices.</p>
<img src="assets/screenshots/23.png" class="img-thumbnail">
</div>
<div style="display: block; margin: 30px auto;">
<h3 style="font-family: 'Montserrat', sans-serif; font-size: 18px; font-weight: bold;">Add Mobile in Website</h3>
<p style="font-weight: 400; font-family: 'Montserrat', sans-serif; font-size: 14px;">In the website form view we can define the number along with country code required for communicating

16
whatsapp_mail_messaging/views/res_company_views.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="res_company_view_form" model="ir.ui.view">
<field name="name">
res.company.view.form.inherit.whatsapp.mail.messaging
</field>
<field name="model">res.company</field>
<field name="inherit_id"
ref="base.view_company_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='country_id']" position="after">
<field name="whatsapp_message" invisible="1"/>
</xpath>
</field>
</record>
</odoo>

31
whatsapp_mail_messaging/views/res_config_settings_views.xml

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">
res.config.settings.view.form.inherit.whatsapp.mail.messaging
</field>
<field name="model">res.config.settings</field>
<field name="inherit_id"
ref="base.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='integration']" position="after">
<h2>Whatsapp</h2>
<div class="row mt16 o_settings_container" name="whatsapp_message">
<div class="col-12 col-lg-6 o_setting_box" id="whatsapp_message_tempalte">
<label for="whatsapp_message"/>
<field name="whatsapp_message" placeholder="Message..." widget="text_emojis"/>
<div class="text-muted">
This WhatsApp message template is for sales orders and invoices.
</div>
</div>
</div>
<!-- <block title="Whatsapp" id="whatsapp_message">-->
<!-- <setting-->
<!-- help="This WhatsApp message template is for sales orders and invoices.">-->
<!-- <field name="whatsapp_message" placeholder="Message..." widget="text_emojis"/>-->
<!-- </setting>-->
<!-- </block>-->
</xpath>
</field>
</record>
</odoo>

55
whatsapp_mail_messaging/views/selection_messages_views.xml

@ -1,55 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!--Selection messages Tree View -->
<record id="selection_messages_view_tree" model="ir.ui.view">
<field name="name">selection.messages.view.tree</field>
<field name="model">selection.messages</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="message"/>
</tree>
</field>
</record>
<!-- Selection messages Form View-->
<record id="selection_messages_view_form" model="ir.ui.view">
<field name="name">selection.messages.view.form</field>
<field name="model">selection.messages</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<group>
<field name="name"/>
</group>
</group>
<notebook>
<page string="Message">
<group>
<field colspan="2" name="message" widget="text_emojis"
nolabel="1"
placeholder="Write Message here...."
/>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<!--Selection messages Action -->
<record id="selection_messages_action" model="ir.actions.act_window">
<field name="name">Selection Messages</field>
<field name="res_model">selection.messages</field>
<field name="type">ir.actions.act_window</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="selection_messages_view_tree"/>
</record>
<menuitem name="Whatsapp Messages"
id="menu_website_selection_messages"
action="selection_messages_action"
parent="website.menu_website_global_configuration"
sequence="50"
/>
</odoo>

16
whatsapp_mail_messaging/wizard/wh_message_wizard.py

@ -28,8 +28,6 @@ class WhatsappSendMessage(models.TransientModel):
partner_id = fields.Many2one('res.partner', string="Recipient")
mobile = fields.Char(required=True, string="Contact Number")
message = fields.Text(string="Message", required=True)
message_name_id = fields.Many2one('selection.messages', string="Message Template")
type_message = fields.Selection([('custom', 'Custom'), ('default', 'Default')], 'Message Type', default='custom')
image_1920 = fields.Binary(readonly=1)
@api.onchange('partner_id')
@ -39,18 +37,6 @@ class WhatsappSendMessage(models.TransientModel):
self.mobile = self.partner_id.mobile
self.image_1920 = self.partner_id.image_1920
@api.onchange('message_name_id')
def _onchange_type_message(self):
"""Function to set the default message based on type_message"""
if self.message_name_id:
self.message = self.message_name_id.message
@api.onchange('type_message')
def _onchange_type_message_type(self):
"""Function to set the default message based on type_message"""
if self.type_message == 'default':
self.message = self.message_name_id.message
def send_message(self):
"""In this function we are redirecting to the whatsapp web
with required parameters"""
@ -62,7 +48,7 @@ class WhatsappSendMessage(models.TransientModel):
message_string = message_string[:(len(message_string) - 3)]
message_post_content = message_string
if self.partner_id:
self.partner_id.message_post(body=message_post_content)
self.partner_id.message_post(body=message_post_content)
return {
'type': 'ir.actions.act_url',
'url': "https://api.whatsapp.com/send?phone=" + self.mobile + "&text=" + message_string,

12
whatsapp_mail_messaging/wizard/wh_message_wizard.xml

@ -14,24 +14,22 @@
$('.modal-body').css({'height': '100%'});
});
</script>
<sheet>
<field name="image_1920" widget='image' class="oe_avatar"/>
<group col="2" colspan="4">
<group>
<field name="partner_id"/>
<field name="mobile"/>
<field name="type_message" widget="radio"/>
<field name="message_name_id" attrs="{'invisible': [('type_message', '=', 'custom')]}"/>
<field name="message" widget="text_emojis"/>
</group>
<group>
<field name="image_1920" widget='image' class="oe_avatar"
options='{"preview_image": "image", "size": [150, 150]}' nolabel="1"/>
<field name="message" widget="text_emojis"/>
</group>
</group>
<footer>
<button name="send_message" string="Send" type="object" class="oe_highlight"
icon="fa-whatsapp"/>
<button name="cancel" string="Cancel" special="cancel"/>
</footer>
</sheet>
</form>
</field>
</record>

Loading…
Cancel
Save