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

Can Odoo automatically pick the Cheapest Vendor listed in the Purchase tab of a Product when generating an RFQ?

Suscribirse

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

Se marcó esta pregunta
automaticpricelowPurchase
5 Respuestas
14332 Vistas
Avatar
Community Question

I have multiple Vendors for several Products.

I would like Odoo to automatically select the Vendor with the cheapest price (the prices change each month) when generating an RFQ (draft Purchase Order). 

Is this possible.

0
Avatar
Descartar
Avatar
Friedrich Sauer
Mejor respuesta

Hi all, 

I converted this to an automated action that works in v17. 




My code:

def sort_seller_ids(self):
    for rec in self:
       
        seller_ids = self.env['product.supplierinfo'].search([('product_tmpl_id', 'in', [rec.product_tmpl_id.id])])
        rec.product_tmpl_id.message_post(body=f'seller_ids: {seller_ids}')
       
        seller_prices = {}
       
        for seller in seller_ids:
            # seller's ID --> key and their price --> value
            seller_prices[seller.id] = seller.price
           
        # Sort the dictionary by price in ascending order
        sorted_seller_ids = sorted(seller_prices, key=seller_prices.get, reverse=False)
       
        # Update the sequence of seller_ids based on the sorted order
        for sequence, seller_id in enumerate(sorted_seller_ids, start=1):
            seller = seller_ids.filtered_domain([('id', '=', seller_id)])
            if seller:
                seller.write({'sequence': sequence})


sort_seller_ids(record)

Removing the drag handles is not obligatory, but they have no funcionality anymore.


Best,

Friedrich

2
Avatar
Descartar
Chris TRINGHAM

Hi Friedrich - I'm not a Python programmer, but from my testing it seems as if this is putting the highest price first. Also, is there any way to make this work as a Server Action (to do a mass update)?

Friedrich Sauer

Hi Chris, you are right! I changed the code.

Putting this in a server action can work. you need to go through all products and use the action on its order lines. in serveractions with model product.template use something like:

def sort_seller_lines_for_all_products(self):
for product in records:
seller_ids = product.seller_ids

seller_prices = {}

for seller in seller_ids:
# seller's ID --> key and their price --> value
seller_prices[seller.id] = seller.price

# Sort the dictionary by price in ascending order
sorted_seller_ids = sorted(seller_prices, key=seller_prices.get, reverse=False)

# Update the sequence of seller_ids based on the sorted order
for sequence, seller_id in enumerate(sorted_seller_ids, start=1):
seller = seller_ids.filtered_domain([('id', '=', seller_id)])
if seller:
seller.write({'sequence': sequence})

sort_seller_lines_for_all_products(records)

You can add this as an "contextual action" so that is is available under the action wheel in the products view. (I have not tested this code btw)

Best,
Friedrich

Avatar
Ray Carnes (ray)
Mejor respuesta

Note: Right Click the images below and select VIEW IMAGE / OPEN IMAGE IN A NEW TAB to see larger versions.

Yes.

Odoo uses the first Vendor in the list by default.

To have it choose the cheapest, the easiest way is to sort the list by price each time it is edited.  You will also have to remove the drag handle from the list to stop users re-sorting the list.

1. Create an Automated Action that makes sure the list of is always sorted after any edits (also works if you change prices from the Vendor Pricelist menu).



2. Remove the drag handle by creating your own view that inherits and overrides the default:


5
Avatar
Descartar
Darren

is this working on Odoo 15.0? I am using Odoo Cloud by Odoo. I tried this ccode, it seem no working. I just follow the first step.

Avatar
Sanjeev Kumar
Mejor respuesta

Is there a way to stop Odoo to pick the cheapest price? It's handy when there are several vendors for one product. However, when there is only one supplier and prices increase every year, this function does not make sense. It's really difficult to remove old prices one by one when there is a huge number of products in the system.

0
Avatar
Descartar
Caribbean Data Challengers

Just a thought...
Did you try to work with the start and end dates of the price?
Another approach would be to add a custom boolean field "current_price". Export the whole list (updatable) and set current_price to 0. Add your new records with the current_price = 1.
Now all you need is the add this field in the sort somehow, perhaps a Python specialist can help with that.

Darren

You can try "end date" when you add the price.

Avatar
Gargano Dok Scarl
Mejor respuesta

In odoo 13 CE is not possible sort suppliers list from product template, changes will not be saved.

It's possible sort suppliers list from product.supplierlist, changes will be saved.

Can anyone adapt code descripted in this post, for use it in template product.supplierinfo

Below original code:

if record.seller_ids:
  record['seller_ids'] = record.seller_ids.sorted(key = lambda s: s.price)

Thanks

0
Avatar
Descartar
Ray Carnes (ray)

Make sure base_automation "Automated Action Rules" is installed and visit the Automated Actions menu.

Gargano Dok Scarl

Hi Ray, thanks for your help. I've do it some days ago, and it work. I've do step 1 only (1. Create an Automated Action) and not step 2. (2. Remove the drag handle). But if I change manually a supplier price, in product template, It not reoder automatic supplier list. Maybe I must to do step 2, for work well? Thanks

Gargano Dok Scarl

Hi, I'm using odoo 13 community, not work! I've do it, both modifies, but not sort supplier list by price.

Chris TRINGHAM

I think there may be an extra step. As well as removing the "drag handle", existing records on product.supplierinfo need to be updated so that the sequence is 1 (otherwise this overrides the sort done in the Automated Action)

Gargano Dok Scarl

Hi Chris, can you write more details to do, I'm not a developer and I don't know how do. Could you write what I must do? Thanks

Chris TRINGHAM

Here's a step-by-step guide: https://odootricks.tips/automatically-select-lowest-price-vendor/

Gargano Dok Scarl

Hi Chris, thanks for guide. I've try, and suppliers are sorted by price. But I've look that suppliers are sorted by min_qty first , and by price after. If I have some suppliers with high min_qty and more expensive, they will be sorted before others more cheap end with low min_qty. I don't know if is this correct action, but I needed sort by price first , and by min_qty secondary. Any idea?

Chris TRINGHAM

I'm not a Python programmer, but a bit of quick research reveals that you can add a second field to the sort:

if record.seller_ids:

record['seller_ids'] = record.seller_ids.sorted(key = lambda s: (s.price,s.min_qty))

Gargano Dok Scarl

Hi Chris I don't know why, but not work anyway. It is sorted by min_qty before, always. Thank you very much. If anyone have any others solution is appreciated, thanks

Avatar
Chris Kelley
Mejor respuesta

would this work if you updated by import (i dont think it would)

0
Avatar
Descartar
Ray Carnes (ray)

Yes. Create and Update are triggered with data imports, and I tested this particular automation.

¿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
Link RFQs and Quotations
Purchase
Avatar
0
sept 23
3229
Problem with tax included price Resuelto
price
Avatar
1
jun 23
243
With odoo 16 what are the prices for iot box?
price
Avatar
Avatar
1
dic 22
4674
Bill of Entry & Date for Importing Raw Material in Purchase
Purchase
Avatar
1
oct 22
2949
Sales Unit Price Resuelto
price
Avatar
Avatar
1
ene 22
3126
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