Link loyalty programs to order lines

sale_loyalty_order_line_link
REPOSITORY
REPOSITORYOCA/sale-promotion
GIT
GIThttps://github.com/OCA/sale-promotion.git
GIT FOLDER
GIT FOLDERhttps://github.com/OCA/sale-promotion/tree/18.0/sale_loyalty_order_line_link
VERSION
VERSION 1.0.0
CATEGORY
CATEGORYSale
LICENSE
LICENSEAGPL-3
APPLICATION
APPLICATIONNo
AUTO-INSTALLABLE
AUTO-INSTALLABLENo
AUTHORS
AUTHORSTecnativa, Odoo Community Association (OCA)
MAINTAINERS
MAINTAINERSTecnativa, Odoo Community Association (OCA)
COMMITTERS
COMMITTERSOCA-git-bot, oca-ci, Bhavesh Heliconia
WEBSITE
WEBSITEhttps://github.com/OCA/sale-promotion
LAST TRACKING UPDATE
LAST TRACKING UPDATE2026-07-06 19:30:08
ODOO DEPENDENCIES
ODOO DEPENDENCIES odoo/odoo:
    - sale_loyalty
    - sale
    - sales_team
    - base
    - mail
    - base_setup
    - web
    - bus
    - web_tour
    - html_editor
    - account_payment
    - account
    - onboarding
    - product
    - uom
    - analytic
    - portal
    - web_editor
    - http_routing
    - auth_signup
    - digest
    - resource
    - payment
    - utm
    - loyalty
PYTHON DEPENDENCIES
PYTHON DEPENDENCIES Not have
SYSTEM DEPENDENCIES
SYSTEM DEPENDENCIES Not have
DESCRIPTION
DESCRIPTION
This module adds a link in the sale order line to the program used in a
discount, so it can be easily tracked afterwards. Also eases the
implementation of loyalty modules that don't necessarily use the
discount product as product for the discount line.

It also links the reward lines to:  
- The order lines that generated them, so we can follow which order
  lines produced which discounts.
- The order lines over which the reward is applied:
  - In a discount promo: the cheapest product, specific products or the
    whole order.
  - In a product promo: the product lines over which the reward is
    discounted.

Additionally, this module adds a button in the loyalty program form view to open related sale orders.

Code Analysis

Views touched (4)
XML IDNameModelTypeStatus
loyalty_program_view_form_inherit loyalty.program.form.inherit loyalty.program xpath Inherits loyalty.loyalty_program_view_form
view_order_form sale.order xpath Inherits sale.view_order_form
view_order_line_tree sale.order.line field Inherits sale.view_order_line_tree
view_order_product_search sale.report field Inherits sale.view_order_product_search
Models touched (4)

New fields (1)
  • related_so_count Integer
    compute='_compute_related_so_count'
Public methods (1)
  • action_open_related_sale_orders(self)

New fields (0)

No new fields.

Public methods (1)
  • write(self, vals)
    We're looking for reward lines set in the write, from those, we'll get the proper ids to write them into the related lines

New fields (4)
  • loyalty_program_id Many2one
    related='reward_id.program_id' store=True string='Loyalty Program'
  • reward_generated_line_ids Many2many → sale.order.line
    column1='sale_line_id' column2='reward_generated_line_id' comodel_name='sale.order.line' help='Link on the reward lines generated meeting this line as criteria' relation='sale_line_reward_generated_line_rel' string='Reward Generated lines'
  • reward_line_ids Many2many → sale.order.line
    column1='sale_line_id' column2='reward_line_id' comodel_name='sale.order.line' help='Link on the reward lines applied from this one' relation='sale_line_reward_line_rel' string='Reward lines'
  • reward_origin_generated_line_ids Many2many → sale.order.line
    column1='reward_generated_line_id' column2='sale_line_id' comodel_name='sale.order.line' help='Origin Link on the reward lines generated meeting this line as criteria' relation='sale_line_reward_generated_line_rel' string='Origin Reward Generated lines'
