Sale Promotion Rule
sale_promotion_rule · OCA/sale-workflow
-
Security25/25No findings
-
Activity6/25Last human commit 29 months ago
-
Required by5/250 modules depend on it
-
Maturity25/25In 4 Odoo series since 10.0
Heuristic over the facts below, not an audit · How it's computed
Migration considerations
SalePromotionRule— Migrating to 19.0: `_sql_constraints` is ignored and its constraints are silently not created: declare `models.Constraint` attributes instead. migration-sql-constraints · sourceSalePromotionRule— Since 17.0: `name_get` no longer feeds `display_name`: override `_compute_display_name` instead. migration-name-get · sourceview_sale_order_applied_sale_promotion_rule_tree— Migrating to 18.0: the `tree` view type was renamed to `list` (`<list>` roots, `view_mode`). migration-view-tree-tag · sourceview_sale_promotion_rule_tree— Migrating to 18.0: the `tree` view type was renamed to `list` (`<list>` roots, `view_mode`). migration-view-tree-tag · source
Migration review checklist, not a compatibility verdict. "Migrating to X.0" applies once you upgrade to that version; "Since X.0" means this version already ignores or rejects that code. Methodology
Description
This module adds the concept of promotion rules that can be applied on the sale order.
Two kinds of rules are implemented:
- automatic
- coupon
Automatic rules are applied/recomputed automatically for a sale order when the user clicks on the button "Apply discount" in the view form. Depending on the rule's criteria more than one automatic rule can be applied to a same sale order.
Coupon are special manual rules. Only one coupon can be applied to a sale order. This rule takes always precedence over automatic rules.

Dependencies
Code analysis
Extracted from the source by best-effort static analysis (no code is executed); details may be incomplete.
Views touched 5
| XML ID | Name | Model | Type | Status |
|---|---|---|---|---|
sale_order_add_coupon_form_view |
sale.order.add.coupon.form (in sale_promotion_rule) | sale.order.add.coupon | form | New |
view_order_form |
sale.order | form | Inherits sale.view_order_form | |
view_sale_order_applied_sale_promotion_rule_tree |
sale.promotion.rule | tree | New | |
view_sale_promotion_rule_form |
sale.promotion.rule | form | New | |
view_sale_promotion_rule_tree |
sale.promotion.rule | tree | New |
HTTP endpoints 0
No HTTP endpoints found for this module.
Models touched 4
-
applied_promotion_rule_idsMany2many → sale.promotion.rulecompute='_compute_applied_promotion_rule_ids'string='Applied Promotion rules' args: 'sale.promotion.rule' -
coupon_codeCharreadonly=Truerelated='coupon_promotion_rule_id.code'store=Truestring='Coupont Promotion Code' -
coupon_promotion_rule_idMany2one → sale.promotion.ruledomain=[('rule_type', '=', 'coupon')]index=Truereadonly=Truestring='Coupon promotion rule' args: 'sale.promotion.rule' -
has_promotion_rulesBooleancompute='_compute_has_promotion_rules' -
promotion_rule_idsMany2many → sale.promotion.ruledomain=[('rule_type', '!=', 'coupon')]index=Truereadonly=Truestring='Promotion rules' args: 'sale.promotion.rule'
-
add_coupon(self, coupon_code) -
apply_promotions(self) -
clear_promotions(self)
-
nameCharrequired=Truestring='Coupon Name'
-
doit(self)
-
applied_promotion_rule_idsMany2many → sale.promotion.rulecompute='_compute_applied_promotion_rule_ids'string='Applied Promotion rules' args: 'sale.promotion.rule' -
coupon_codeCharreadonly=Truerelated='coupon_promotion_rule_id.code'store=True -
coupon_promotion_rule_idMany2one → sale.promotion.ruledomain=[('rule_type', '=', 'coupon')]string='Coupon promotion rule' args: 'sale.promotion.rule' -
has_promotion_rulesBooleancompute='_compute_has_promotion_rules' -
is_promotion_lineBooleanhelp='True if the line has been added by a promotion rule' -
promotion_rule_idsMany2many → sale.promotion.ruledomain=[('rule_type', '!=', 'coupon')]string='Promotion rules' args: 'sale.promotion.rule'
No public methods.
-
codeChar -
company_idMany2one → res.companycomodel_name='res.company'help='Define on which company this promotion rule is available (let it empty if available for every companies)'index=Truestring='Company' -
date_fromDate -
date_toDate -
discount_amountFloatdigits='Discount'required=True -
discount_amount_currency_idMany2one → res.currencydefault=<expr>string='Discount Amount Currency' args: 'res.currency' -
discount_product_idMany2one → product.productdomain=[('type', '=', 'service')]string='Product used to apply the promotion' args: 'product.product' -
discount_typeSelectiondefault='percentage'required=Trueselection=[('percentage', 'Percentage'), ('amount_tax_included', 'Amount (Taxes included)'), ('amount_tax_excluded', 'Amount (Taxes excluded)')] -
is_minimal_amount_tax_inclBooleandefault=Truerequired=True args: 'Tax included into minimal amount?' -
minimal_amountFloatdigits='Discount' -
multi_rule_strategySelectiondefault='use_best'selection=[('use_best', 'Use the best promotion'), ('cumulate', 'Cumulate promotion'), ('exclusive', 'Exclusive promotion'), ('keep_existing', 'Keep existing discount')] -
nameCharrequired=Truetranslate=True -
only_newsletterBoolean -
promo_typeSelectiondefault='discount'required=Trueselection=[('discount', 'Discount')] -
restrict_partner_idsMany2many → res.partnercolumn1='rule_id'column2='partner_id'comodel_name='res.partner'relation='discount_rule_partner_rel'string='Restricted partners' -
restrict_pricelist_idsMany2many → product.pricelistcolumn1='rule_id'column2='pricelist_id'comodel_name='product.pricelist'relation='discount_rule_pricelist_rel'string='Restricted pricelists' -
rule_typeSelectiondefault='coupon'required=Trueselection=[('coupon', 'Coupon'), ('auto', 'Automatic')] -
sequenceIntegerdefault=10 -
usage_restrictionSelectiondefault='no_restriction'required=Trueselection=[('one_per_partner', 'One per partner'), ('no_restriction', 'No restriction')]
-
apply_auto(self, orders)@api.modelApply automatic promotion rules to the orders -
apply_coupon(self, orders, coupon_code)Add a coupon to orders -
compute_promotions(self, orders)@api.modelCompute available promotions on the given orders. If a coupon is already defined on the orders, it's preserved -
name_get(self) -
remove_promotions(self, orders)@api.model
Loading…
Loading…
Loading…