1818from slugify import slugify # pylint: disable=missing-manifest-dependency
1919
2020import odoo
21- from odoo import _ , api , fields , models
21+ from odoo import api , fields , models
2222from odoo .exceptions import AccessError , UserError
23- from odoo .osv . expression import AND , OR , normalize_domain
23+ from odoo .fields import Domain
2424
2525from .strtobool import strtobool
2626
@@ -169,9 +169,9 @@ def _store_in_db_instead_of_object_storage_domain(self):
169169 for mimetype_key , limit in storage_config .items ():
170170 part = [("mimetype" , "=like" , f"{ mimetype_key } %" )]
171171 if limit :
172- part = AND ([part , [("file_size" , "<=" , limit )]])
172+ part = Domain . AND ([part , [("file_size" , "<=" , limit )]])
173173 # OR simplifies to [(1, '=', 1)] if a domain being OR'ed is empty
174- domain = OR ([domain , part ]) if domain else part
174+ domain = Domain . OR ([domain , part ]) if domain else part
175175 return domain
176176
177177 def _store_in_db_instead_of_object_storage (self , data , mimetype ):
@@ -306,7 +306,7 @@ def write(self, vals):
306306 vals ["mimetype" ] = mimetypes [0 ]
307307 else :
308308 raise UserError (
309- _ (
309+ self . env . _ (
310310 "You can't write on multiple attachments with different "
311311 "mimetypes at the same time."
312312 )
@@ -723,7 +723,9 @@ def _move_attachment_to_store(self):
723723 @api .model
724724 def force_storage (self ):
725725 if not self .env ["res.users" ].browse (self .env .uid )._is_admin ():
726- raise AccessError (_ ("Only administrators can execute this action." ))
726+ raise AccessError (
727+ self .env ._ ("Only administrators can execute this action." )
728+ )
727729 location = self .env .context .get ("storage_location" ) or self ._storage ()
728730 if location not in self ._get_storage_codes ():
729731 return super ().force_storage ()
@@ -762,9 +764,9 @@ def force_storage_to_db_for_special_fields(
762764 )
763765 return
764766
765- domain = AND (
767+ domain = Domain . AND (
766768 (
767- normalize_domain (
769+ Domain . normalize_domain (
768770 [
769771 ("store_fname" , "=like" , f"{ storage } ://%" ),
770772 # for res_field, see comment in
@@ -774,7 +776,9 @@ def force_storage_to_db_for_special_fields(
774776 ("res_field" , "!=" , False ),
775777 ]
776778 ),
777- normalize_domain (self ._store_in_db_instead_of_object_storage_domain ()),
779+ Domain .normalize_domain (
780+ self ._store_in_db_instead_of_object_storage_domain ()
781+ ),
778782 )
779783 )
780784
0 commit comments