11# Copyright 2021 Camptocamp SA
22# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
33
4- from odoo import _ , api , fields , models
4+ from odoo import api , fields , models
55from odoo .exceptions import ValidationError
66from odoo .tools .cache import ormcache
77from odoo .tools .safe_eval import safe_eval
@@ -123,7 +123,7 @@ def _inverse_model_name(self):
123123 def _check_field_in_model (self ):
124124 for opt in self :
125125 if opt .field_id .model_id != opt .model_id :
126- msg = _ (
126+ msg = self . env . _ (
127127 "'%(field_name)s' is not a valid field for model '%(model_name)s'!" ,
128128 field_name = opt .field_name ,
129129 model_name = opt .model_name ,
@@ -134,7 +134,7 @@ def _check_field_in_model(self):
134134 def _check_field_type (self ):
135135 ttypes = ("many2many" , "many2one" )
136136 if any (o .field_id .ttype not in ttypes for o in self ):
137- msg = _ ("Only Many2many and Many2one fields can be chosen!" )
137+ msg = self . env . _ ("Only Many2many and Many2one fields can be chosen!" )
138138 raise ValidationError (msg )
139139
140140 def _apply_options (self , node ):
@@ -145,14 +145,14 @@ def _apply_options(self, node):
145145 options = safe_eval (options , dict (self .env .context or [])) or {}
146146
147147 for k in ("create" , "create_edit" ):
148- opt = self ["option_%s" % k ]
148+ opt = self [f "option_{ k } " ]
149149 if opt == "none" :
150150 continue
151151 mode , val = opt .split ("_" )
152152 if k not in options :
153153 options [k ] = val == "true"
154154 if mode == "force" :
155- options ["no_%s" % k ] = val == "false"
155+ options [f "no_{ k } " ] = val == "false"
156156 if not self .option_create_edit_wizard :
157157 options ["no_quick_create" ] = True
158158 node .set ("options" , str (options ))
0 commit comments