[15.0] sale_invoice_plan: Cannot edit or add sale line after invoices are generated
hussain opened this issue · 0 comments
hussain commented
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:
- Create a sale order with 1 line item.
- Create invoice plan.
- Confirm sale order.
- Generate all invoices using button "Create invoice by Plan" and create all invoices.
- 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.