From 0bcf0b004f248c5400488dd2b0344efa1f2d08cb Mon Sep 17 00:00:00 2001 From: hveficent Date: Wed, 31 Jul 2019 14:25:05 +0200 Subject: [PATCH] ao_purchase_request: Custom Purchase Request Product Usage --- ao_purchase_request/README.rst | 3 + ao_purchase_request/__init__.py | 1 + ao_purchase_request/__manifest__.py | 8 ++- ao_purchase_request/models/__init__.py | 1 + .../models/purchase_request.py | 9 +++ .../views/purchase_request_view.xml | 59 +++++++++++++++++++ ao_purchase_request/wizards/__init__.py | 1 + ...rchase_request_line_make_purchase_order.py | 9 +++ ..._request_line_make_purchase_order_view.xml | 19 ++++++ 9 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 ao_purchase_request/models/purchase_request.py create mode 100644 ao_purchase_request/views/purchase_request_view.xml create mode 100644 ao_purchase_request/wizards/__init__.py create mode 100644 ao_purchase_request/wizards/purchase_request_line_make_purchase_order.py create mode 100644 ao_purchase_request/wizards/purchase_request_line_make_purchase_order_view.xml diff --git a/ao_purchase_request/README.rst b/ao_purchase_request/README.rst index 3bd5769b..5a4981b6 100644 --- a/ao_purchase_request/README.rst +++ b/ao_purchase_request/README.rst @@ -10,6 +10,9 @@ This module contains customizations specific to Aleph Objects. * Disables the capability to group into a single purchase request from various procurements. +* Purchase Request Product Usage custom workflow: + * Usage is seen by Purchase Request Users also + * Usage is required if Product is Consumible or a Service Credits ======= diff --git a/ao_purchase_request/__init__.py b/ao_purchase_request/__init__.py index 0650744f..aee8895e 100644 --- a/ao_purchase_request/__init__.py +++ b/ao_purchase_request/__init__.py @@ -1 +1,2 @@ from . import models +from . import wizards diff --git a/ao_purchase_request/__manifest__.py b/ao_purchase_request/__manifest__.py index 70e2d020..3487d9e4 100644 --- a/ao_purchase_request/__manifest__.py +++ b/ao_purchase_request/__manifest__.py @@ -8,7 +8,13 @@ "author": "Eficent Business and IT Consulting Services S.L.", "website": "http://www.eficent.com", "category": "Product", - "depends": ["purchase_request"], + "depends": ["purchase_request", + "purchase_request_product_usage", + ], + "data": [ + "views/purchase_request_view.xml", + "wizards/purchase_request_line_make_purchase_order_view.xml", + ], "license": "AGPL-3", 'installable': True, } diff --git a/ao_purchase_request/models/__init__.py b/ao_purchase_request/models/__init__.py index 55eae172..32883636 100644 --- a/ao_purchase_request/models/__init__.py +++ b/ao_purchase_request/models/__init__.py @@ -1 +1,2 @@ from . import stock_rule +from . import purchase_request diff --git a/ao_purchase_request/models/purchase_request.py b/ao_purchase_request/models/purchase_request.py new file mode 100644 index 00000000..e6c08dcf --- /dev/null +++ b/ao_purchase_request/models/purchase_request.py @@ -0,0 +1,9 @@ +# Copyright 2019 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import fields, models + + +class PurchaseRequestLine(models.Model): + _inherit = "purchase.request.line" + + product_type = fields.Selection(related='product_id.type', readonly=True) diff --git a/ao_purchase_request/views/purchase_request_view.xml b/ao_purchase_request/views/purchase_request_view.xml new file mode 100644 index 00000000..21ff864e --- /dev/null +++ b/ao_purchase_request/views/purchase_request_view.xml @@ -0,0 +1,59 @@ + + + + + + purchase.request.form + purchase.request + + + + + + + {'required': ['|', ('product_id','=', False), ('product_type', 'in', ['consu', 'service'])]} + + + + + + + {'required': ['|', ('product_id','=', False), ('product_type', 'in', ['consu', 'service'])]} + + + + + + + purchase.request.line.form + purchase.request.line + + + + + + + {'required': ['|', ('product_id','=', False), ('product_type', 'in', ['consu', 'service'])]} + + + + + + + purchase.request.line.search + purchase.request.line + + + + + + + + + + diff --git a/ao_purchase_request/wizards/__init__.py b/ao_purchase_request/wizards/__init__.py new file mode 100644 index 00000000..f26ebe35 --- /dev/null +++ b/ao_purchase_request/wizards/__init__.py @@ -0,0 +1 @@ +from . import purchase_request_line_make_purchase_order diff --git a/ao_purchase_request/wizards/purchase_request_line_make_purchase_order.py b/ao_purchase_request/wizards/purchase_request_line_make_purchase_order.py new file mode 100644 index 00000000..b7634325 --- /dev/null +++ b/ao_purchase_request/wizards/purchase_request_line_make_purchase_order.py @@ -0,0 +1,9 @@ +# Copyright 2019 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0). +from odoo import fields, models + + +class PurchaseRequestLineMakePurchaseOrderItem(models.TransientModel): + _inherit = "purchase.request.line.make.purchase.order.item" + + product_type = fields.Selection(related='product_id.type', readonly=True) diff --git a/ao_purchase_request/wizards/purchase_request_line_make_purchase_order_view.xml b/ao_purchase_request/wizards/purchase_request_line_make_purchase_order_view.xml new file mode 100644 index 00000000..8faa695f --- /dev/null +++ b/ao_purchase_request/wizards/purchase_request_line_make_purchase_order_view.xml @@ -0,0 +1,19 @@ + + + + + + Purchase Request Line Make Purchase Order + purchase.request.line.make.purchase.order + + + + + + + + + + +