[MIG] printer_zpl2: Migration to 12.0

This commit is contained in:
Florent de Labarre
2019-03-20 14:24:37 +01:00
committed by Nils Hamerlinck
parent 7b647116e5
commit 84a14641de
11 changed files with 52 additions and 24 deletions

View File

@@ -42,7 +42,7 @@ class PrintingLabelZpl2(models.Model):
component_ids = fields.One2many(
comodel_name='printing.label.zpl2.component', inverse_name='label_id',
string='Label Components',
help='Components which will be printed on the label.')
help='Components which will be printed on the label.', copy=True)
restore_saved_config = fields.Boolean(
string="Restore printer's configuration",
help="Restore printer's saved configuration and end of each label ",
@@ -85,6 +85,9 @@ class PrintingLabelZpl2(models.Model):
})
data = safe_eval(component.data, eval_args) or ''
if data == 'component_not_show':
continue
# Generate a list of elements if the component is repeatable
for idx in range(
component.repeat_offset,
@@ -151,9 +154,14 @@ class PrintingLabelZpl2(models.Model):
component.diagonal_orientation,
})
elif component.component_type == 'graphic':
image = component.graphic_image or data
pil_image = Image.open(io.BytesIO(
base64.b64decode(image))).convert('RGB')
# During the on_change don't take the bin_size
image = component.with_context(bin_size_graphic_image=False)\
.graphic_image or data
try:
pil_image = Image.open(io.BytesIO(
base64.b64decode(image))).convert('RGB')
except Exception:
continue
if component.width and component.height:
pil_image = pil_image.resize(
(component.width, component.height))
@@ -292,7 +300,7 @@ class PrintingLabelZpl2(models.Model):
record = Obj.search([('id', '=', self.record_id)], limit=1)
if not record:
record = Obj.search([], limit=1, order='id desc')
self.record_id = record.id
self.record_id = record.id
return record