Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Implementing Warehouse Logic with Automated Actions and Python Code in Odoo

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
warehousesAutomatedActionsdeliveries-warehouseodoo16featuresPythonCode
2313 Vistas
Avatar
Skander Ghamgui

Hello Odoo Community,


I'm currently working on optimizing my delivery and picking processes in Odoo, and I'm seeking guidance on implementing a specific logic using Automated Actions and Python code.


Objective:

When a customer places an order, I want Odoo to intelligently determine from which warehouse the order should be picked based on the availability of the products in different warehouses.


Logic Overview:

I've already devised a Python function that efficiently distributes the order quantity among different warehouses based on their availability. Here's a simplified version of the logic:


def fulfill_order(main_qty, C_qty, B_qty, A_qty, order_qty):
    def find_most_products(warehouses):
        # Prioritize C > B > A
        warehouse_order = [C_qty, B_qty, A_qty]
        max_index = max(range(len(warehouses)), key=lambda i: (warehouses[i], -warehouse_order[i]))
        return max_index

    total_available_qty = main_qty + C_qty + B_qty + A_qty

    print(f"Order Quantity: {order_qty}")
    print("Initial product availability:")
    print(f"- Main Warehouse: {main_qty}")
    print(f"- Warehouse C: {C_qty}")
    print(f"- Warehouse B: {B_qty}")
    print(f"- Warehouse A: {A_qty}\n")

    main_taken = min(main_qty, order_qty)
    main_qty -= main_taken
    order_qty -= main_taken

    def distribute_from_warehouses(qty, warehouses):
        distributed = [0, 0, 0]
        for _ in range(qty):
            if sum(warehouses) == 0:
                break
            most_products_index = find_most_products(warehouses)
            distributed[most_products_index] += 1
            warehouses[most_products_index] -= 1

        return distributed

    distributed_qty = distribute_from_warehouses(order_qty, [C_qty, B_qty, A_qty])

    C_qty -= distributed_qty[0]
    B_qty -= distributed_qty[1]
    A_qty -= distributed_qty[2]

    print("Products distributed:")
    if main_taken > 0:
        print(f"- {main_taken} products from Main Warehouse")
    if distributed_qty[0] > 0:
        print(f"- {distributed_qty[0]} products from Warehouse C")
    if distributed_qty[1] > 0:
        print(f"- {distributed_qty[1]} products from Warehouse B")
    if distributed_qty[2] > 0:
        print(f"- {distributed_qty[2]} products from Warehouse A")

    print(f"\nRemaining product availability:")
    print(f"- Main Warehouse: {main_qty}")
    print(f"- Warehouse C: {C_qty}")
    print(f"- Warehouse B: {B_qty}")
    print(f"- Warehouse A: {A_qty}")

    remaining_qty = order_qty - sum(distributed_qty)
    if remaining_qty > 0:
        print(f"\n{remaining_qty} products are not available")

# Example usage
main_qty = int(input("How many products are available in Main Warehouse? "))
C_qty = int(input("How many products are available in Warehouse C? "))
B_qty = int(input("How many products are available in Warehouse B? "))
A_qty = int(input("How many products are available in Warehouse A? "))
order_qty = int(input("How many products did the customer order? "))

fulfill_order(main_qty, C_qty, B_qty, A_qty, order_qty)


Scenario: I have multiple warehouses where A, B, and C also function as points of sale with a depot inside, while the main warehouse is solely for storage and not a point of sale.

Question: How can I integrate this Python logic into Odoo using Automated Actions? Specifically, I want Odoo to automatically execute this Python function whenever a new order is placed, so the system can determine the optimal warehouse for picking.

Additional Notes:

  • I understand that Automated Actions allow for triggering actions based on specific events in Odoo.
  • I'm not entirely sure about the process of executing custom Python code within an Automated Action in Odoo.
  • Any insights, examples, or pointers on how to achieve this integration would be greatly appreciated.
  • You can copy paste the code and try it for your self with different scenarios so you can better understand the logic I want to impliment
  • You can ask me any questions for more clarifications I'll answer as soon as I can
  • Any help is greatly appreciated

Thank you in advance for your assistance!

Best regards,

Skander

1
Avatar
Descartar
Ricardo Gross

very good question! did you find the solution "to intelligently determine from which warehouse the order should be picked based on the availability of the products in different warehouses"?

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Odoo16: where is Automated Actions in Technical menu Resuelto
AutomatedActions odoo16features
Avatar
Avatar
Avatar
Avatar
3
oct 23
4255
ValueError: <class 'psycopg2.ProgrammingError'>: "can't adapt type 'mail.activity.type'" Resuelto
activity AutomatedActions odoo16features
Avatar
1
ago 23
3697
ValueError: [class 'psycopg2.ProgrammingError']: "can't adapt type 'ir.model'" while evaluating Resuelto
activity AutomatedActions odoo16features
Avatar
Avatar
1
ago 23
4455
Automated Action to clone a task and adding days to due date Resuelto
project.task AutomatedActions odoo16features
Avatar
1
nov 22
3617
default value of fied based on another field odoo16
sales warehouses product odoo16features
Avatar
Avatar
Avatar
Avatar
3
jul 25
5166
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now