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
@@ -91,7 +91,7 @@ class PrintingLabelZpl2(models.Model):
91
91
@api .constrains ("component_ids" )
92
92
def check_recursion (self ):
93
93
cr = self ._cr
94
- self .flush (["component_ids" ])
94
+ self .flush_recordset (["component_ids" ])
95
95
query = (
96
96
'SELECT "{}", "{}" FROM "{}" '
97
97
'WHERE "{}" IN %s AND "{}" IS NOT NULL' .format (
@@ -115,7 +115,9 @@ def check_recursion(self):
115
115
[id1 ] + list (preds [id1 ]), [id2 ] + list (succs [id2 ])
116
116
):
117
117
if x == y :
118
- raise ValidationError (_ ("You can not create recursive labels." ))
118
+ raise ValidationError (
119
+ self .env ._ ("You can not create recursive labels." )
120
+ )
119
121
succs [x ].add (y )
120
122
preds [y ].add (x )
121
123
if id2 not in done :
@@ -370,7 +372,9 @@ def print_label(self, printer, record, page_count=1, **extra):
370
372
for label in self :
371
373
if record ._name != label .model_id .model :
372
374
raise exceptions .UserError (
373
- _ ("This label cannot be used on {model}" ).format (model = record ._name )
375
+ self .env ._ ("This label cannot be used on {model}" ).format (
376
+ model = record ._name
377
+ )
374
378
)
375
379
# Send the label to printer
376
380
label_contents = label ._generate_zpl2_data (
@@ -385,7 +389,7 @@ def print_label(self, printer, record, page_count=1, **extra):
385
389
def new_action (self , model_id ):
386
390
return self .env ["ir.actions.act_window" ].create (
387
391
{
388
- "name" : _ ("Print Label" ),
392
+ "name" : self . env . _ ("Print Label" ),
389
393
"binding_model_id" : model_id ,
390
394
"res_model" : "wizard.print.record.label" ,
391
395
"view_mode" : "form" ,
@@ -522,9 +526,9 @@ def _generate_labelary_image(self):
522
526
return base64 .b64encode (imgByteArr .getvalue ())
523
527
else :
524
528
_logger .warning (
525
- _ ("Error with Labelary API. %s" ) % response .status_code
529
+ self . env . _ ("Error with Labelary API. %s" ) % response .status_code
526
530
)
527
531
528
532
except Exception as e :
529
- _logger .warning (_ ("Error with Labelary API. %s" ) % e )
533
+ _logger .warning (self . env . _ ("Error with Labelary API. %s" ) % e )
530
534
return False
0 commit comments