Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profit organisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

I don't want to skip sequence when deleting RFQ

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
purchasesequencepurchase_ordersequencenumber
1 Beantwoorden
3252 Weergaven
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
Annuleer
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)
Beste antwoord

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
Annuleer
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

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
edit due date after creating partial purchase order
purchase purchase_order
Avatar
0
mei 22
3387
How to change the Quotation, Order, Invoice sequence numbers ? Opgelost
sequence sequencenumber
Avatar
Avatar
Avatar
2
dec. 23
29939
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) Opgelost
purchase purchase_order
Avatar
Avatar
1
nov. 20
5218
Configuring Purchase Order Form and Report Opgelost
purchase purchase_order
Avatar
Avatar
1
okt. 20
5730
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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