/usr/lib/python2.7/dist-packages/trytond/modules/sale_supply/stock.py is in tryton-modules-sale-supply 3.4.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from trytond.model import ModelView, Workflow
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
__all__ = ['ShipmentIn']
__metaclass__ = PoolMeta
class ShipmentIn:
__name__ = 'stock.shipment.in'
@classmethod
@ModelView.button
@Workflow.transition('done')
def done(cls, shipments):
SaleLine = Pool().get('sale.line')
super(ShipmentIn, cls).done(shipments)
# Assigned sale move lines
for shipment in shipments:
move_ids = [x.id for x in shipment.incoming_moves]
sale_lines = SaleLine.search([
('purchase_request.purchase_line.moves',
'in', move_ids),
('purchase_request.origin', 'like', 'sale.sale,%'),
])
pbl = {}
for move in shipment.inventory_moves:
pbl.setdefault(move.product, {}).setdefault(
move.to_location, 0.0)
pbl[move.product][move.to_location] += \
move.internal_quantity
for sale_line in sale_lines:
sale_line.assign_supplied(pbl[sale_line.product])
|