Public methods (1)
  • write(self, vals)
    When the reward line is update we should refresh the line links as well

New fields (1)
  • loyalty_program_id Many2one → loyalty.program
    comodel_name='loyalty.program' string='Loyalty Program'
Public methods (0)

No public methods.

REPOSITORY
REPOSITORYOCA/sale-promotion
GIT
GIThttps://github.com/OCA/sale-promotion.git
GIT FOLDER
GIT FOLDERhttps://github.com/OCA/sale-promotion/tree/17.0/sale_loyalty_order_line_link
VERSION
VERSION 1.0.0
CATEGORY
CATEGORYSale
LICENSE
LICENSEAGPL-3
APPLICATION
APPLICATIONNo
AUTO-INSTALLABLE
AUTO-INSTALLABLENo
AUTHORS
AUTHORSTecnativa, Odoo Community Association (OCA)
MAINTAINERS
MAINTAINERSTecnativa, Odoo Community Association (OCA)
COMMITTERS
COMMITTERSOCA-git-bot, oca-ci, arantxa-s73
WEBSITE
WEBSITEhttps://github.com/OCA/sale-promotion
LAST TRACKING UPDATE
LAST TRACKING UPDATE2026-07-06 19:20:02
ODOO DEPENDENCIES
ODOO DEPENDENCIES odoo/odoo:
    - sale_loyalty
    - sale
    - sales_team
    - base
    - mail
    - base_setup
    - web
    - bus
    - web_tour
    - account_payment
    - account
    - onboarding
    - product
    - uom
    - analytic
    - portal
    - web_editor
    - http_routing
    - auth_signup
    - digest
    - resource
    - payment
    - utm
    - loyalty
PYTHON DEPENDENCIES
PYTHON DEPENDENCIES Not have
SYSTEM DEPENDENCIES
SYSTEM DEPENDENCIES Not have
DESCRIPTION
DESCRIPTION
This module adds a link in the sale order line to the program used in a
discount, so it can be easily tracked afterwards. Also eases the
implementation of loyalty modules that don't necessarily use the
discount product as product for the discount line.

It also links the reward lines to:  
- The order lines that generated them, so we can follow which order
  lines produced which discounts.
- The order lines over which the reward is applied:
  - In a discount promo: the cheapest product, specific products or the
    whole order.
  - In a product promo: the product lines over which the reward is
    discounted.

Code Analysis

Views touched (3)
XML IDNameModelTypeStatus
view_order_form sale.order xpath Inherits sale.view_order_form
view_order_line_tree sale.order.line field Inherits sale.view_order_line_tree
view_order_product_search sale.report field Inherits sale.view_order_product_search
Models touched (3)

New fields (0)

No new fields.

Public methods (1)
  • write(self, vals)
    We're looking for reward lines set in the write, from those, we'll get the proper ids to write them into the related lines

New fields (4)
  • loyalty_program_id Many2one
    related='reward_id.program_id' store=True string='Loyalty Program'
  • reward_generated_line_ids Many2many → sale.order.line
    column1='sale_line_id' column2='reward_generated_line_id' comodel_name='sale.order.line' help='Link on the reward lines generated meeting this line as criteria' relation='sale_line_reward_generated_line_rel' string='Reward Generated lines'
  • reward_line_ids Many2many → sale.order.line
    column1='sale_line_id' column2='reward_line_id' comodel_name='sale.order.line' help='Link on the reward lines applied from this one' relation='sale_line_reward_line_rel' string='Reward lines'
  • reward_origin_generated_line_ids Many2many → sale.order.line
    column1='reward_generated_line_id' column2='sale_line_id' comodel_name='sale.order.line' help='Origin Link on the reward lines generated meeting this line as criteria' relation='sale_line_reward_generated_line_rel' string='Origin Reward Generated lines'
Public methods (1)
  • write(self, vals)
    When the reward line is update we should refresh the line links as well

New fields (1)
  • loyalty_program_id Many2one → loyalty.program
    comodel_name='loyalty.program' string='Loyalty Program'
