Commit 49e97d3c authored by Cédric Krier's avatar Cédric Krier
Browse files

Do not supply stock with user without company

Closes #11501
parent 9835560ca851
Pipeline #61546 passed with stages
in 209 minutes and 5 seconds
......@@ -56,6 +56,8 @@
Location = pool.get('stock.location')
User = pool.get('res.user')
company = User(Transaction().user).company
if not company:
return
if warehouses is None:
# fetch warehouses:
......@@ -66,7 +68,7 @@
# fetch order points
order_points = OrderPoint.search([
('warehouse_location', '!=', None),
('company', '=', company.id if company else None),
('company', '=', company.id),
])
# index them by product
product2ops = {}
......@@ -140,6 +142,7 @@
products = set(products)
reqs = cls.search([
('state', '=', 'draft'),
('company', '=', company.id),
('origin', 'like', 'stock.order_point,%'),
])
reqs = [r for r in reqs
......
......@@ -28,9 +28,12 @@
User = pool.get('res.user')
Move = pool.get('stock.move')
LeadTime = pool.get('stock.location.lead_time')
company = User(Transaction().user).company
if not company:
return
if warehouses is None:
warehouses = Location.search([
('type', '=', 'warehouse'),
])
......@@ -31,13 +34,12 @@
if warehouses is None:
warehouses = Location.search([
('type', '=', 'warehouse'),
])
user_record = User(Transaction().user)
today = Date.today()
lead_time = LeadTime.get_max_lead_time()
if clean:
reqs = cls.search([
('state', '=', 'request'),
......@@ -38,11 +40,12 @@
today = Date.today()
lead_time = LeadTime.get_max_lead_time()
if clean:
reqs = cls.search([
('state', '=', 'request'),
('company', '=', company.id),
])
cls.delete(reqs)
# fetch quantities on order points
order_points = OrderPoint.search([
......@@ -44,10 +47,11 @@
])
cls.delete(reqs)
# fetch quantities on order points
order_points = OrderPoint.search([
('type', '=', 'internal'),
])
('type', '=', 'internal'),
('company', '=', company.id)
])
order_points = [
op for op in order_points if op.location.warehouse in warehouses]
id2product = {}
......@@ -157,7 +161,7 @@
product=product,
quantity=qty,
uom=product.default_uom,
company=user_record.company,
company=company,
))
shipment.moves = shipment_moves
shipment.planned_start_date = (
......
......@@ -54,7 +54,9 @@
Date = pool.get('ir.date')
User = pool.get('res.user')
company = User(Transaction().user).company
if not company:
return
if clean:
reqs = cls.search([
('state', '=', 'request'),
......@@ -57,7 +59,8 @@
if clean:
reqs = cls.search([
('state', '=', 'request'),
('company', '=', company.id),
('origin', 'like', 'stock.order_point,%'),
])
if warehouses:
......@@ -73,7 +76,7 @@
# fetch order points
order_points = OrderPoint.search([
('warehouse_location', '!=', None),
('company', '=', company.id if company else None),
('company', '=', company.id),
])
# index them by product
product2ops = {}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment