mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
ADJ: When generating invoices from the Wizard to create invoices manually, reraise any UserError with information about which contract triggered the exception to facilitate the investigation by accountants in case invoices are not generated automatically.
This commit is contained in:
committed by
Pedro M. Baeza
parent
0bc5082115
commit
d673af70da
@@ -2,6 +2,13 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import (
|
||||
AccessDenied,
|
||||
AccessError,
|
||||
MissingError,
|
||||
UserError,
|
||||
ValidationError,
|
||||
)
|
||||
|
||||
|
||||
class ContractManuallyCreateInvoice(models.TransientModel):
|
||||
@@ -52,7 +59,24 @@ class ContractManuallyCreateInvoice(models.TransientModel):
|
||||
self.ensure_one()
|
||||
invoices = self.env["account.move"]
|
||||
for contract in self.contract_to_invoice_ids:
|
||||
invoices |= contract.recurring_create_invoice()
|
||||
try:
|
||||
invoices |= contract.recurring_create_invoice()
|
||||
except (
|
||||
AccessDenied,
|
||||
AccessError,
|
||||
MissingError,
|
||||
UserError,
|
||||
ValidationError,
|
||||
) as oe:
|
||||
raise UserError(
|
||||
_(
|
||||
"Failed to process the contract %(name)s [id: %(id)s]:\n%(ue)s",
|
||||
name=contract.name,
|
||||
id=contract.id,
|
||||
ue=repr(oe),
|
||||
)
|
||||
) from oe
|
||||
|
||||
return {
|
||||
"type": "ir.actions.act_window",
|
||||
"name": _("Invoices"),
|
||||
|
||||
Reference in New Issue
Block a user