Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
5
sale_require_po_doc/models/__init__.py
Executable file
5
sale_require_po_doc/models/__init__.py
Executable file
@@ -0,0 +1,5 @@
|
||||
# Copyright (C) 2021 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import res_partner
|
||||
from . import sale_order
|
||||
23
sale_require_po_doc/models/res_partner.py
Executable file
23
sale_require_po_doc/models/res_partner.py
Executable file
@@ -0,0 +1,23 @@
|
||||
# Copyright (C) 2021 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = "res.partner"
|
||||
|
||||
customer_need_po = fields.Boolean(
|
||||
string="Customer Requires PO",
|
||||
tracking=True,
|
||||
help="A PO number will be required on the"
|
||||
" Sales Order field for Customer Reference",
|
||||
)
|
||||
sale_doc = fields.Text(
|
||||
string="Sales Require Documentation",
|
||||
tracking=True,
|
||||
help="Details of the sales documentation required for this customer."
|
||||
" Sales documentation notes field will be required on Sales Orders"
|
||||
" This is complementary to requiring a PO number, and can be used"
|
||||
" with or without that setting.",
|
||||
)
|
||||
42
sale_require_po_doc/models/sale_order.py
Executable file
42
sale_require_po_doc/models/sale_order.py
Executable file
@@ -0,0 +1,42 @@
|
||||
# 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()
|
||||
Reference in New Issue
Block a user