Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0] subscription_oca: error when creating subscription invoice (manually or cron) with "Next Invoice Date" value is empty #1091

Open
cuongnmtm opened this issue Jun 10, 2024 · 0 comments
Labels

Comments

@cuongnmtm
Copy link

Module

subscription_oca

Describe the bug

Error when the Next Invoice Date [recurring_next_date] field value is empty.

To Reproduce

Affected versions: 16.0

Steps to reproduce the behavior:

  1. Create a subscription and set value for fields.
  2. Change the stage to "In progress" by clicking on the status bar. The field "Next Invoice Date" appears.
  3. Empty the value of "Next Invoice Date", the field disappears permanently.
  4. When the subscription cron running or when pressing the button "Create invoice", face the error below:
  File ".../oca-contract/subscription_oca/models/sale_subscription.py", line 219, in calculate_recurring_next_date
    self.recurring_next_date = start_date + relativedelta(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unsupported operand type(s) for +: 'bool' and 'relativedelta'

So there are two issues when the "Next Invoice Date" value is empty:

  1. The field "Next Invoice Date" disappears permanently.
  2. Error when creating subscription invoice (manually or cron).

Another weird behavior:

  • When clicking on the button "Close subscription", a popup appears to input the close reason, then I cancel the popup, and the "Next invoice date" value is emptied. Then the above issue happens.

Expected behavior

  • No error.
  • Either "Next Invoice Date" should not be emptied when the subscription is not closed or a value for "Next Invoice Date" is set automatically to avoid issues.

Additional context

This is how the field is displayed on the view:

<field
    name="recurring_next_date"
    attrs="{'invisible': ['|', ('recurring_next_date', '=', False), ('in_progress', '=', False)]}"
/>

Workaround
Create a new subscription from scratch (duplicate subscription does not help).

@cuongnmtm cuongnmtm added the bug label Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant