Initial commit
This commit is contained in:
30
fusion_claims/static/src/js/tax_totals_patch.js
Normal file
30
fusion_claims/static/src/js/tax_totals_patch.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { TaxTotalsComponent } from "@account/components/tax_totals/tax_totals";
|
||||
|
||||
/**
|
||||
* Patch TaxTotalsComponent to handle cases where subtotals is undefined
|
||||
* This fixes the "Invalid loop expression: 'undefined' is not iterable" error
|
||||
* that occurs when invoices have no tax configuration.
|
||||
*/
|
||||
patch(TaxTotalsComponent.prototype, {
|
||||
formatData(props) {
|
||||
// Call the original formatData method
|
||||
super.formatData(props);
|
||||
|
||||
// If totals exists but subtotals is undefined, set it to empty array
|
||||
if (this.totals && this.totals.subtotals === undefined) {
|
||||
this.totals.subtotals = [];
|
||||
}
|
||||
|
||||
// Also ensure each subtotal has tax_groups array
|
||||
if (this.totals && this.totals.subtotals) {
|
||||
for (const subtotal of this.totals.subtotals) {
|
||||
if (subtotal.tax_groups === undefined) {
|
||||
subtotal.tax_groups = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user