Browse Source

May 03: [FIX] Bug Fixed 'payment_proof_attachment'

pull/254/merge
RisvanaCybro 12 months ago
parent
commit
3e2574cc84
  1. 17
      payment_proof_attachment/controllers/payment_proof_attachment.py
  2. 17
      payment_proof_attachment/data/payment_proof_attachment.xml
  3. 2
      payment_proof_attachment/static/src/js/my_account_screen.js
  4. 2
      payment_proof_attachment/static/src/js/payment_screen.js

17
payment_proof_attachment/controllers/payment_proof_attachment.py

@ -57,7 +57,8 @@ class WebsitePaymentProof(http.Controller):
sale_id = request.session.sale_order_id
sale = request.env['sale.order'].sudo().browse(sale_id)
for attachment in kw['attachments']:
payment_proof_attachment = request.env['ir.attachment'].sudo().create({
payment_proof_attachment = request.env[
'ir.attachment'].sudo().create({
'name': attachment['name'],
'res_model': 'sale.order',
'res_id': sale_id,
@ -66,14 +67,18 @@ class WebsitePaymentProof(http.Controller):
'datas': attachment['content'],
})
body = _("%s document is added by %s" % (
attachment['name'], request.env.user.name))
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
copied_attachment = payment_proof_attachment.copy()
mail_template = request.env.ref(
'payment_proof_attachment'
'.payment_proof_attachment_email_template').id
template = request.env['mail.template'].browse(mail_template)
template.attachment_ids = [(6, 0, [payment_proof_attachment.id])]
template.attachment_ids = [(6, 0, [copied_attachment.id])]
template.send_mail(sale_id, force_send=True)
template.attachment_ids = [(3, payment_proof_attachment.id)]
return
template.attachment_ids = [(3, copied_attachment.id)]
return True
@http.route(['/my_account_screen/show_updated'], type='json', auth="public")
def payment_show_receipt(self, **kw):

17
payment_proof_attachment/data/payment_proof_attachment.xml

@ -1,18 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="payment_proof_attachment_email_template" model="mail.template">
<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="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;">
<p>Dear,</p>
<p>Your Payment Proof Attachment is Uploaded Successfully</p>
<span>Dear<t t-out="object.partner_id.name"/>,
</span>
<p>Your Payment Proof Attachment is Uploaded Successfully
</p>
<p>Best regards,</p>
<p>{{ object.company_id.id }}</p>
<span>
<t t-out="object.company_id.name"/>
</span>
</div>
</field>
<field name="lang">{{ object.partner_id.lang }}</field>

2
payment_proof_attachment/static/src/js/my_account_screen.js

@ -75,7 +75,7 @@ odoo.define('payment_proof_attachment.my_account_screen', function(require) {
$(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 class='btn btn-outline-info' href='" + id + "'>" + name + " <i class='fa fa-download'/></a><br/>");
self.$el.find('#showing_updated_receipt').append("<a style='margin-bottom: 10px;' class='btn btn-outline-info' href='" + id + "'>" + name + " <i class='fa fa-download'/></a><br/>");
});
} else {
self.$el.find("#showing_updated_receipt").empty();

2
payment_proof_attachment/static/src/js/payment_screen.js

@ -73,7 +73,7 @@ odoo.define('payment_proof_attachment.payment_screen', function(require) {
$(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 class='btn btn-outline-info' href='" + id + "'>" + name + " <i class='fa fa-download'/></a><br/>");
self.$el.find('#showing_updated_receipt').append("<a style='margin-bottom: 10px;' class='btn btn-outline-info' href='" + id + "'>" + name + " <i class='fa fa-download'/></a><br/>");
});
} else {
self.$el.find("#showing_updated_receipt").empty();

Loading…
Cancel
Save