Public methods (0)

No public methods.

REPOSITORY
REPOSITORYOCA/sale-promotion
GIT
GIThttps://github.com/OCA/sale-promotion.git
GIT FOLDER
GIT FOLDERhttps://github.com/OCA/sale-promotion/tree/16.0/sale_loyalty_order_line_link
VERSION
VERSION 1.1.0
CATEGORY
CATEGORYSale
LICENSE
LICENSEAGPL-3
APPLICATION
APPLICATIONNo
AUTO-INSTALLABLE
AUTO-INSTALLABLENo
AUTHORS
AUTHORSTecnativa, Odoo Community Association (OCA)
MAINTAINERS
MAINTAINERSTecnativa, Odoo Community Association (OCA)
COMMITTERS
COMMITTERSWeblate, OCA-git-bot, oca-ci, pilarvargas-tecnativa, Duy (Đỗ Anh)
WEBSITE
WEBSITEhttps://github.com/OCA/sale-promotion
LAST TRACKING UPDATE
LAST TRACKING UPDATE2026-07-06 00:53:41
ODOO DEPENDENCIES
ODOO DEPENDENCIES odoo/odoo:
    - sale_loyalty
    - sale
    - sales_team
    - base
    - mail
    - base_setup
    - web
    - bus
    - web_tour
    - account_payment
    - account
    - product
    - uom
    - analytic
    - portal
    - web_editor
    - http_routing
    - auth_signup
    - digest
    - resource
    - payment
    - utm
    - loyalty
PYTHON DEPENDENCIES
PYTHON DEPENDENCIES Not have
SYSTEM DEPENDENCIES
SYSTEM DEPENDENCIES Not have
DESCRIPTION
DESCRIPTION

Code Analysis

Views touched (4)
XML IDNameModelTypeStatus
loyalty_program_view_form_inherit loyalty.program.form.inherit loyalty.program xpath Inherits loyalty.loyalty_program_view_form
view_order_form sale.order xpath Inherits sale.view_order_form
view_order_line_tree sale.order.line field Inherits sale.view_order_line_tree
view_order_product_search sale.report field Inherits sale.view_order_product_search
Models touched (4)

New fields (1)
  • related_so_count Integer
    compute='_compute_related_so_count'
Public methods (1)
  • action_open_related_sale_orders(self)

New fields (0)

No new fields.

Public methods (1)
  • write(self, vals)
    We're looking for reward lines set in the write, from those, we'll get the proper ids to write them into the related lines

New fields (4)
  • loyalty_program_id Many2one
    related='reward_id.program_id' store=True string='Loyalty Program'
  • reward_generated_line_ids Many2many → sale.order.line
    column1='sale_line_id' column2='reward_generated_line_id' comodel_name='sale.order.line' help='Link on the reward lines generated meeting this line as criteria' relation='sale_line_reward_generated_line_rel' string='Reward Generated lines'
  • reward_line_ids Many2many → sale.order.line
    column1='sale_line_id' column2='reward_line_id' comodel_name='sale.order.line' help='Link on the reward lines applied from this one' relation='sale_line_reward_line_rel' string='Reward lines'
  • reward_origin_generated_line_ids Many2many → sale.order.line
    column1='reward_generated_line_id' column2='sale_line_id' comodel_name='sale.order.line' help='Origin Link on the reward lines generated meeting this line as criteria' relation='sale_line_reward_generated_line_rel' string='Origin Reward Generated lines'
Public methods (1)
  • write(self, vals)
    When the reward line is update we should refresh the line links as well

New fields (1)
  • loyalty_program_id Many2one → loyalty.program
    comodel_name='loyalty.program' string='Loyalty Program'
Public methods (0)

No public methods.

STATUS
STATUSOpen migration PR - not merged yet for this version
REPOSITORY
REPOSITORYOCA/sale-promotion
PULL REQUEST
PULL REQUEST[19.0][MIG] sale_loyalty_order_line_link: Migration to 19.0 (#328)