def _search_abandoned_cart(self, operator, value): abandoned_delay = self.website_id and self.website_id.cart_abandoned_delay or 1.0 abandoned_datetime = fields.Datetime.to_string(datetime.utcnow() - relativedelta(hours=abandoned_delay)) abandoned_domain = expression.normalize_domain([ ('date_order', '<=', abandoned_datetime), ('website_id', '!=', False), ('state', '=', 'draft'), ('partner_id', '!=', self.env.ref('base.public_partner').id), ('order_line', '!=', False) ]) # is_abandoned domain possibilities if (operator not in expression.NEGATIVE_TERM_OPERATORS and value) or (operator in expression.NEGATIVE_TERM_OPERATORS and not value): return abandoned_domain return expression.distribute_not(['!'] + abandoned_domain) # negative domain
def _search_abandoned_cart(self, operator, value): abandoned_delay = float(self.env['ir.config_parameter'].sudo().get_param('website_sale.cart_abandoned_delay', '1.0')) abandoned_datetime = fields.Datetime.to_string(datetime.utcnow() - relativedelta(hours=abandoned_delay)) abandoned_domain = expression.normalize_domain([ ('date_order', '<=', abandoned_datetime), ('team_id.team_type', '=', 'website'), ('state', '=', 'draft'), ('partner_id.id', '!=', self.env.ref('base.public_partner').id), ('order_line', '!=', False) ]) # is_abandoned domain possibilities if (operator not in expression.NEGATIVE_TERM_OPERATORS and value) or (operator in expression.NEGATIVE_TERM_OPERATORS and not value): return abandoned_domain return expression.distribute_not(abandoned_domain) # negative domain