Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Sale Loyalty

Entity: loyalty.program

Compute Method: _compute_order_count

Inputs Method Outputs
  • reward_ids
  • reward_ids.ids
read_group_res = self.env['sale.order.line']._read_group(
            [('reward_id', 'in', self.reward_ids.ids)], ['order_id'], ['reward_id:array_agg'])
for program in self:
            program_reward_ids = program.reward_ids.ids
            program.order_count = sum(
                any(id_ in reward_ids for id_ in program_reward_ids)
                for __, reward_ids in read_group_res
            )

Back to entity