mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[IMP] Add a test mode to print a label on write
This commit is contained in:
@@ -49,9 +49,12 @@ class PrintingLabelZpl2(models.Model):
|
||||
default=True)
|
||||
action_window_id = fields.Many2one(
|
||||
comodel_name='ir.actions.act_window', string='Action', readonly=True)
|
||||
test_print_mode = fields.Boolean(string='Mode Print')
|
||||
test_labelary_mode = fields.Boolean(string='Mode Labelary')
|
||||
record_id = fields.Integer(string='Record ID', default=1)
|
||||
extra = fields.Text(string="Extra", default='{}')
|
||||
printer_id = fields.Many2one(
|
||||
comodel_name='printing.printer', string='Printer')
|
||||
labelary_image = fields.Binary(string='Image from Labelary', readonly=True)
|
||||
labelary_dpmm = fields.Selection(
|
||||
selection=[
|
||||
@@ -293,6 +296,14 @@ class PrintingLabelZpl2(models.Model):
|
||||
|
||||
return record
|
||||
|
||||
def print_test_label(self):
|
||||
for label in self:
|
||||
if label.test_print_mode and label.record_id and label.printer_id:
|
||||
record = label._get_record()
|
||||
extra = safe_eval(label.extra, {'env': self.env})
|
||||
if record:
|
||||
label.print_label(label.printer_id, record, **extra)
|
||||
|
||||
@api.onchange(
|
||||
'record_id', 'labelary_dpmm', 'labelary_width', 'labelary_height',
|
||||
'component_ids', 'origin_x', 'origin_y')
|
||||
|
||||
Reference in New Issue
Block a user