[FIX] isort,prettier,black

This commit is contained in:
KKamaa
2022-08-26 12:09:39 +03:00
parent cb5bbcff6a
commit 997909e915
3 changed files with 25 additions and 18 deletions

View File

@@ -144,8 +144,13 @@ class ReportAsync(models.Model):
@api.model @api.model
def print_document_async( def print_document_async(
self, record_ids, report_name, html=None, data=None, to_email="", self,
save_attachment_to_records=False record_ids,
report_name,
html=None,
data=None,
to_email="",
save_attachment_to_records=False,
): ):
"""Generate a document async, do not return the document file""" """Generate a document async, do not return the document file"""
user_email = to_email or self.env.user.email user_email = to_email or self.env.user.email
@@ -158,7 +163,7 @@ class ReportAsync(models.Model):
email_notify=True, email_notify=True,
to_email=user_email, to_email=user_email,
session_id=request.session.sid, session_id=request.session.sid,
save_attachment_to_records=save_attachment_to_records save_attachment_to_records=save_attachment_to_records,
) )
@api.model @api.model
@@ -171,7 +176,7 @@ class ReportAsync(models.Model):
email_notify=False, email_notify=False,
to_email=None, to_email=None,
session_id=None, session_id=None,
save_attachment_to_records=False save_attachment_to_records=False,
): ):
report = self.env["ir.actions.report"].browse(report_id) report = self.env["ir.actions.report"].browse(report_id)
func = REPORT_TYPES_FUNC[report.report_type] func = REPORT_TYPES_FUNC[report.report_type]
@@ -207,7 +212,10 @@ class ReportAsync(models.Model):
model = report.model model = report.model
records = self.env[model].browse(docids) records = self.env[model].browse(docids)
for record in records: for record in records:
attachment = self.env["ir.attachment"].sudo().create( attachment = (
self.env["ir.attachment"]
.sudo()
.create(
{ {
"name": out_name, "name": out_name,
"datas": out_file, "datas": out_file,
@@ -216,7 +224,8 @@ class ReportAsync(models.Model):
"res_id": record.id, "res_id": record.id,
} }
) )
if hasattr(record, 'message_post'): )
if hasattr(record, "message_post"):
record.message_post(attachment_ids=[attachment.id]) record.message_post(attachment_ids=[attachment.id])
self._cr.execute( self._cr.execute(
""" """

View File

@@ -67,7 +67,7 @@ odoo.define("report_async.ActionMenus", function (require) {
to_email: user_email, to_email: user_email,
data: action.data || {}, data: action.data || {},
context: action.context || {}, context: action.context || {},
save_attachment_to_records: save_report_attachment save_attachment_to_records: save_report_attachment,
}, },
}) })
.then(() => { .then(() => {

View File

@@ -29,13 +29,11 @@
checked="checked" checked="checked"
id="async-save-report-checker" id="async-save-report-checker"
/> />
<label class="form-check-label" <label class="form-check-label" for="async-save-report-checker">
for="async-save-report-checker">
Save attachment to records Save attachment to records
</label> </label>
</div> </div>
<small id="async-save-report-checker-help" <small id="async-save-report-checker-help" class="form-text text-muted">
class="form-text text-muted">
Checker enables async report attachment to be created and Checker enables async report attachment to be created and
saved to the records. NB: Records should support attachments saved to the records. NB: Records should support attachments
</small> </small>