Python Formula for Dynamic Prices in Subscriptions
by CLuedoo https://www.cluedoo.com/shop/licclusetsal0052-python-formula-for-dynamic-prices-in-subscriptions-7250$ 350.01
In-App Purchases| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
•
Subscriptions (sale_subscription)
• Discuss (mail) • Invoicing (account) • Sales (sale_management) |
| Community Apps Dependencies | Show |
| Lines of code | 588 |
| Technical Name |
cds_dynamic_price_subscription |
| License | OPL-1 |
| Website | https://www.cluedoo.com/shop/licclusetsal0052-python-formula-for-dynamic-prices-in-subscriptions-7250 |
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
•
Subscriptions (sale_subscription)
• Discuss (mail) • Invoicing (account) • Sales (sale_management) |
| Community Apps Dependencies | Show |
| Lines of code | 588 |
| Technical Name |
cds_dynamic_price_subscription |
| License | OPL-1 |
| Website | https://www.cluedoo.com/shop/licclusetsal0052-python-formula-for-dynamic-prices-in-subscriptions-7250 |
ODOO'S FUNCTION
By default, Odoo supports subscription pricing through pricelists with fixed prices, percentage discounts, or basic formula-based rules. However, it does not support custom pricing logic or automatic price updates.CLUEDOO'S FUNCTION
CLuedoo extends Odoo's subscription pricing by allowing Python formulas to be defined directly in pricelists. This enables automatic price recomputation at the end of each billing period - ensuring subscription prices always reflect the latest formula without any manual intervention.
CONFIGURATION |
|
|
1. Go to Subscriptions > Products > Pricelists , open or create a pricelist > Under the Recurring Prices tab, add a line to open Recurring Pricing and select Python Formula as the Price Type, then write your formula in the script box.
Example:
result = 320 means the unit price will be $320 for every billing period.
|
|
|
2. Go to Subscriptions > Configuration > Recurring Plans > Open or create a new one > Enable Auto Update Price (Formula) checkbox. If checked, the system will automatically recalculate the price based on the python formula at the end of the current billing period. |
|
USAGE |
|
|
1. Create a new Subscriptions Order using the recurring plan and pricelist you just configured > The formula is automatically inherited by each Order Line At this point, the unit price still shows the original value. The formula is ready but not yet applied. |
Before using Calculate Price button
|
|
2.
Hit the Calculate Price button at the top of the Subscriptions > The system instantly recomputes the unit price for all lines based on their formula > Confirm the order |
After using Calculate Price button |
|
3. Change the Python Formula
For example, I change the formula from result = 320 to result = 444 |
|
|
4. The system runs a daily scheduled action - "Subscription: Auto Update Price on Anniversary" - that automatically triggers Calculate Price for all subscriptions whose current billing period ends today. You can also trigger it manually anytime via the Run Manually button.
|
|
|
5. Back to the Subscription Order, once the price has been recalculated, a notification appears in the subscription's chatter: |
|
|
The Order Line is updated accordingly with the new unit price. Notes:
|
|
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module