Files
Odoo-18.0-20251222/sale_force_invoiced/model/sale_order.py
tocmo0nlord adbe430761
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled
Initial commit: Odoo 18.0-20251222 extra-addons
2026-03-13 20:43:25 +00:00

46 lines
1.4 KiB
Python
Executable File

# Copyright 2017 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class SaleOrder(models.Model):
_inherit = "sale.order"
force_invoiced = fields.Boolean(
help="When you set this field, the sales order will be considered as "
"fully invoiced, even when there may be ordered or delivered "
"quantities pending to invoice.",
readonly=True,
tracking=20,
copy=False,
)
@api.depends("force_invoiced")
def _compute_invoice_status(self):
res = super()._compute_invoice_status()
self.filtered(lambda so: so.force_invoiced and so.state == "sale").update(
{"invoice_status": "invoiced"}
)
return res
@api.depends("force_invoiced")
def _compute_amount_to_invoice(self):
# force_invoiced causes the amount to invoice to be zero
res = super()._compute_amount_to_invoice()
for so in self.filtered("force_invoiced"):
so.amount_to_invoice = 0
return res
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
@api.depends("order_id.force_invoiced")
def _compute_invoice_status(self):
res = super()._compute_invoice_status()
self.filtered(
lambda sol: sol.order_id.force_invoiced
).invoice_status = "invoiced"
return res