mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[IMP] printing_auto_base: log or raise
Select on printing.auto to log or raise errors
This commit is contained in:
committed by
Jacques-Etienne Baudoux
parent
9dc8e3ad02
commit
fb24e652fe
@@ -53,6 +53,12 @@ class PrintingAuto(models.Model):
|
|||||||
printer_id = fields.Many2one("printing.printer", "Printer")
|
printer_id = fields.Many2one("printing.printer", "Printer")
|
||||||
printer_tray_id = fields.Many2one("printing.tray", "Tray")
|
printer_tray_id = fields.Many2one("printing.tray", "Tray")
|
||||||
nbr_of_copies = fields.Integer("Number of Copies", default=1)
|
nbr_of_copies = fields.Integer("Number of Copies", default=1)
|
||||||
|
action_on_error = fields.Selection(
|
||||||
|
[("log", "Record an error"), ("raise", "Raise an Exception")],
|
||||||
|
"Action on error",
|
||||||
|
default="log",
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
|
|
||||||
@api.constrains("data_source", "report_id", "attachment_domain")
|
@api.constrains("data_source", "report_id", "attachment_domain")
|
||||||
def _check_data_source(self):
|
def _check_data_source(self):
|
||||||
|
|||||||
@@ -37,14 +37,21 @@ class PrintingAutoMixin(models.AbstractModel):
|
|||||||
def _get_printing_auto(self):
|
def _get_printing_auto(self):
|
||||||
return self.auto_printing_ids
|
return self.auto_printing_ids
|
||||||
|
|
||||||
def _handle_print_auto(self, printing_auto):
|
def _do_print_auto(self, printing_auto):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
printing_auto.ensure_one()
|
printing_auto.ensure_one()
|
||||||
|
printer, count = printing_auto.do_print(self)
|
||||||
|
if count:
|
||||||
|
self._on_printing_auto_done(printing_auto, printer, count)
|
||||||
|
|
||||||
|
def _handle_print_auto(self, printing_auto):
|
||||||
|
printing_auto.ensure_one()
|
||||||
|
if printing_auto.action_on_error == "raise":
|
||||||
|
self._do_print_auto(printing_auto)
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
with self.env.cr.savepoint():
|
with self.env.cr.savepoint():
|
||||||
printer, count = printing_auto.do_print(self)
|
self._do_print_auto(printing_auto)
|
||||||
if count:
|
|
||||||
self._on_printing_auto_done(printing_auto, printer, count)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_logger.exception(
|
_logger.exception(
|
||||||
"An error occurred while printing '%s' for record %s.",
|
"An error occurred while printing '%s' for record %s.",
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
domain="[('printer_id', '=', printer_id)]"
|
domain="[('printer_id', '=', printer_id)]"
|
||||||
/>
|
/>
|
||||||
<field name="nbr_of_copies" />
|
<field name="nbr_of_copies" />
|
||||||
|
<field name="action_on_error" />
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
@@ -44,6 +45,7 @@
|
|||||||
<field name="printer_id" />
|
<field name="printer_id" />
|
||||||
<field name="printer_tray_id" />
|
<field name="printer_tray_id" />
|
||||||
<field name="nbr_of_copies" />
|
<field name="nbr_of_copies" />
|
||||||
|
<field name="action_on_error" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
Reference in New Issue
Block a user