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

[15.0] sale_invoice_plan: Cannot edit or add sale line after invoices are generated #2950

Open
hussain opened this issue Feb 12, 2024 · 0 comments
Labels

Comments

@hussain
Copy link

hussain commented Feb 12, 2024

Module

sale_invoice_plan

Describe the bug

Error when editing or adding new line in sale order if invoices are generated from invoice plan.

To Reproduce

Affected versions: 15.0, and not sure if other versions have same issue.

Steps to reproduce the behavior:

  1. Create a sale order with 1 line item.
  2. Create invoice plan.
  3. Confirm sale order.
  4. Generate all invoices using button "Create invoice by Plan" and create all invoices.
  5. Edit the description of sale order line, or add new line in sale order.

Expected behavior
Edit should of description of line of sale order should be possible.
Adding new line to sale order should be possible.

Error message

  File "/sale_invoice_plan/models/sale_invoice_plan.py", line 100, in _compute_amount
    rec.percent = rec.amount / rec.sale_id.amount_untaxed * 100
....
ZeroDivisionError: float division by zero

Potential solution
in _compute_amount here, code could be:

    @api.depends("percent")
    def _compute_amount(self):
        for rec in self:
            # With invoice already created, no recompute
            if rec.invoiced:
                #rec.amount = rec.amount_invoiced
                #rec.percent = rec.amount / rec.sale_id.amount_untaxed * 100
                continue

based on my understanding, if the invoice is created for this invoice plan line, then no need to recompute. So, why assigning any value, it should be continue without any assignments.

If this is correct, I'll create a PR.

@hussain hussain added the bug label Feb 12, 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