Skip to content

Commit

Permalink
[16.0] [FIX] l10n_it_fatturapa_out: attach report to a xml invoice po…
Browse files Browse the repository at this point in the history
…ps an error on "report_print_menu" field
  • Loading branch information
micheledic authored May 23, 2024
1 parent d527ff4 commit 8e3ca22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
27 changes: 4 additions & 23 deletions l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,8 @@ class WizardExportFatturapa(models.TransientModel):
_name = "wizard.export.fatturapa"
_description = "Export E-invoice"

@api.model
def _domain_ir_values(self):
model_name = self.env.context.get("active_model", False)
# Get all print actions for current model
return [
("binding_model_id", "=", model_name),
]

def _get_selection(self):
reports = self.env["ir.actions.report"].sudo().search(self._domain_ir_values())
ret = [(str(r.id), r.name) for r in reports]
return ret

report_print_menu = fields.Selection(
selection="_get_selection",
help="This report will be automatically included in the created XML",
report_print_menu = fields.Many2one("ir.actions.report",
help="This report will be automatically included in the created XML"
)

def saveAttachment(self, fatturapa, number):
Expand Down Expand Up @@ -300,14 +286,9 @@ def exportFatturaPA(self):
return action

def generate_attach_report(self, inv):
try:
report_id = int(self.report_print_menu)
except ValueError as exc:
raise UserError(_("Print report not found")) from exc

report_model = self.env["ir.actions.report"].sudo().browse(report_id)
report_model = self.env['ir.actions.report']

Check warning on line 289 in l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_fatturapa_out/wizard/wizard_export_fatturapa.py#L289

Added line #L289 was not covered by tests
attachment, attachment_type = report_model._render_qweb_pdf(
report_model, inv.ids
self.report_print_menu, inv.ids
)
att_id = self.env["ir.attachment"].create(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<field
name="report_print_menu"
string="Attached report"
domain="[('binding_model_id','=',context.get('active_model'))]"
widget="selection"
/>
</group>
Expand Down

0 comments on commit 8e3ca22

Please sign in to comment.