You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

51 lines
2.2 KiB

# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2020-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Sayooj A O(<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 models
class Account(models.Model):
_inherit = 'account.move'
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_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,
'default_mobile': self.partner_id.mobile,
'default_image_1920': self.partner_id.image_1920,
})
return {
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'whatsapp.message.wizard',
'views': [(compose_form_id, 'form')],
'view_id': compose_form_id,
'target': 'new',
'context': ctx,
}