mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] stock_request_picking_type: black, isort
This commit is contained in:
committed by
Reed Hayashikawa
parent
b3b0d4b1ea
commit
4de01878a7
@@ -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"],
|
||||
}
|
||||
|
||||
@@ -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;"
|
||||
)
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user