Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

I don't want to skip sequence when deleting RFQ

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
purchasesequencepurchase_ordersequencenumber
1 Répondre
3250 Vues
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
Ignorer
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)
Meilleure réponse

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
Ignorer
Oyku Muhammed
Auteur

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

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
edit due date after creating partial purchase order
purchase purchase_order
Avatar
0
mai 22
3385
How to change the Quotation, Order, Invoice sequence numbers ? Résolu
sequence sequencenumber
Avatar
Avatar
Avatar
2
déc. 23
29936
Purchase prototype products; What´s your solution?
purchase purchase_order
Avatar
0
juil. 24
2452
How to enable Source Document (field label) Origin (field name) Résolu
purchase purchase_order
Avatar
Avatar
1
nov. 20
5217
Configuring Purchase Order Form and Report Résolu
purchase purchase_order
Avatar
Avatar
1
oct. 20
5728
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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