Browse Source

May 03: [FIX] Bug Fixed 'payment_proof_attachment'

pull/254/merge
RisvanaCybro 12 months ago
parent
commit
3e2574cc84
  1. 15
      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

15
payment_proof_attachment/controllers/payment_proof_attachment.py

@ -57,7 +57,8 @@ class WebsitePaymentProof(http.Controller):
sale_id = request.session.sale_order_id sale_id = request.session.sale_order_id
sale = request.env['sale.order'].sudo().browse(sale_id) sale = request.env['sale.order'].sudo().browse(sale_id)
for attachment in kw['attachments']: 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'], 'name': attachment['name'],
'res_model': 'sale.order', 'res_model': 'sale.order',
'res_id': sale_id, 'res_id': sale_id,
@ -68,12 +69,16 @@ class WebsitePaymentProof(http.Controller):
body = _("%s document is added by %s" % ( body = _("%s document is added by %s" % (
attachment['name'], request.env.user.name)) attachment['name'], request.env.user.name))
sale.message_post(body=body) 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 = 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.send_mail(sale_id, force_send=True)
template.attachment_ids = [(3, payment_proof_attachment.id)] template.attachment_ids = [(3, copied_attachment.id)]
return return True
@http.route(['/my_account_screen/show_updated'], type='json', auth="public") @http.route(['/my_account_screen/show_updated'], type='json', auth="public")
def payment_show_receipt(self, **kw): 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"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<data noupdate="1"> <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="name">Sales Order: Payment Proof Attachment</field>
<field name="model_id" ref="sale.model_sale_order"/> <field name="model_id" ref="sale.model_sale_order"/>
<field name="subject">Payment Proof Attachment</field> <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="partner_to">{{ object.partner_id.id }}</field>
<field name="body_html" type="html"> <field name="body_html" type="html">
<div style="margin: 0px; padding: 0px;"> <div style="margin: 0px; padding: 0px;">
<p>Dear,</p> <span>Dear<t t-out="object.partner_id.name"/>,
<p>Your Payment Proof Attachment is Uploaded Successfully</p> </span>
<p>Your Payment Proof Attachment is Uploaded Successfully
</p>
<p>Best regards,</p> <p>Best regards,</p>
<p>{{ object.company_id.id }}</p> <span>
<t t-out="object.company_id.name"/>
</span>
</div> </div>
</field> </field>
<field name="lang">{{ object.partner_id.lang }}</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) { $(attachment_ids).each(function(attachment_id) {
var id = "/web/content/" + attachment_ids[attachment_id]['id'] var id = "/web/content/" + attachment_ids[attachment_id]['id']
var name = attachment_ids[attachment_id]['name'] 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 { } else {
self.$el.find("#showing_updated_receipt").empty(); 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) { $(attachment_ids).each(function(attachment_id) {
var id = "/web/content/" + attachment_ids[attachment_id]['id'] var id = "/web/content/" + attachment_ids[attachment_id]['id']
var name = attachment_ids[attachment_id]['name'] 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 { } else {
self.$el.find("#showing_updated_receipt").empty(); self.$el.find("#showing_updated_receipt").empty();

Loading…
Cancel
Save