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

I don't want to skip sequence when deleting RFQ

Suscribirse

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

Se marcó esta pregunta
purchasesequencepurchase_ordersequencenumber
1 Responder
3261 Vistas
Avatar
Oyku Muhammed

I have made a customization that when confirming a sale order, an rfq or more to be created automatically, and when SO is cancelled, the RFQs to be deleted


but I don't want to skip the sequence, for example, if the deleted RFQs have P0004_P0005_P0006

I want the next number to be P0004, not P0007
so i tried to update the sequence next_number but didn't work
here is my code and i would appreciate help

def_action_cancel(self):

​res = super(SaleOrder, self)._action_cancel()

​​purchase_orders = self.env['purchase.order'].search([('source_sale_id',  '=', self.id)])

​sequence_code = 'purchase.order'# Update with the correct sequence code
for po in purchase_orders:

​​for order in po:

​ ​for inv in order.invoice_ids:

​ ​ ​ifinvandinv.state notin ('cancel', 'draft'):

​ ​ ​ ​raise UserError(_("Unable to cancel this sale order. You must first cancel the ""vendor bills related to the RFQs."))

​​po_name = po.name 

​po.write({'state': 'cancel', 'mail_reminder_confirmed': False})

​po.unlink()

​​​sequence = self.env['ir.sequence'].search([ ('code', '=', sequence_code), ('company_id', '=', self.env.company.id) ], limit=1)

​if sequence:

​ ​sequence_number = int(po_name.split('/')[-1])

​ ​next_sequence_number = sequence_number - 1

​ ​sequence.sudo().write({'number_next':

​ ​next_sequence_number})sequence.sudo().write({'number_next_actual': next_sequence_number})
return res



0
Avatar
Descartar
Lars Aam

Why do you have such a requirement? Why not only cancel the RFQ's and not delete? keep the sequence without any gaps.
Btw. If you set up the MTO process for this, I think the RFQ's will be cancelled automatic, if you cancel the sales order.

Avatar
Niyas Raphy (Walnut Software Solutions)
Mejor respuesta

Hi,

This wont be an easy customization, if you don't want a missing sequence better option is to prevent the deletion of RFQ and keep it in cancelled state. You can add necessary code logic for this.

If you go with what you are looking to achieve now,

Lets say we have a sequence values P0001, P0002 ....... P0005 and as per your code, on deleting a record, you are taking the sequence of the record and trying to update the ir.sequence next number value. Think what if you deleted multiple records from different positions ( 0002 0004) at the same ? The method wont be stable, as next number value will be either 0001 or 0003 in order of deletion.


If you need to really achieve this, try to modify and apply your logic in the place of sequence number assignation for the purchase, instead of calling a new sequence from the sequence record, find missing sequence in existing record and assign it for the new records, this will little heavy as you need to check for missing sequence in each creation.


Also in business perspective, if you share the RFQ with some one, and delete it from the system and later when you assign same sequence to different record, it will bring confusion, if later we look into the system with that reference number.


The ideal solution is to keep in cancelled state.


Additionally, you have option inside the ir.sequence called NO GAP in which if user delete the last record, the new number will be on last deleted sequence.


Update:

currently for the new purchase order the sequence is generated by calling this line of code:  vals['name'] = self_comp.env['ir.sequence'].next_by_code('purchase.order', sequence_date=seq_date) or '/'    from the create function.




So you have to rewrite this create method and instead of calling the next number from ir.sequence, check inside your records for missing numbers, if missing number is found, assign that value for newly created record, and only if the missing number is not found, you can get the next number from ir.sequence.


Thanks

1
Avatar
Descartar
Oyku Muhammed
Autor

Thank you for your answer.
I have already tried the no gap but it doesn't do the job,
but can you elaborate more on
"If you need to really achieve this, try to modify and apply your logic in the place of sequence number assignation for the purchase, instead of calling a new sequence from the sequence record, find missing sequence in existing record and assign it for the new records, this will little heavy as you need to check for missing sequence in each creation."

because I don't quite get it.
I am very aware that the requirement is not good in business but sometimes clients want what they want, and I already deployed the cancelling, but it wasn't what they need.

Niyas Raphy (Walnut Software Solutions)

see the updated answer

¿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
edit due date after creating partial purchase order
purchase purchase_order
Avatar
0
may 22
3391
How to change the Quotation, Order, Invoice sequence numbers ? Resuelto
sequence sequencenumber
Avatar
Avatar
Avatar
2
dic 23
29943
Purchase prototype products; What´s your solution?
purchase purchase_order
Avatar
0
jul 24
2452
How to enable Source Document (field label) Origin (field name) Resuelto
purchase purchase_order
Avatar
Avatar
1
nov 20
5222
Configuring Purchase Order Form and Report Resuelto
purchase purchase_order
Avatar
Avatar
1
oct 20
5730
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