refactor: replace odoo.osv.expression with odoo.fields.Domain for domain filtering logic

This commit is contained in:
Suherdy Yacob 2026-06-19 09:40:47 +07:00
parent b5fa919327
commit 52565d3f92

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from odoo import fields, models, api from odoo import fields, models, api
from odoo.osv import expression from odoo.fields import Domain
from datetime import datetime from datetime import datetime
import pytz import pytz
@ -23,7 +23,7 @@ class PosOrder(models.Model):
today_start_utc = today_start_tz.astimezone(pytz.UTC).replace(tzinfo=None) today_start_utc = today_start_tz.astimezone(pytz.UTC).replace(tzinfo=None)
# Restrict domain so only orders from the current day (local timezone start) are returned # Restrict domain so only orders from the current day (local timezone start) are returned
domain = expression.AND([domain, [('date_order', '>=', today_start_utc)]]) domain = Domain.AND([domain, [('date_order', '>=', today_start_utc)]])
return super(PosOrder, self).search_paid_order_ids(config_id, domain, limit, offset) return super(PosOrder, self).search_paid_order_ids(config_id, domain, limit, offset)
@ -61,7 +61,7 @@ class PosOrder(models.Model):
if local_order_ids: if local_order_ids:
# Exclude the empty order(s) already known to the calling device so we # Exclude the empty order(s) already known to the calling device so we
# don't false-positive on an order that this device itself created. # don't false-positive on an order that this device itself created.
domain = expression.AND([domain, [('id', 'not in', local_order_ids)]]) domain = Domain.AND([domain, [('id', 'not in', local_order_ids)]])
orders = self.env['pos.order'].search(domain) orders = self.env['pos.order'].search(domain)