[16.0][IMP] report_csv: support attachment use

This commit is contained in:
sbejaoui
2023-09-26 22:36:00 +02:00
parent c4af987fe4
commit fd34b95bbd
2 changed files with 61 additions and 1 deletions

View File

@@ -47,6 +47,20 @@ class TestReport(common.TransactionCase):
dict_report = list(csv.DictReader(str_io, delimiter=";", quoting=csv.QUOTE_ALL))
self.assertEqual(self.docs.name, dict(dict_report[0])["name"])
def test_attachment_use(self):
self.report.attachment = "object.name+'.csv'"
self.report.attachment_use = True
rep = self.report_object._render(self.report_name, self.docs.ids, {})
attachment = self.env["ir.attachment"].search(
[("name", "=", self.docs.name + ".csv")]
)
self.assertTrue(attachment)
self.assertEqual(attachment.raw.decode(), rep[0])
rep_from_attachment = self.report_object._render(
self.report_name, self.docs.ids, {}
)
self.assertTupleEqual(rep, rep_from_attachment)
def test_id_retrieval(self):
# Typical call from WebUI with wizard