1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- # -*- coding: utf-8 -*-
- from openerp.http import request
- _MODEL = 'stock.picking'
- def pick_assign(sale_order_id, picking_done=True):
- sale_order = request.env['sale.order'].browse(sale_order_id)
- for picking in sale_order.picking_ids:
- picking.force_assign()
- if picking_done:
- picking.action_done()
- def get_pickings():
- sale_orders = request.env['sale.order'].search([('from_pos', '=', True)])
- sale_orders = sale_orders.mapped(lambda x: x.name)
- domain = [
- ('origin', 'in', sale_orders),
- ('state', '=', 'assigned')
- ]
- return [
- {
- 'id': sp.id,
- 'name': sp.display_name,
- 'origin': sp.origin,
- 'packOperationExist': sp.pack_operation_exist,
- 'moveLines': [
- {
- 'id': move.id,
- 'name': move.display_name,
- 'availability': move.availability,
- 'origin': move.origin,
- 'quantity': move.product_qty,
- 'product': {
- 'id': move.product_id.id,
- 'name': move.product_id.display_name,
- 'image': move.product_id.image_medium
- }
- }
- for move in sp.move_lines
- ],
- 'partner': {
- 'id': sp.partner_id.id,
- 'name': sp.partner_id.display_name,
- 'image': sp.partner_id.image_medium or None,
- 'ruc': sp.partner_id.ruc or None,
- 'phone': sp.partner_id.phone or None,
- 'mobile': sp.partner_id.mobile or None,
- 'email': sp.partner_id.email or None
- }
- } for sp in request.env[_MODEL].search(domain)
- ]
- def confirm_picking(stock_picking_id, user_id):
- stock_picking = request.env[_MODEL].browse(stock_picking_id)
- stock_picking.write({
- 'partner_id': user_id
- })
- stock_picking.do_transfer()
|