Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

Odoo 11 how to remove _sql_constraint in stock.production.lot

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
stocklottracking
3 Besvarelser
11950 Visninger
Avatar
TK

We are using lots to track our products. After purchasing a product we receive it and put the lot number that the vendor stated into the lot number field that has to be filled in when validating the receipt. As an example we have product xy with lot number 1234 on stock. If we have another delivery of that product with an identical lot number Odoo refuses to validate the receipt. Error: 'The combination of serial number and product must be unique!'
This seems to be done via a sql_constraint in stock_production_lot.py in the modul "stock" class Class ProductionLot :

_sql_constraints = [('name_ref_inique', 'unique(name, product_id)', 'The combination of serial number and product must be unique!'),]

I tried to comment the lines out but this does not help. There is another error

IntegrityError : dublicate key value violates unique constraint "stock_production_lot_name_ref_uniq"

DETAIL: Key(name, product_id)=(1234, 18) already exist.


Is there a way to remove that constraint and keep the rest of the functionality? We do not want to disable lots and serial number tracking.

Background: In our business it is quite normal that a vendor sells parts with a certain lot not only in one delivery but in several after another. The lot is often stamped into the part and changing the lot number in Odoo (adding another identification number like the receipt number) would confuse our processes.


1
Avatar
Kassér
Avatar
faOtools
Bedste svar

Hi,

you should both comment the line and remove the constraint from Postgre.

Have a look at: https://www.odoo.com/forum/help-1/question/remove-sql-constraints-5431

Alternatively you may redefine this sql contsraint in your Python class:

class stock_production_lot(models.Model):    
    _inherit = "stock.production.lot"
    _sql_constraints = [('name_ref_inique', 'check(1=1)', 'No error'),]
3
Avatar
Kassér
Avatar
Ibrahim Boudmir
Bedste svar

Hi, 
Just remove the contsraint manually from your python file and from the database. 

try this : 
ALTER TABLE Your_table_name DROP CONSTRAINT Your_constraint_name;

1
Avatar
Kassér
Avatar
TK
Forfatter Bedste svar

Thank you for your answers I did not try them because it turned out that we could solve the problem by ticking an option in the settings of the operation "receipt", field "use_existing_lots" in stock.picking.type.

I am glad that I do not have to alter the database by hand.

0
Avatar
Kassér
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
[V13] easiest way to convert non tracking products to Tracking product even if they have stock on hand! Løst
inventory lot tracking
Avatar
Avatar
Avatar
2
maj 20
3885
How to identify a lot/serial as consumed or unconsumed product using only lot_id
stock lot odoo-10
Avatar
0
apr. 18
3422
assembly of virtual parts
stock manufacturing tracking
Avatar
Avatar
1
jul. 16
4298
production lot number creation
stock tracking production_lot
Avatar
0
mar. 15
6579
stock.pack.operation.lot in Odoo11
stock lot odoo9 odoo11
Avatar
0
maj 21
2812
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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