forked from OCA/l10n-spain
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by HaraldPanten
- Loading branch information
Showing
1 changed file
with
20 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# Copyright 2023 Manuel Regidor <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
from odoo import api, models | ||
from odoo.tools import float_compare | ||
|
||
|
||
class SaleOrderLine(models.Model): | ||
|
@@ -21,3 +22,21 @@ def _prepare_invoice_line(self, **optional_values): | |
res = super()._prepare_invoice_line(**optional_values) | ||
res["is_sigaus"] = self.is_sigaus | ||
return res | ||
|
||
@api.depends("is_sigaus") | ||
def _compute_invoice_status(self): | ||
precision = self.env["decimal.precision"].precision_get( | ||
"Product Unit of Measure" | ||
) | ||
sigaus_lines = self.filtered("is_sigaus") | ||
for line in sigaus_lines: | ||
if ( | ||
float_compare( | ||
line.qty_invoiced, line.product_uom_qty, precision_digits=precision | ||
) | ||
>= 0 | ||
): | ||
line.invoice_status = "invoiced" | ||
else: | ||
line.invoice_status = "no" | ||
return super(SaleOrderLine, self - sigaus_lines)._compute_invoice_status() |