from trytond.model import fields from trytond.pool import Pool, PoolMeta class Move(metaclass=PoolMeta): "Stock Move" __name__ = "stock.move" serial = fields.Char('Serial') class ShipmentOut(metaclass=PoolMeta): "Customer Shipment" __name__ = 'stock.shipment.out' def _get_inventory_move(self, move): 'Return inventory move for the outgoing move if necessary' pool = Pool() Move = pool.get('stock.move') Uom = pool.get('product.uom') quantity = move.quantity for inventory_move in self.inventory_moves: if (inventory_move.origin == move and inventory_move.state != 'cancelled'): quantity -= Uom.compute_qty( inventory_move.uom, inventory_move.quantity, move.uom) quantity = move.uom.round(quantity) if quantity <= 0: return inventory_move = Move( from_location=self.warehouse_storage, to_location=move.from_location, product=move.product, serial=move.serial, uom=move.uom, quantity=quantity, shipment=self, planned_date=move.planned_date, company=move.company, origin=move, state='staging' if move.state == 'staging' else 'draft', ) if inventory_move.on_change_with_unit_price_required(): inventory_move.unit_price = move.unit_price inventory_move.currency = move.currency return inventory_move