10
10
import requests
11
11
from PIL import Image , ImageOps
12
12
13
- from odoo import _ , api , exceptions , fields , models
13
+ from odoo import api , exceptions , fields , models
14
14
from odoo .exceptions import ValidationError
15
15
from odoo .tools .safe_eval import safe_eval , wrap_module
16
16
@@ -64,7 +64,6 @@ class PrintingLabelZpl2(models.Model):
64
64
action_window_id = fields .Many2one (
65
65
comodel_name = "ir.actions.act_window" ,
66
66
string = "Action" ,
67
- readonly = True ,
68
67
)
69
68
test_print_mode = fields .Boolean (string = "Mode Print" )
70
69
test_labelary_mode = fields .Boolean (string = "Mode Labelary" )
@@ -115,7 +114,9 @@ def check_recursion(self):
115
114
[id1 ] + list (preds [id1 ]), [id2 ] + list (succs [id2 ])
116
115
):
117
116
if x == y :
118
- raise ValidationError (_ ("You can not create recursive labels." ))
117
+ raise ValidationError (
118
+ self .env ._ ("You can not create recursive labels." )
119
+ )
119
120
succs [x ].add (y )
120
121
preds [y ].add (x )
121
122
if id2 not in done :
@@ -370,7 +371,9 @@ def print_label(self, printer, record, page_count=1, **extra):
370
371
for label in self :
371
372
if record ._name != label .model_id .model :
372
373
raise exceptions .UserError (
373
- _ ("This label cannot be used on {model}" ).format (model = record ._name )
374
+ self .env ._ ("This label cannot be used on {model}" ).format (
375
+ model = record ._name
376
+ )
374
377
)
375
378
# Send the label to printer
376
379
label_contents = label ._generate_zpl2_data (
@@ -385,7 +388,7 @@ def print_label(self, printer, record, page_count=1, **extra):
385
388
def new_action (self , model_id ):
386
389
return self .env ["ir.actions.act_window" ].create (
387
390
{
388
- "name" : _ ("Print Label" ),
391
+ "name" : self . env . _ ("Print Label" ),
389
392
"binding_model_id" : model_id ,
390
393
"res_model" : "wizard.print.record.label" ,
391
394
"view_mode" : "form" ,
@@ -522,9 +525,9 @@ def _generate_labelary_image(self):
522
525
return base64 .b64encode (imgByteArr .getvalue ())
523
526
else :
524
527
_logger .warning (
525
- _ ("Error with Labelary API. %s" ) % response .status_code
528
+ self . env . _ ("Error with Labelary API. %s" ) % response .status_code
526
529
)
527
530
528
531
except Exception as e :
529
- _logger .warning (_ ("Error with Labelary API. %s" ) % e )
532
+ _logger .warning (self . env . _ ("Error with Labelary API. %s" ) % e )
530
533
return False
0 commit comments