refactor: replace deprecated odoo.osv.expression with odoo.fields.Domain for search queries
This commit is contained in:
parent
b5d7fa0ecc
commit
43d494fbc4
@ -1,6 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
from odoo import api, fields, models, _
|
from odoo import api, fields, models, _
|
||||||
from odoo.osv import expression
|
from odoo.fields import Domain
|
||||||
from odoo.tools.float_utils import float_is_zero
|
from odoo.tools.float_utils import float_is_zero
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
@ -84,7 +84,7 @@ class StockLot(models.Model):
|
|||||||
quant_domain.append(('product_id', '=', ctx.get('default_product_id')))
|
quant_domain.append(('product_id', '=', ctx.get('default_product_id')))
|
||||||
|
|
||||||
quants = self.env['stock.quant'].with_context(skip_location_restriction=True).sudo().search(quant_domain)
|
quants = self.env['stock.quant'].with_context(skip_location_restriction=True).sudo().search(quant_domain)
|
||||||
domain = expression.AND([domain or [], [('id', 'in', quants.mapped('lot_id').ids)]])
|
domain = Domain.AND([domain or [], [('id', 'in', quants.mapped('lot_id').ids)]])
|
||||||
|
|
||||||
# Use positional/keyword pass-through to match V19 BaseModel
|
# Use positional/keyword pass-through to match V19 BaseModel
|
||||||
return super().name_search(name=name, domain=domain, operator=operator, limit=limit)
|
return super().name_search(name=name, domain=domain, operator=operator, limit=limit)
|
||||||
@ -101,5 +101,5 @@ class StockLot(models.Model):
|
|||||||
quant_domain.append(('product_id', '=', ctx.get('default_product_id')))
|
quant_domain.append(('product_id', '=', ctx.get('default_product_id')))
|
||||||
|
|
||||||
quants = self.env['stock.quant'].with_context(skip_location_restriction=True).sudo().search(quant_domain)
|
quants = self.env['stock.quant'].with_context(skip_location_restriction=True).sudo().search(quant_domain)
|
||||||
domain = expression.AND([domain, [('id', 'in', quants.mapped('lot_id').ids)]])
|
domain = Domain.AND([domain, [('id', 'in', quants.mapped('lot_id').ids)]])
|
||||||
return super().web_search_read(domain, specification, offset=offset, limit=limit, order=order, count_limit=count_limit)
|
return super().web_search_read(domain, specification, offset=offset, limit=limit, order=order, count_limit=count_limit)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user