Do not supply stock with user without company

Closes #11501
(grafted from 49e97d3ca0b5bd892e39d77554fbef12e3d5c77e)

--HG--
branch : 6.0
This commit is contained in:
Cédric Krier
2023-01-15 00:19:15 +01:00
parent 1207c441ef
commit af374374e5
3 changed files with 14 additions and 4 deletions
+4 -1
View File
@@ -50,6 +50,8 @@ class PurchaseRequest(metaclass=PoolMeta):
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:
@@ -60,7 +62,7 @@ class PurchaseRequest(metaclass=PoolMeta):
# 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 = {}
@@ -133,6 +135,7 @@ class PurchaseRequest(metaclass=PoolMeta):
products = set(products)
reqs = cls.search([
('state', '=', 'draft'),
('company', '=', company.id),
('origin', 'like', 'stock.order_point,%'),
])
reqs = [r for r in reqs
+6 -2
View File
@@ -26,20 +26,24 @@ class ShipmentInternal(ModelSQL, ModelView):
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
user_record = User(Transaction().user)
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([
('type', '=', 'internal'),
('company', '=', company.id),
])
id2product = {}
product2op = {}
@@ -141,7 +145,7 @@ class ShipmentInternal(ModelSQL, ModelView):
product=product,
quantity=qty,
uom=product.default_uom,
company=user_record.company,
company=company,
))
shipment.moves = shipment_moves
shipment.planned_start_date = (
@@ -48,10 +48,13 @@ class Production(metaclass=PoolMeta):
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'),
('company', '=', company.id),
('origin', 'like', 'stock.order_point,%'),
])
if warehouses:
@@ -67,7 +70,7 @@ class Production(metaclass=PoolMeta):
# 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 = {}