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

[16.0] [FIX] l10n_it_fatturapa_out: attach report to a xml invoice pops an error on "report_print_menu" field #4156

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 5 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,9 @@
_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",
Comment on lines -48 to +36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sembra un rollback di 0315ba5, @TheMule71 @michelerusti cosa ne pensate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ho visto anche la PR che ha portato da Many2one a Selection , ma secondo il mio parere ha più senso sia una many2one visto anche che nel caso di Selection, viene riportato errore se viene settato quel campo senza contesto active_model ....
Cioè gli attributi dell'entità del wizard, non dovrebbero essere strict rispetto al contesto ma il contesto dovrebbe solamente suggerire il report da utilizzare. Poi usando widget=selection anche la many2one diventa come selection e quindi trasparente per ,l'utente finale

Poi chi dovrà provvedere ad esportare le fatture, avrà sicuramente anche accesso al modello ir.actions.report quindi non dovrebbero esserci problemi di permessi d'accesso

Ovviamente parere mio tecnico, potrei anche sbagliarmi

help="This report will be automatically included in the created XML"
)

def saveAttachment(self, fatturapa, number):
Expand Down Expand Up @@ -300,14 +287,9 @@
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 290 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#L290

Added line #L290 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
Loading