Files
Odoo-18.0-20251222/sale_require_po_doc/models/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

43 lines
1.4 KiB
Python
Executable File

# Copyright (C) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
from odoo.exceptions import ValidationError
class SaleOrder(models.Model):
_inherit = "sale.order"
customer_need_po = fields.Boolean(
related="partner_id.customer_need_po",
string="Customer Requires PO",
)
sale_doc = fields.Text(
related="partner_id.sale_doc",
string="Sales Require Documentation",
)
sale_document_option = fields.Selection(
[
("no_need", "No documentation needed for this Sale"),
("done", "Documentation required obtained and archived"),
],
string="Sale Documentation",
)
sale_document_note = fields.Text(string="Sale Documentation Notes")
def action_confirm(self):
for order in self:
if order.customer_need_po and not order.client_order_ref:
raise ValidationError(
self.env._(
"You can not confirm sale order without Customer reference."
)
)
if order.sale_doc and not order.sale_document_option:
raise ValidationError(
self.env._(
"You can not confirm sale order without Sale Documentation."
)
)
return super().action_confirm()