Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

SQL CONSTRAINT ON STOCK.PICKING FIELD OPENERP 7 [SOLVED]

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
3 Risposte
7836 Visualizzazioni
Avatar
TEIMI Yassine

The objects stock.picking.out (Delivery orders) and stock.picking.in (Incomings Shipments), inherits from stock.picking by prototype inheritance, So as to customize the stock.picking.out form view, I added a field on stock.picking, and made it visible juste for stock.picking.out, but now I want to add a sql_constraints unique, to that field, I wrote on stock.picking where the field is decalred : 

_sql_constraints = [('bl_uniq','unique(num_bl)','Physical Delivery order number is unique !')].

But this sql constraint doesn't work, is it due to the prototype inheritance ? if yes what is the solution to overcome this issue ?

0
Avatar
Abbandona
OdooBot
I have tried this , but without sucess ...

2014-12-01 17:37 GMT+00:00 Dhinesh <dvdhinesh.mail@gmail.com>:

A new answer for SQL CONSTRAINT ON STOCK.PICKING FIELD OPENERP 7 has been posted. Click here to access the post.

--

Dhinesh
Sent by Odoo S.A. using Odoo about Forum Post SQL CONSTRAINT ON STOCK.PICKING FIELD OPENERP 7



--

Cordialement

Yassine TEIMI

Ingénieur SI-BI & Consultant technico-fonctionnel ERP 

TEL : 06-56 15 31 47
Dhinesh

Hi, 1) Check whether your table already has any null or duplicated value in it. Constraint will not be applied if you have null or duplicated value in column. 2) Check whether your constraint is applied to the table or not. Pgadmin -> Db -> Table -> Constraints -> Your Constraints.

TEIMI Yassine
Autore

@Dhinesh : I've done a select on "num_bl", the field I want to be unique, it doesn't display any data, while, I am sure I supplied data to this field using the webclient. Is this means that the columns is NULL ? How to access constraints of a table on command line, i'm on ubuntu. @ John: Sorry I don't have enough karma to comment your answer. I performed the sql query that you gave me, but it did'nt work, taking in consideration that the relation is : stock_picking ( the sql table ), the error displayed is : column "stock_picking.num_bl" must appear in the GROUP BY clause or be used in an aggregate function

Med Said BARA

You should read this:https://www.odoo.com/forum/help-1/question/why-sql-constraints-not-working-39549 especially the comment from Ray CARNES

TEIMI Yassine
Autore

@Said : Yes, I have alreadu duplicated data for the field num_bl, should I remove all duplicated data and apply the unique constraint ?

Med Said BARA

Yes, but use it carefully (to avoid any loss of data). The best way to do it is to use a tool like PgAdmin3, and change (or delete) the content of your records. MAKE A BACKUP OF YOUR DATABASE FIRST !!!

Med Said BARA

MAKE A BACKUP OF YOUR DATABASE FIRST !!!

TEIMI Yassine
Autore

@ said : I've already done a backup, I'm working on a test database, one last question , I have also empty values for that field num_bl, according to the advice of Dhinesh, it will cause the same problem no ?

Med Said BARA

I think NO: http://www.postgresql.org/docs/9.0/static/indexes-unique.html and https://www.pgrs.net/2008/01/11/postgresql-allows-duplicate-nulls-in-unique-columns/

TEIMI Yassine
Autore

Yes you're right, thank you guys : @said @john @dhinesh, it worked fine. the cause was the duplicated data on the unique field, null duplicated values don't affect the work of constraint unique. adding to that I was struggling with the field, That i resolved with john in another topic. Thanks.

Avatar
Ivan
Risposta migliore

If unique constraint is to be applied to a table with data, you need to ensure that the table indeed have that column unique (NULL values are not considered).  Try to check the following SQL: SELECT num_bl, COUNT(*) FROM stock.picking HAVING COUNT(*) > 1 and see if there are records aside from NULL value.

0
Avatar
Abbandona
Avatar
Med Said BARA
Risposta migliore

Try with:  _sql_constraints = [('bl_uniq', 'unique (num_bl)', 'Physical Delivery order number is unique !')]

            

0
Avatar
Abbandona
Avatar
TEIMI Yassine
Autore Risposta migliore

This is what I tried at first, I just made a mistake while posting my question, I corrected it. do you have any idea how this can be done in my case ?

0
Avatar
Abbandona
Med Said BARA

Change: bl_uniq to num_bl_uniq

Med Said BARA

How did you defined your field "num_bl" ?

Med Said BARA

First check if the field "num_bl" is created in your table.

Med Said BARA

Second, Check for related errors to sql_constraint violation in your openerp-server.log.

TEIMI Yassine
Autore

I created the field on the top class, "stock.picking", because the inheritance is of type prototype, I changed to num_bl_uniq without any change, I'll have to check the stock.picking table on postgres, if the field is there, it appears on the interface anyway.

Med Said BARA

Yassine, check for any errors message related to sql_constraint violation in your .log file

TEIMI Yassine
Autore

I have a problem with my log file, it's on /var/log/openerp/openerp-server.log, it does'nt display any error, maybe I have to run the openerp server to check the error ?

TEIMI Yassine
Autore

Yes you're right, thank you guys : @said @john @dhinesh, it worked fine. the cause was the duplicated data on the unique field, null duplicated values don't affect the work of constraint unique. adding to that I was struggling with the field, That i resolved with john in another topic. Thanks.

Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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