diff --git a/stock_request_picking_type/README.rst b/stock_request_picking_type/README.rst new file mode 100644 index 000000000..21cd7854d --- /dev/null +++ b/stock_request_picking_type/README.rst @@ -0,0 +1,21 @@ +**This file is going to be generated by oca-gen-addon-readme.** + +*Manual changes will be overwritten.* + +Please provide content in the ``readme`` directory: + +* **DESCRIPTION.rst** (required) +* INSTALL.rst (optional) +* CONFIGURE.rst (optional) +* **USAGE.rst** (optional, highly recommended) +* DEVELOP.rst (optional) +* ROADMAP.rst (optional) +* HISTORY.rst (optional, recommended) +* **CONTRIBUTORS.rst** (optional, highly recommended) +* CREDITS.rst (optional) + +Content of this README will also be drawn from the addon manifest, +from keys such as name, authors, maintainers, development_status, +and license. + +A good, one sentence summary in the manifest is also highly recommended. diff --git a/stock_request_picking_type/__init__.py b/stock_request_picking_type/__init__.py new file mode 100644 index 000000000..dbf87a2fe --- /dev/null +++ b/stock_request_picking_type/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2019 Open Source Integrators +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from . import models diff --git a/stock_request_picking_type/__manifest__.py b/stock_request_picking_type/__manifest__.py new file mode 100644 index 000000000..bccedbc55 --- /dev/null +++ b/stock_request_picking_type/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2019 Open Source Integrators +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +{ + 'name': 'Stock Request Picking Type', + 'summary': 'Add Stock Requests to the Inventory App', + 'version': '12.0.1.0.0', + 'license': 'LGPL-3', + 'website': 'https://github.com/stock-logistics-warehouse', + 'author': 'Open Source Integrators, ' + 'Odoo Community Association (OCA)', + 'category': 'Warehouse Management', + 'depends': [ + 'stock_request', + ], + 'data': [ + 'data/stock_picking_type.xml', + 'views/stock_request_views.xml', + 'views/stock_picking_views.xml', + ], + 'development_status': 'Beta', + 'maintainers': ['max3903'] +} diff --git a/stock_request_picking_type/data/stock_picking_type.xml b/stock_request_picking_type/data/stock_picking_type.xml new file mode 100644 index 000000000..0c2bca50b --- /dev/null +++ b/stock_request_picking_type/data/stock_picking_type.xml @@ -0,0 +1,11 @@ + + + + + Stock Requests + + stock_request + 0 + + + diff --git a/stock_request_picking_type/models/__init__.py b/stock_request_picking_type/models/__init__.py new file mode 100644 index 000000000..1953de94f --- /dev/null +++ b/stock_request_picking_type/models/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2019 Open Source Integrators +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from . import stock_request +from . import stock_picking_type diff --git a/stock_request_picking_type/models/stock_picking_type.py b/stock_request_picking_type/models/stock_picking_type.py new file mode 100644 index 000000000..9c7eb4a13 --- /dev/null +++ b/stock_request_picking_type/models/stock_picking_type.py @@ -0,0 +1,43 @@ +# Copyright 2019 Open Source Integrators +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import fields, models + + +class StockPickingType(models.Model): + _inherit = 'stock.picking.type' + + code = fields.Selection(selection_add=[('stock_request', + 'Stock Request')]) + count_sr_todo = fields.Integer(string="To Do", + compute='_compute_sr_count') + count_sr_open = fields.Integer(string="In Progress", + compute='_compute_sr_count') + count_sr_late = fields.Integer(string="Late", + compute='_compute_sr_count') + + def _compute_sr_count(self): + types = self.filtered(lambda picking: picking.code == 'stock_request') + if not types: + return + domains = { + 'count_sr_todo': [('state', '=', 'draft')], + 'count_sr_open': [('state', '=', 'open')], + 'count_sr_late': [('expected_date', '<', fields.Date.today()), + ('state', 'in', ('draft', 'open'))], + } + for field in domains: + data = self.env['stock.request'].read_group( + domains[field] + + [('state', 'not in', ('done', 'cancel')), + ('picking_type_id', 'in', self.ids)], + ['picking_type_id'], ['picking_type_id']) + count = {x['picking_type_id'] and + x['picking_type_id'][0]: x['picking_type_id_count'] + for x in data} + for record in types: + record[field] = count.get(record.id, 0) + + def get_stock_request_picking_type_action(self): + return self._get_action( + 'stock_request_picking_type.action_picking_dashboard') diff --git a/stock_request_picking_type/models/stock_request.py b/stock_request_picking_type/models/stock_request.py new file mode 100644 index 000000000..f37e82dd5 --- /dev/null +++ b/stock_request_picking_type/models/stock_request.py @@ -0,0 +1,21 @@ +# Copyright 2019 Open Source Integrators +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import api, fields, models + + +class StockRequest(models.Model): + _inherit = 'stock.request' + + @api.model + def _get_default_picking_type(self): + return self.env['stock.picking.type'].search([ + ('code', '=', 'stock_request'), + ('warehouse_id.company_id', 'in', + [self.env.context.get('company_id', self.env.user.company_id.id), + False])], + limit=1).id + + picking_type_id = fields.Many2one( + 'stock.picking.type', 'Operation Type', + default=_get_default_picking_type, required=True) diff --git a/stock_request_picking_type/readme/CONTRIBUTORS.rst b/stock_request_picking_type/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..ab792860d --- /dev/null +++ b/stock_request_picking_type/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Maxime Chambreuil diff --git a/stock_request_picking_type/readme/DESCRIPTION.rst b/stock_request_picking_type/readme/DESCRIPTION.rst new file mode 100644 index 000000000..5d16cd18e --- /dev/null +++ b/stock_request_picking_type/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module adds stock requests within the Inventory app with a new operation type. diff --git a/stock_request_picking_type/readme/USAGE.rst b/stock_request_picking_type/readme/USAGE.rst new file mode 100644 index 000000000..e785e49f6 --- /dev/null +++ b/stock_request_picking_type/readme/USAGE.rst @@ -0,0 +1,3 @@ +* Go to Inventory +* Click on the Stock Requests tile to process stock requests +* You can also go to Inventory > Operations > Stock Requests diff --git a/stock_request_picking_type/static/description/icon.png b/stock_request_picking_type/static/description/icon.png new file mode 100644 index 000000000..c31ecfd9f Binary files /dev/null and b/stock_request_picking_type/static/description/icon.png differ diff --git a/stock_request_picking_type/views/stock_picking_views.xml b/stock_request_picking_type/views/stock_picking_views.xml new file mode 100644 index 000000000..01e9a511e --- /dev/null +++ b/stock_request_picking_type/views/stock_picking_views.xml @@ -0,0 +1,117 @@ + + + + + stock.picking.type.kanban + stock.picking.type + + + + + + + + + +
+
+
+
+ + + +
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ + + Operation Types + stock.picking.type + + + + {"invisible": [("code", "=", "stock_request")]} + + + {"invisible": [("code", "=", "stock_request")]} + + + + +
diff --git a/stock_request_picking_type/views/stock_request_views.xml b/stock_request_picking_type/views/stock_request_views.xml new file mode 100644 index 000000000..fff0146fe --- /dev/null +++ b/stock_request_picking_type/views/stock_request_views.xml @@ -0,0 +1,53 @@ + + + + + stock.request.select + stock.request + + + + + + + + + + + + + + + + + + + Stock Requests + ir.actions.act_window + stock.request + form + tree,form + + + [('picking_type_id', '=', active_id)] + {'default_picking_type_id': active_id} + + + + Stock Requests + ir.actions.act_window + stock.request + form + form + + + + +