Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Corrige geração do boleto durante envio de e-mail #649

Merged
merged 1 commit into from
Nov 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 11 additions & 6 deletions br_nfse_paulistana/models/invoice_eletronic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import re
import time
import pytz
import base64
import logging
from datetime import date, datetime, timedelta
from dateutil.relativedelta import relativedelta
from odoo import api, fields, models
from odoo.tools.safe_eval import safe_eval
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT as DTFT

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -233,14 +235,17 @@ def _find_attachment_ids_email(self):
return atts

attachment_obj = self.env['ir.attachment']
danfe_report = self.env['ir.actions.report.xml'].search(
[('report_name', '=', 'br_nfse.main_template_br_nfse_danfe')])
report_service = danfe_report.report_name
danfse = self.env['report'].get_pdf([self.id], report_service)
danfe_report = self.env['ir.actions.report'].search(
[('report_name', '=',
'br_nfse_paulistana.main_template_br_nfse_danfe')])
report_service = danfe_report.xml_id
danfse, dummy = self.env.ref(report_service).render_qweb_pdf([self.id])
report_name = safe_eval(danfe_report.print_report_name,
{'object': self, 'time': time})
if danfse:
danfe_id = attachment_obj.create(dict(
name="paulistana-%08d.pdf" % self.numero,
datas_fname="paulistana-%08d.pdf" % self.numero,
name=report_name,
datas_fname=report_name,
datas=base64.b64encode(danfse),
mimetype='application/pdf',
res_model='account.invoice',
Expand Down