Initial commit: Odoo 18.0-20251222 extra-addons
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

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
from . import invoice_blocking_reason
from . import sale_order

View File

@@ -0,0 +1,18 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class InvoiceBlockingReason(models.Model):
_name = "invoice.blocking.reason"
_description = "Sale invoice blocking reason"
name = fields.Char(string="Reason", required=True)
_sql_constraints = [
(
"name_uniq",
"unique (name)",
"You cannot have two invoice blocking reasons with the same name.",
)
]

View File

@@ -0,0 +1,36 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
from odoo.exceptions import UserError
class SaleOrder(models.Model):
_inherit = "sale.order"
invoice_blocking_reason_id = fields.Many2one(
"invoice.blocking.reason",
string="Blocking for invoicing",
)
@api.depends("invoice_blocking_reason_id", "state", "order_line.invoice_status")
def _compute_invoice_status(self):
res = super()._compute_invoice_status()
for order in self.filtered(
lambda order: order.invoice_blocking_reason_id
and order.state in ("sale", "done")
):
order.invoice_status = "no"
return res
def _get_invoiceable_lines(self, final=False):
"""Return the invoiceable lines for order `self`."""
if self.invoice_blocking_reason_id:
return self.env["sale.order.line"]
return super()._get_invoiceable_lines(final=final)
def _nothing_to_invoice_error_message(self):
error = super()._nothing_to_invoice_error_message()
error += _("\n- You may have an invoice blocking reason on the sale order")
return UserError(error)