I can not reproduce your performance on latest trunk. I’ve created a proteus script (see below) to create 200 products and add a shipment which recives 4 units of one of them. I’ve run on a postgresql database with stock, sale, stock_lot and production modules activated. Here are my results:
With eager loading:
Shipment created 0:00:07.425063
Shipment received 0:00:02.891001
Shipment done 0:00:01.724375
With lazy loading:
Shipment created 0:00:06.377097
Shipment received 0:00:02.791547
Shipment done 0:00:01.463134
Here is the script:
import datetime
from decimal import Decimal
from proteus import Model, config
config.set_trytond()
Product = Model.get('product.product')
products = Product.find([])
if not products:
print('Creating products')
Uom = Model.get('product.uom')
unit, = Uom.find([('symbol', '=', 'u')])
Template = Model.get('product.template')
templates = []
for i in range(200):
template = Template()
template.name = 'Product %s' % (i + 1)
template.type = 'goods'
template.default_uom = unit
template.list_price = Decimal(0)
product, = template.products
product.code = 'PROD%s' % (i + 1)
product.cost_price = Decimal(0)
templates.append(template)
Template.save(templates)
products = Product.find([])
ShipmentIn = Model.get('stock.shipment.in')
Location = Model.get('stock.location')
warehouse_loc, = Location.find([('code', '=', 'WH')])
Party = Model.get('party.party')
party, = Party.find([], limit=1)
start = datetime.datetime.now()
print('Creating shipment')
shipment = ShipmentIn()
shipment.supplier = party
for product in products:
move = shipment.inventory_moves.new()
move.from_location = party.supplier_location
move.to_location = shipment.warehouse.input_location
move.product = product
move.quantity = 4.0
move.unit_price = product.cost_price
shipment.save()
print('Shipment created', (datetime.datetime.now() - start))
start = datetime.datetime.now()
shipment.click('receive')
print('Shipment received', (datetime.datetime.now() - start))
start = datetime.datetime.now()
shipment.click('done')
print('Shipment done', (datetime.datetime.now() - start))