@@ -56,6 +56,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:
|
||||
@@ -66,7 +68,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 = {}
|
||||
@@ -140,6 +142,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
|
||||
|
||||
@@ -28,26 +28,30 @@ 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
|
||||
|
||||
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'),
|
||||
('company', '=', company.id),
|
||||
])
|
||||
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 @@ 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 = (
|
||||
|
||||
@@ -54,10 +54,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:
|
||||
@@ -73,7 +76,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 = {}
|
||||
|
||||
Reference in New Issue
Block a user