Block sales orders sharing the same customer reference per client
Description
Prevents saving a sales order whose Customer Reference is already used by another order for the same customer. Empty references stay allowed.
Author
Cloudia
Copyright
Copyright (c) 2025-Present Cloudia Systems S.A.C.
License
OPL-1
Version
18.0.1.1
Dependencies
sale_management
This module is not installed on database prosac18. Screenshots show the standard Referencia del Cliente field and existing duplicate values. After install, saving a clash raises a validation error and a unique index enforces the rule in the database.
2. User instructions
Enter a unique customer reference
Open the quotation or sales order.
Fill Referencia del Cliente (customer PO / external number).
Save. If another order for the same customer already has that value, Odoo blocks the save: The Customer Reference of the sale order must be unique per customer ! (Spanish translation in the module: the same message on the customer reference.)
OV002067: Referencia del Cliente ert3453563 on a confirmed order for ALWA PERU S.A.
Blank references are ignored (several orders may have no reference). The uniqueness is per customer, not company-wide.
What happens on install
If duplicates already exist, install keeps the best row (confirmed/done first, then sent/draft, then others; newest wins inside a band) and renames the rest with a -DUP001, -DUP002, … suffix. Then it creates a unique index on (customer, reference) where the reference is set.
Live example of why that cleanup matters: OV002061 and OV002060 both use alwa0001 for ALWA PERU S.A. — that pair would be split on install.
Pedidos de Ventas filtered by alwa0001: OV002061 and OV002060, same customer, same Referencia del Cliente.
Control de referencia de cliente duplicada
Nombre técnico: cs_sales_order_duplicate
Nombre
Sales Order Duplicate Reference Guard
Resumen
Impide órdenes de venta con la misma referencia de cliente por cliente
Descripción
Evita guardar una orden de venta cuya Referencia del Cliente ya existe en otra orden del mismo cliente. Las referencias vacías siguen permitidas.
Autor
Cloudia
Copyright
Copyright (c) 2025-Present Cloudia Systems S.A.C.
Licencia
OPL-1
Versión
18.0.1.1
Dependencias
sale_management
Este módulo no está instalado en la base prosac18. Las capturas muestran el campo estándar Referencia del Cliente y valores duplicados ya existentes. Tras instalarlo, guardar un choque dispara un error de validación y un índice único lo refuerza en la base.
2. Instrucciones de usuario
Referencia de cliente única
Abra la cotización u orden de venta.
Complete Referencia del Cliente (OC del cliente / número externo).
Guarde. Si otra orden del mismo cliente ya tiene ese valor, Odoo bloquea el guardado: The Customer Reference of the sale order must be unique per customer ! (i18n del módulo: La referencia de cliente del pedido de venta debe ser única por cliente!).
OV002067: Referencia del Cliente ert3453563 en una orden confirmada de ALWA PERU S.A.
Las referencias vacías no cuentan (varias órdenes pueden ir sin referencia). La unicidad es por cliente, no global.
Qué ocurre al instalar
Si ya hay duplicados, la instalación conserva la mejor fila (confirmada/hecha primero, luego enviada/borrador, luego el resto; gana la más nueva dentro del mismo tramo) y renombra las demás con sufijo -DUP001, -DUP002, … Luego crea un índice único en (cliente, referencia) cuando hay referencia.
Ejemplo en vivo de por qué importa esa limpieza: OV002061 y OV002060 usan ambas alwa0001 para ALWA PERU S.A.; al instalar se partirían.
Pedidos de Ventas filtrados por alwa0001: OV002061 y OV002060, mismo cliente, misma Referencia del Cliente.