diff --git a/stock_request_picking_type/__manifest__.py b/stock_request_picking_type/__manifest__.py index 54d256284..2aea55a19 100644 --- a/stock_request_picking_type/__manifest__.py +++ b/stock_request_picking_type/__manifest__.py @@ -2,22 +2,19 @@ # 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.2.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_submit', + "name": "Stock Request Picking Type", + "summary": "Add Stock Requests to the Inventory App", + "version": "13.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_submit"], + "data": [ + "data/stock_picking_type.xml", + "views/stock_request_order_views.xml", + "views/stock_picking_views.xml", ], - 'data': [ - 'data/stock_picking_type.xml', - 'views/stock_request_order_views.xml', - 'views/stock_picking_views.xml', - ], - 'development_status': 'Beta', - 'maintainers': ['max3903'] + "development_status": "Beta", + "maintainers": ["max3903"], } diff --git a/stock_request_picking_type/migrations/12.0.2.0.0/post-migration.py b/stock_request_picking_type/migrations/12.0.2.0.0/post-migration.py index 2a9d38e06..1e5b9e6e5 100644 --- a/stock_request_picking_type/migrations/12.0.2.0.0/post-migration.py +++ b/stock_request_picking_type/migrations/12.0.2.0.0/post-migration.py @@ -6,9 +6,11 @@ def migrate(env, version): if not version: return - env.execute("UPDATE stock_request_order " - "SET picking_type_id = (" - "SELECT id " - "FROM stock_picking_type " - "WHERE code = 'stock_request_order') " - "WHERE picking_type_id IS NULL;") + env.execute( + "UPDATE stock_request_order " + "SET picking_type_id = (" + "SELECT id " + "FROM stock_picking_type " + "WHERE code = 'stock_request_order') " + "WHERE picking_type_id IS NULL;" + ) diff --git a/stock_request_picking_type/models/stock_picking_type.py b/stock_request_picking_type/models/stock_picking_type.py index 47fa48ea3..3e118f19c 100644 --- a/stock_request_picking_type/models/stock_picking_type.py +++ b/stock_request_picking_type/models/stock_picking_type.py @@ -5,40 +5,44 @@ from odoo import fields, models class StockPickingType(models.Model): - _inherit = 'stock.picking.type' + _inherit = "stock.picking.type" - code = fields.Selection(selection_add=[('stock_request_order', - 'Stock Request Order')]) - 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') + code = fields.Selection( + selection_add=[("stock_request_order", "Stock Request Order")] + ) + 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_order') + types = self.filtered(lambda picking: picking.code == "stock_request_order") if not types: return domains = { - 'count_sr_todo': [('state', '=', 'submitted')], - 'count_sr_open': [('state', '=', 'open')], - 'count_sr_late': [('expected_date', '<', fields.Date.today()), - ('state', 'in', ('submitted', 'open'))], + "count_sr_todo": [("state", "=", "submitted")], + "count_sr_open": [("state", "=", "open")], + "count_sr_late": [ + ("expected_date", "<", fields.Date.today()), + ("state", "in", ("submitted", "open")), + ], } for field in domains: - data = self.env['stock.request.order'].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} + data = self.env["stock.request.order"].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_order_picking_type_action(self): - return self._get_action( - 'stock_request_picking_type.action_picking_dashboard') + return self._get_action("stock_request_picking_type.action_picking_dashboard") diff --git a/stock_request_picking_type/models/stock_request_order.py b/stock_request_picking_type/models/stock_request_order.py index 984aad6a6..99c3e458a 100644 --- a/stock_request_picking_type/models/stock_request_order.py +++ b/stock_request_picking_type/models/stock_request_order.py @@ -5,17 +5,34 @@ from odoo import api, fields, models class StockRequestOrder(models.Model): - _inherit = 'stock.request.order' + _inherit = "stock.request.order" @api.model def _get_default_picking_type(self): - return self.env['stock.picking.type'].search([ - ('code', '=', 'stock_request_order'), - ('warehouse_id.company_id', 'in', - [self.env.context.get('company_id', self.env.user.company_id.id), - False])], - limit=1).id + return ( + self.env["stock.picking.type"] + .search( + [ + ("code", "=", "stock_request_order"), + ( + "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) + "stock.picking.type", + "Operation Type", + default=_get_default_picking_type, + required=True, + )