Skip to Content
मेन्यू
This question has been flagged

I want to sell access to my online course by subscription, and I want the student to have access to the course only when their subscription is active. I want the access to be revoked if the subscription is closed or canceled.

This seems to be a pretty basic functionnality regarding an eLearning platform, but I've looked up for tutorials, and it's not a native Odoo functionnality. I've asked Deepseek how to manage that, and it seems that I need Odoo Studio to customize (details below).

How to submit this functionnality to be included in a future update?

______________________________

In Odoo, by default, when a subscription ends, the client’s access to the course linked to that subscription is not automatically revoked. Odoo does not natively handle the automatic revocation of course access based on subscription status. However, you can configure this behavior using custom development or automated actions. Here’s a detailed explanation of what happens by default and how you can manage course access when a subscription ends:

1. Default Behavior in Odoo

  • Subscription Ends: When a subscription ends, Odoo marks it as expired or canceled, but it does not automatically revoke access to the course.
  • Course Access: The client retains access to the course unless you manually revoke it or implement a custom solution.

2. Why This Happens

  • Odoo’s Subscription and eLearning modules are not tightly integrated by default.
  • There is no native functionality to automatically link subscription status to course access.

3. How to Automatically Revoke Course Access When a Subscription Ends

To automatically revoke course access when a subscription ends, you can use one of the following approaches:

a. Automated Actions

  1. Create an Automated Action:
    • Go to Settings > Technical > Automation > Automated Actions.
    • Create a new automated action triggered when a subscription is expired or canceled.
  2. Update Course Access:
    • Use the automated action to update the client’s access to the course.
    • Example: Set a custom field (e.g., has_access) to False when the subscription ends.
  3. Restrict Access:
    • Use Record Rules to restrict access to the course based on the has_access field.

b. Custom Development

  1. Create a Custom Field:
    • Add a custom field (e.g., subscription_active) to the res.partner model to track subscription status.
  2. Update Subscription Status:
    • Use a custom module or script to update the subscription_active field when a subscription ends.
  3. Restrict Course Access:
    • Override the access logic for the course to check the subscription_active field.
    • Example: If subscription_active is False, deny access to the course.

c. Odoo Studio (Custom Edition Only)

If you’re using the Custom Edition (29.9 €/month), you can use Odoo Studio to create a custom workflow that links subscription status to course access.

4. Example Workflow

Here’s an example of how you can implement this functionality:

  1. Create a Custom Field:
    • Add a custom field (e.g., subscription_active) to the res.partner model.
  2. Automate Subscription Status Updates:
    • Use an automated action to update the subscription_active field when a subscription ends.
    • Example:
      python
      Copy
      from odoo import models, fields
      
      class Subscription(models.Model):
          _inherit = 'sale.subscription'
      
          def update_subscription_status(self):
              for subscription in self:
                  partner = subscription.partner_id
                  if subscription.state in ['closed', 'canceled']:
                      partner.write({'subscription_active': False})
  3. Restrict Course Access:
    • Use a record rule to restrict access to the course based on the subscription_active field.
    • Example:
      xml
      Copy
      <record id="restrict_course_access" model="ir.rule">
          <field name="name">Restrict Course Access</field>
          <field name="model_id" ref="model_slide_channel"/>
          <field name="domain_force">[('subscription_active', '=', True)]</field>
          <field name="groups" eval="[(4, ref('base.group_user'))]"/>
      </record>
      Run HTML

5. Notify the Client

  • Use Email Templates to notify the client when their subscription ends and their course access is revoked.
  • Example: Send an email when the subscription_active field is set to False.

6. Testing

  • Test the setup by creating a subscription, linking it to a course, and verifying access is revoked when the subscription ends.

Conclusion

By default, Odoo does not automatically revoke course access when a subscription ends. However, you can implement this functionality using automated actionscustom development, or Odoo Studio (if you’re using the Custom Edition). If you need assistance, consider hiring an Odoo developer to create a custom solution tailored to your needs.

Avatar
Discard
Related Posts Replies Views Activity
0
मार्च 25
862
0
मार्च 25
894
1
जुल॰ 25
1813
2
अक्तू॰ 24
884
1
मार्च 25
832