Post-processing

Konfoo supports post-processing the output of the aggregator ruleset with predefined algorithms.

Example:

options:
    name: Example Bill of Materials
    path: bom

# Sum identical aggregator items
process:
    - operation: sum_identical
      params:
          - product_qty

rules:
    - example_rule1:
        domain: Example
        model: mrp.bom.line
        require:
            - self.product_id # let `product_id` be 1234
            - self.qty_field  # let `qty_field` be 2
        product_id: (expr) self.product_id
        product_qty: (expr) self.qty_field
        product_uom_id: Units

    - example_rule2:
        domain: Example
        model: mrp.bom.line
        require:
            - self.product_id
            - self.qty_field
        product_id: (expr) self.product_id
        product_qty: (expr) self.qty_field
        product_uom_id: Units

This will result in a rule output of:

{
    "__id__": "summed-0", // This is generated automatically
    "__instance__": "01GW9C7YEHP4YYEXAMPLEVALUE",
    "domain": "Example",
    "model": "mrp.bom.line",
    "product_id": 1234,
    "product_qty": 4, // 2 * self.qty_field
    "product_uom_id": "Units"
}

Supported post-processing operations

sum_identical

Will sum the fields listed in params of any output items (rules) that are otherwise identical. The fields listed in params and internal fields like __id__ and __instance__ are exempt from the equality test of output items.

NOTE: only fields with values that are convertible to floating point numbers can be summed.

strip_zero

Will remove any rule outputs that have a value of 0 on any of the fields given in params (logical OR). This handles both integer and floating point values.