2
2
# Copyright 2023 Tecnativa - Carlos Dauden
3
3
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4
4
5
- from odoo import _ , api , fields , models
5
+ from odoo import api , fields , models
6
6
from odoo .osv import expression
7
7
from odoo .tools import ormcache
8
8
from odoo .tools .safe_eval import datetime , safe_eval
@@ -52,9 +52,7 @@ class IrFilters(models.Model):
52
52
53
53
@api .model
54
54
def _get_default_is_assortment (self ):
55
- if self .env .context .get ("product_assortment" , False ):
56
- return True
57
- return False
55
+ return self .env .context .get ("product_assortment" , False )
58
56
59
57
@api .model
60
58
def _update_assortment_default_values (self , vals_list ):
@@ -83,7 +81,7 @@ def get_partner_domain_fields(self):
83
81
for ir_filter in self .sudo ().search ([("is_assortment" , "=" , True )]):
84
82
domain = ir_filter ._get_eval_partner_domain ()
85
83
for item in domain :
86
- if isinstance (item , ( list , tuple ) ) and isinstance (item [0 ], str ):
84
+ if isinstance (item , list | tuple ) and isinstance (item [0 ], str ):
87
85
field_set .add (item [0 ].split ("." )[0 ])
88
86
return field_set
89
87
@@ -146,13 +144,18 @@ def _compute_record_count(self):
146
144
record .record_count = self .env [record .model_id ].search_count (domain )
147
145
148
146
@api .model
149
- def _get_action_domain (self , action_id = None ):
147
+ def _get_action_domain (
148
+ self , action_id = None , embedded_action_id = None , embedded_parent_res_id = None
149
+ ):
150
150
# tricky way to act on get_filter method to prevent returning
151
151
# assortment in search view filters
152
- domain = super ()._get_action_domain (action_id = action_id )
153
- domain = expression .AND ([[("is_assortment" , "=" , False )], domain ])
152
+ res = super ()._get_action_domain (
153
+ action_id = action_id ,
154
+ embedded_action_id = embedded_action_id ,
155
+ embedded_parent_res_id = embedded_parent_res_id ,
156
+ )
154
157
155
- return domain
158
+ return res + [( "is_assortment" , "=" , False )]
156
159
157
160
def write (self , vals ):
158
161
res = super ().write (vals )
@@ -167,7 +170,7 @@ def show_products(self):
167
170
action .update (
168
171
{
169
172
"domain" : self ._get_eval_domain (),
170
- "name" : _ ("Products" ),
173
+ "name" : self . env . _ ("Products" ),
171
174
"context" : self .env .context ,
172
175
"target" : "current" ,
173
176
}
0 commit comments