@ -0,0 +1,50 @@ |
|||||
|
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg |
||||
|
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html |
||||
|
:alt: License: AGPL-3 |
||||
|
|
||||
|
Payment Proof Attachment |
||||
|
======================== |
||||
|
This module adds an option to your customer to attach the payment proof files in the website |
||||
|
|
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
* No additional configurations needed |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
* Developers: V(16) yadhukrishnan, |
||||
|
V(17) Sabeel B, |
||||
|
V(18) Raneesha MK |
||||
|
Contact : odoo@cybrosys.com |
||||
|
|
||||
|
Contacts |
||||
|
-------- |
||||
|
* Mail Contact : odoo@cybrosys.com |
||||
|
* Website : https://cybrosys.com |
||||
|
|
||||
|
License |
||||
|
------- |
||||
|
General Public License, Version 3 (AGPL v3). |
||||
|
(https://www.gnu.org/licenses/agpl-3.0-standalone.html) |
||||
|
|
||||
|
Bug Tracker |
||||
|
----------- |
||||
|
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
||||
|
|
||||
|
Maintainer |
||||
|
========== |
||||
|
.. image:: https://cybrosys.com/images/logo.png |
||||
|
:target: https://cybrosys.com |
||||
|
|
||||
|
This module is maintained by Cybrosys Technologies. |
||||
|
|
||||
|
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Further information |
||||
|
=================== |
||||
|
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,21 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Raneesha MK (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
################################################################################ |
||||
|
from . import controllers |
@ -0,0 +1,52 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Raneesha MK (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
################################################################################ |
||||
|
{ |
||||
|
'name': 'Payment Proof Attachment', |
||||
|
'version': '18.0.1.0.0', |
||||
|
'category': 'Website', |
||||
|
'summary': """Proof Attachment In Website for Odoo 17 Community and |
||||
|
Enterprise Edition.""", |
||||
|
'description': """This module allows the customers to attach proof |
||||
|
attachments in the website""", |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'website': 'https://www.cybrosys.com', |
||||
|
'depends': [ |
||||
|
'website_sale', |
||||
|
'sale_management' |
||||
|
], |
||||
|
'data': [ |
||||
|
'views/attachment_templates.xml', |
||||
|
'data/payment_proof_attachment.xml' |
||||
|
], |
||||
|
'assets': { |
||||
|
'web.assets_frontend': [ |
||||
|
'payment_proof_attachment/static/src/js/*.js', |
||||
|
'payment_proof_attachment/static/src/css/payment_proof.css', |
||||
|
] |
||||
|
}, |
||||
|
'images': ['static/description/banner.jpg'], |
||||
|
'license': 'AGPL-3', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False, |
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Raneesha MK (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
################################################################################ |
||||
|
from . import payment_proof_attachment |
@ -0,0 +1,113 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Raneesha MK (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
################################################################################ |
||||
|
from odoo import http, _ |
||||
|
from odoo.http import request |
||||
|
|
||||
|
|
||||
|
class WebsitePaymentProof(http.Controller): |
||||
|
""" |
||||
|
The WebsitePaymentProof updating the value of the sale order from the |
||||
|
backend with the content that the customer |
||||
|
uploaded in the frontend. |
||||
|
Methods: |
||||
|
payment_proof(self, **kw): |
||||
|
onclick the save button creating new records in "ir.attachment" for |
||||
|
the corresponding sale order working on |
||||
|
"my account" screen. |
||||
|
payment_screen_proof(self, **kw): |
||||
|
onclick the save button creating new records in "ir.attachment" for |
||||
|
the corresponding sale order working on "payment" screen. |
||||
|
payment_show_receipt(self, **kw): |
||||
|
onclick the show attachment button getting updated attachments. |
||||
|
""" |
||||
|
|
||||
|
@http.route(['/payment_proof/submit'], type='json', auth="public") |
||||
|
def payment_proof(self, **kw): |
||||
|
""" |
||||
|
Summary: |
||||
|
onclick the save button creating new records in "ir.attachment" for |
||||
|
the corresponding sale order working on |
||||
|
"my account" screen. |
||||
|
Args: |
||||
|
kw(dict): |
||||
|
it contains sale order id and contents of the input files. |
||||
|
""" |
||||
|
if 'sale_id' in kw: |
||||
|
sale_id = int(kw.get('sale_id')) |
||||
|
else: |
||||
|
sale_id = request.session.sale_order_id |
||||
|
sale = request.env['sale.order'].sudo().browse(sale_id) |
||||
|
attached_files = kw['attachments'] |
||||
|
for attachment in attached_files: |
||||
|
name = attachment['name'] |
||||
|
content = attachment['content'] |
||||
|
payment_proof_attachment = request.env[ |
||||
|
'ir.attachment'].sudo().create({ |
||||
|
'name': name, |
||||
|
'res_model': 'sale.order', |
||||
|
'res_id': sale_id, |
||||
|
'type': 'binary', |
||||
|
'public': True, |
||||
|
'datas': content, |
||||
|
}) |
||||
|
copied_attachment = payment_proof_attachment.copy() |
||||
|
body = _("%s document is added by %s" % ( |
||||
|
attachment['name'], request.env.user.name)) |
||||
|
sale.message_post(body=body) |
||||
|
mail_template = request.env.ref( |
||||
|
'payment_proof_attachment' |
||||
|
'.payment_proof_attachment_email_template').id |
||||
|
payment_proof_template = request.env['mail.template'].browse( |
||||
|
mail_template) |
||||
|
payment_proof_template.attachment_ids = [ |
||||
|
(6, 0, [copied_attachment.id])] |
||||
|
payment_proof_template.send_mail(sale_id, force_send=True) |
||||
|
payment_proof_template.attachment_ids = [(3, copied_attachment.id)] |
||||
|
|
||||
|
return |
||||
|
|
||||
|
@http.route(['/my_account_screen/show_updated'], type='json', |
||||
|
auth="public") |
||||
|
def payment_show_receipt(self, **kw): |
||||
|
""" |
||||
|
Summary: |
||||
|
onclick the show attachment button getting updated attachments. |
||||
|
Args: |
||||
|
kw(dict): |
||||
|
it contains the id of the current sale order. |
||||
|
Return(list) |
||||
|
it contains the all attachments |
||||
|
""" |
||||
|
if kw: |
||||
|
sale_id = kw['data'] |
||||
|
else: |
||||
|
sale_id = request.session.sale_order_id |
||||
|
user_id = request.session.uid |
||||
|
attachment_ids_list = [] |
||||
|
attachment_ids = request.env['ir.attachment'].sudo().search([( |
||||
|
'res_model', '=', 'sale.order'), ('res_id', '=', sale_id), |
||||
|
('create_uid', '=', user_id)]) |
||||
|
for attachment_id in attachment_ids: |
||||
|
attachment_ids_list.append(({ |
||||
|
'id': attachment_id.id, |
||||
|
'name': attachment_id.name |
||||
|
})) |
||||
|
return attachment_ids_list |
@ -0,0 +1,29 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<data noupdate="1"> |
||||
|
<record id="payment_proof_attachment_email_template" |
||||
|
model="mail.template"> |
||||
|
<field name="name">Sales Order: Payment Proof Attachment</field> |
||||
|
<field name="model_id" ref="sale.model_sale_order"/> |
||||
|
<field name="subject">Payment Proof Attachment</field> |
||||
|
<field name="email_from">{{ (object.user_id.email_formatted or |
||||
|
user.email_formatted or '') }} |
||||
|
</field> |
||||
|
<field name="partner_to">{{ object.partner_id.id }}</field> |
||||
|
<field name="body_html" type="html"> |
||||
|
<div style="margin: 0px; padding: 0px;"> |
||||
|
<span>Dear<t t-out="object.partner_id.name"/>, |
||||
|
</span> |
||||
|
<p>Your Payment Proof Attachment is Uploaded Successfully |
||||
|
</p> |
||||
|
<p>Best regards,</p> |
||||
|
<span> |
||||
|
<t t-out="object.company_id.name"/> |
||||
|
</span> |
||||
|
</div> |
||||
|
</field> |
||||
|
<field name="lang">{{ object.partner_id.lang }}</field> |
||||
|
<field name="auto_delete" eval="False"/> |
||||
|
</record> |
||||
|
</data> |
||||
|
</odoo> |
@ -0,0 +1,5 @@ |
|||||
|
## Module <payment_proof_attachment> |
||||
|
#### 05.10.2024 |
||||
|
#### Version 18.0.1.0.0 |
||||
|
##### ADD |
||||
|
- Initial Commit for Payment Proof Attachment |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 912 KiB |
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 191 KiB |
After Width: | Height: | Size: 206 KiB |
After Width: | Height: | Size: 211 KiB |
After Width: | Height: | Size: 206 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 134 KiB |
After Width: | Height: | Size: 135 KiB |
After Width: | Height: | Size: 268 KiB |
After Width: | Height: | Size: 326 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 134 KiB |
After Width: | Height: | Size: 12 KiB |
@ -0,0 +1,68 @@ |
|||||
|
.payment_proof_modal { |
||||
|
display: none; /* Hidden by default */ |
||||
|
position: fixed; /* Stay in place */ |
||||
|
z-index: 1300; /* Sit on top */ |
||||
|
padding-top: 100px; /* Location of the box */ |
||||
|
left: 0; |
||||
|
top: 0; |
||||
|
width: 100%; /* Full width */ |
||||
|
height: 100%; /* Full height */ |
||||
|
overflow: auto; /* Enable scroll if needed */ |
||||
|
background-color: rgb(0,0,0); /* Fallback color */ |
||||
|
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ |
||||
|
} |
||||
|
|
||||
|
/* Modal Content */ |
||||
|
.payment_proof_modal_content { |
||||
|
position: relative; |
||||
|
background-color: #fefefe; |
||||
|
margin: auto; |
||||
|
padding: 0; |
||||
|
border: 1px solid #888; |
||||
|
width: 40%; |
||||
|
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19); |
||||
|
-webkit-animation-name: animatetop; |
||||
|
-webkit-animation-duration: 0.4s; |
||||
|
animation-name: animatetop; |
||||
|
animation-duration: 0.4s |
||||
|
} |
||||
|
|
||||
|
/* Add Animation */ |
||||
|
@-webkit-keyframes animatetop { |
||||
|
from {top:-300px; opacity:0} |
||||
|
to {top:0; opacity:1} |
||||
|
} |
||||
|
|
||||
|
@keyframes animatetop { |
||||
|
from {top:-300px; opacity:0} |
||||
|
to {top:0; opacity:1} |
||||
|
} |
||||
|
/* The Close Button */ |
||||
|
.close { |
||||
|
color: white; |
||||
|
float: right; |
||||
|
font-size: 28px; |
||||
|
font-weight: bold; |
||||
|
} |
||||
|
|
||||
|
.close:hover, |
||||
|
.close:focus { |
||||
|
color: #000; |
||||
|
text-decoration: none; |
||||
|
cursor: pointer; |
||||
|
} |
||||
|
|
||||
|
.payment_proof_modal_header { |
||||
|
padding: 2px 16px; |
||||
|
background-color: #8595A2; |
||||
|
color: white; |
||||
|
} |
||||
|
|
||||
|
.payment_proof_modal_body {padding: 2px 16px;} |
||||
|
|
||||
|
.payment_proof_modal_footer { |
||||
|
padding: 2px 16px; |
||||
|
background-color: #8595A2; |
||||
|
color: white; |
||||
|
} |
||||
|
|
@ -0,0 +1,91 @@ |
|||||
|
/** @odoo-module **/ |
||||
|
import publicWidget from "@web/legacy/js/public/public_widget"; |
||||
|
import { rpc } from "@web/core/network/rpc"; |
||||
|
|
||||
|
publicWidget.registry.Template = publicWidget.Widget.extend({ |
||||
|
// init() {
|
||||
|
// this.rpc = this.env.services.rpc;
|
||||
|
// },
|
||||
|
selector: '#wrapwrap', |
||||
|
events: { |
||||
|
'click #btnShowModal': '_onClickShowModal', |
||||
|
'click .close_modal': '_onClickCloseModal', |
||||
|
'change #payment_proof': '_onChangePaymentProof', |
||||
|
'click #payment_proof_update': '_onClickUpdateAttachment', |
||||
|
'click #btnShowReceipt': '_onClickShowReceipt', |
||||
|
'click #refresh_receipt': '_onClickShowReceipt', |
||||
|
|
||||
|
|
||||
|
}, |
||||
|
/** |
||||
|
*for showing the modal dialog |
||||
|
*/ |
||||
|
_onClickShowModal: function () { |
||||
|
this.el.querySelector('#myModal').style.display = 'block'; |
||||
|
}, |
||||
|
/** |
||||
|
*for closing the modal dialog |
||||
|
*/ |
||||
|
_onClickCloseModal: function () { |
||||
|
this.el.querySelector('#myModal').style.display = 'none'; |
||||
|
}, |
||||
|
/** |
||||
|
*getting content from the uploaded file |
||||
|
*/ |
||||
|
_onChangePaymentProof: function (ev) { |
||||
|
const files = ev.target.files; |
||||
|
var fileList = []; |
||||
|
for (let i = 0; i < files.length; i++) { |
||||
|
var reader = new FileReader(); |
||||
|
var reader_content = reader.readAsDataURL(files[i]); |
||||
|
reader.onload = function (reader_content) { |
||||
|
var dataURL = reader_content.target.result.split(',')[1]; |
||||
|
var fileName = files[i].name; |
||||
|
fileList.push({ |
||||
|
name: fileName, |
||||
|
content: dataURL |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
this.fileList = fileList; |
||||
|
}, |
||||
|
/** |
||||
|
*transfer the content to python in my account screen |
||||
|
*/ |
||||
|
_onClickUpdateAttachment: function (ev) { |
||||
|
var self = this; |
||||
|
this.el.querySelector('#myModal').style.display = 'none'; |
||||
|
if (self.fileList) { |
||||
|
rpc('/payment_proof/submit', { |
||||
|
'sale_id': Number(self.$(ev.currentTarget).attr('value')), |
||||
|
'attachments': this.fileList |
||||
|
}).then(function () { |
||||
|
self.fileList = "" |
||||
|
self.$el.find("#payment_proof").val("") |
||||
|
}); |
||||
|
} |
||||
|
}, |
||||
|
/** |
||||
|
*getting updated attachments |
||||
|
*/ |
||||
|
_onClickShowReceipt: function () { |
||||
|
var self = this; |
||||
|
this.el.querySelector('#updated_receipt').style.display = 'block'; |
||||
|
this.el.querySelector('#btnShowReceipt').style.display = 'none'; |
||||
|
rpc('/my_account_screen/show_updated', { |
||||
|
'data': this.el.querySelector('#btnShowReceipt').getAttribute('value'), |
||||
|
}).then(function (attachment_ids) { |
||||
|
if (attachment_ids.length > 0) { |
||||
|
self.$el.find("#showing_updated_receipt").empty(); |
||||
|
$(attachment_ids).each(function (attachment_id) { |
||||
|
var id = "/web/content/" + attachment_ids[attachment_id]['id'] |
||||
|
var name = attachment_ids[attachment_id]['name'] |
||||
|
self.$el.find('#showing_updated_receipt').append("<a style='width:200px; margin-bottom: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;' class='btn btn-outline-secondary' href='" + id + "'>" + name + " <i class='fa fa-download'></i></a><br/>"); |
||||
|
}); |
||||
|
} else { |
||||
|
self.$el.find("#showing_updated_receipt").empty(); |
||||
|
self.$el.find('#showing_updated_receipt').append("<p style='color:red;'>There is no attachments for this sale order.</p>") |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
}) |
@ -0,0 +1,88 @@ |
|||||
|
/** @odoo-module **/ |
||||
|
import publicWidget from "@web/legacy/js/public/public_widget"; |
||||
|
import { rpc } from "@web/core/network/rpc"; |
||||
|
|
||||
|
publicWidget.registry.PaymentProof = publicWidget.Widget.extend({ |
||||
|
// init() {
|
||||
|
// this.rpc = this.env.services.rpc;
|
||||
|
// },
|
||||
|
selector: '.payment_screen', |
||||
|
events: { |
||||
|
'click #btnShowModal': '_onClickShowModal', |
||||
|
'click .close_modal': '_onClickCloseModal', |
||||
|
'change #payment_proof': '_onChangePaymentProof', |
||||
|
'click #payment_proof_cart_update': '_onClickUpdateAttachment', |
||||
|
'click #paymentScreenBtnShowReceipt': '_onClickShowReceipt', |
||||
|
'click #refresh_payment_receipt': '_onClickShowReceipt', |
||||
|
}, |
||||
|
/** |
||||
|
*for closing the modal dialog |
||||
|
*/ |
||||
|
_onClickShowModal: function () { |
||||
|
this.el.querySelector('#myModal').style.display = 'block'; |
||||
|
// document.querySelector('#wrapwrap').style.overflow = 'hidden';
|
||||
|
}, |
||||
|
/** |
||||
|
*for closing the modal dialog |
||||
|
*/ |
||||
|
_onClickCloseModal: function () { |
||||
|
this.el.querySelector('#myModal').style.display = 'none'; |
||||
|
// document.querySelector('#wrapwrap').style.overflow = 'auto';
|
||||
|
}, |
||||
|
/** |
||||
|
*getting content from the uploaded file |
||||
|
*/ |
||||
|
_onChangePaymentProof: function (ev) { |
||||
|
const files = ev.target.files; |
||||
|
var fileList = []; |
||||
|
for (let i = 0; i < files.length; i++) { |
||||
|
var reader = new FileReader(); |
||||
|
var reader_content = reader.readAsDataURL(files[i]); |
||||
|
reader.onload = function (reader_content) { |
||||
|
var dataURL = reader_content.target.result.split(',')[1]; |
||||
|
var fileName = files[i].name; |
||||
|
fileList.push({ |
||||
|
name: fileName, |
||||
|
content: dataURL |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
this.fileList = fileList; |
||||
|
}, |
||||
|
/** |
||||
|
*transfer the content to python in payment screen |
||||
|
*/ |
||||
|
_onClickUpdateAttachment: function (ev) { |
||||
|
var self = this; |
||||
|
this.el.querySelector('#myModal').style.display = 'none'; |
||||
|
if (self.fileList) { |
||||
|
rpc('/payment_proof/submit', { |
||||
|
'attachments': this.fileList |
||||
|
}).then(function () { |
||||
|
self.fileList = "" |
||||
|
self.$el.find("#payment_proof").val("") |
||||
|
}); |
||||
|
} |
||||
|
}, |
||||
|
/** |
||||
|
*getting updated attachments |
||||
|
*/ |
||||
|
_onClickShowReceipt: function () { |
||||
|
var self = this; |
||||
|
this.$el.find('#updated_receipt').css("display", "block") |
||||
|
this.$el.find('#paymentScreenBtnShowReceipt').css("display", "none") |
||||
|
rpc('/my_account_screen/show_updated', {}).then(function (attachment_ids) { |
||||
|
if (attachment_ids.length > 0) { |
||||
|
self.$el.find("#showing_updated_receipt").empty(); |
||||
|
$(attachment_ids).each(function (attachment_id) { |
||||
|
var id = "/web/content/" + attachment_ids[attachment_id]['id'] |
||||
|
var name = attachment_ids[attachment_id]['name'] |
||||
|
self.$el.find('#showing_updated_receipt').append("<a style='width:200px; margin-bottom: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;' class='btn btn-outline-secondary' href='" + id + "'>" + name + " <i class='fa fa-download'></i></a><br/>"); |
||||
|
}); |
||||
|
} else { |
||||
|
self.$el.find("#showing_updated_receipt").empty(); |
||||
|
self.$el.find('#showing_updated_receipt').append("<p style='color:yellow;>There is no attachments for this sale order.</p>") |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
}) |
@ -0,0 +1,108 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<odoo> |
||||
|
<!-- Inherit sale.sale_order_portal_template View to Modify it --> |
||||
|
<template id="sale_order_portal_attachment_inherit" |
||||
|
inherit_id="sale.sale_order_portal_template"> |
||||
|
<xpath expr="//div[hasclass('o_download_pdf')]" position="after"> |
||||
|
<div class="my_account_screen" > |
||||
|
<t t-if="sale_order.state != 'sale'"> |
||||
|
<div> |
||||
|
<button id="btnShowModal" style="width: 100%;" |
||||
|
class="btn btn-primary">Save / |
||||
|
Update Transaction Receipt |
||||
|
</button> |
||||
|
</div> |
||||
|
<div style="margin-top: 5px;width: 100%;"> |
||||
|
<button id="btnShowReceipt" class="btn btn-secondary" |
||||
|
style="width: 100%;" |
||||
|
t-att-value="sale_order.id">Show Updated Receipt |
||||
|
</button> |
||||
|
</div> |
||||
|
<div id="updated_receipt" style="width:100%;display:none"> |
||||
|
<p style="text-align: end;"> |
||||
|
<i class="fa fa-refresh" id="refresh_receipt" |
||||
|
t-att-value="sale_order.id"/> |
||||
|
</p> |
||||
|
<div id="showing_updated_receipt" style="width:100%;"/> |
||||
|
</div> |
||||
|
</t> |
||||
|
</div> |
||||
|
</xpath> |
||||
|
<xpath expr="//div[hasclass('o_portal_sale_sidebar')]" position="before"> |
||||
|
<div id="myModal" class="modal payment_proof_modal"> |
||||
|
<!-- Modal content --> |
||||
|
<div class="modal-content payment_proof_modal_content"> |
||||
|
<div class="modal-header payment_proof_modal_header"> |
||||
|
<h5>Upload Transaction Receipt</h5> |
||||
|
<div class="close_modal" style="margin-left: 63%;"> |
||||
|
<i class="fa fa-times-circle"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="modal-body payment_proof_modal_body"> |
||||
|
<p>Note :- You can attach proof of payments.</p> |
||||
|
</div> |
||||
|
<div class="modal-footer payment_proof_modal_footer"> |
||||
|
<input type="file" name="file" |
||||
|
id="payment_proof" |
||||
|
multiple="true" |
||||
|
data-show-upload="true" |
||||
|
data-show-caption="true" |
||||
|
accept="image/png,image/jpeg,application/pdf" |
||||
|
style="margin-right: 350px !important"/> |
||||
|
<button id="payment_proof_update" class="btn btn-primary" |
||||
|
t-att-value="sale_order.id" |
||||
|
>Save |
||||
|
</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</xpath> |
||||
|
|
||||
|
</template> |
||||
|
<!-- Inherit website_sale.payment View to Modify it --> |
||||
|
<template id="website_sale_order_inherit" inherit_id="payment.no_pms_available_warning"> |
||||
|
<xpath expr="//div[hasclass('alert-warning')]" position="after"> |
||||
|
<div class="payment_screen"> |
||||
|
<div id="btnShowModal" style="color:#276e72;cursor:pointer;"> |
||||
|
<i class="fa fa-arrow-right"/> |
||||
|
Update Transaction Receipt |
||||
|
</div> |
||||
|
<div id="paymentScreenBtnShowReceipt" |
||||
|
style="color:#276e72;cursor:pointer;"> |
||||
|
<i class="fa fa-arrow-right"/> |
||||
|
Show Updated Receipt |
||||
|
</div> |
||||
|
<div id="updated_receipt" style="width:50%;display:none"> |
||||
|
<p style="text-align: end;"> |
||||
|
<i class="fa fa-refresh" id="refresh_payment_receipt"/> |
||||
|
</p> |
||||
|
<div id="showing_updated_receipt" style="width:100%;"/> |
||||
|
</div> |
||||
|
<div id="myModal" class="modal payment_proof_modal"> |
||||
|
<!-- Modal content --> |
||||
|
<div class="modal-content payment_proof_modal_content"> |
||||
|
<div class="modal-header payment_proof_modal_header"> |
||||
|
<h5>Upload Transaction Receipt</h5> |
||||
|
<span class="close_modal"> |
||||
|
<i class="fa fa-times-circle"/> |
||||
|
</span> |
||||
|
</div> |
||||
|
<div class="modal-body payment_proof_modal_body"> |
||||
|
<p>Note :- You can attach proof of payments.</p> |
||||
|
</div> |
||||
|
<div class="modal-footer payment_proof_modal_footer"> |
||||
|
<input type="file" name="file" |
||||
|
id="payment_proof" |
||||
|
multiple="true" |
||||
|
data-show-upload="true" |
||||
|
data-show-caption="true" |
||||
|
accept="image/png, image/jpeg, application/pdf" |
||||
|
style="margin-right: 350px !important"/> |
||||
|
<button id="payment_proof_cart_update" class="btn btn-primary">Save</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</xpath> |
||||
|
</template> |
||||
|
</odoo> |