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

Why ean13 is not a field of product_product but it is stored in product_product table?

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
pythonproductean13product.productodooV8
1 Beantwoorden
3532 Weergaven
Avatar
E.M.

ean13 is stored in product_product table:

id | ean13 | create_date | default_code | name_template |    ...   | active

----+---------------+----------------------------+--------------+---------------+------------+-------------------+-----------------+---------------+-----------+----------------------------+--------

  32 | 2910000000185 | 2015-07-11 10:08:14.009873 | | FOOBAR1 | 1 | | 51 | | 1 | 2015-07-11 10:08:14.009873 | t


however, you can not recover ean13 from product_product attributes


print product_fields

[{'ean13': False, 'id': 32, 'name_template': u'FOOBAR1'}]

print product_id32.ean13

False

print product_id32.name_template

FOOBAR1


How do I recover ean13 value for a given product?

 

0
Avatar
Annuleer
Avatar
FEDERICO LEONI
Beste antwoord

Please explain more deeply what you need/want to archive, because I use EAN codes from my external programs every day.

For example, if you need a very simple program for Python based on id search:

import psycopg2, sys, psycopg2.extras
try:
con = psycopg2.connect(host='localhost', database='Database', user='xxxxxx', password='xxxxxx')
cur = con.cursor()
sql_query = 'Select id, name_template, ean13 from product_product where id = %s'
idt = '66'
cur.execute(sql_query,[idt]); product_fields = cur.fetchone()
print product_fields
print 'id:', product_fields[0]
print 'name_template:', product_fields[1]
print 'ean13:', product_fields[2]
except psycopg2.DatabaseError, e:
print 'Error %s' % e
sys.exit(1)
finally:
if con:
con.close()

output :

/usr/bin/python2.7 /home/effe/.PyCharm40/config/scratches/scratch
(66, 'Formaggi', '1002000000003')
id: 66
name_template: Formaggi
ean13: 1002000000003
Process finished with exit code 0

Or from a quick query for a specific EAN13 from Postgres:

Select id, name_template, ean13 from product_product where ean13 = '1002000000003'

 

id
product_template
Ean13
66 
Formaggi
1002000000003

Both examples are simple to edit for your needs. 

0
Avatar
Annuleer
E.M.
Auteur

Thanks for your answer and examples The question arised while trying to modify "create" method to add automatically an EAN13 code when a product is created. As 'ean13' is a field of 'product.product' initially you start modifying 'create' method for 'product.product', but the EAN13 code is actually managed and populated via 'create' method in 'product.template' (so 'create' method for 'product.product' has no visibility on the EAN13 entered by the user). Once business logic is moved into 'create' 'product.template' instead of 'product.product', it is easy to complete the task.

OdooBot

Now is clear.
Since I prefer manage Odoo externally trough Python to have a full control I don't have a deep knowledge of internal coding. Anyway, did you try to inherit the table adding a fields.related or compiling a simple fields.char it via on_change?

E.M.
Auteur

I am not sure if on_change applies here, I have used once for on-the-fly calculations in a form. I guess there might be a way to trigger some code when a new product is added, which might fit in this scenario. Regarding the approach I was looking for, as the field is already there (ean13 in product_product table), it was just a matter of doing something if user has not entered EAN13, so I think that the "right" approach is to modify the method create adding the required logic. There might be other or better approaches though; I am far from having a sound knowledge of Odoo.

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
'ean13' not retrieved from product.product read method
python ean13 model product.product odooV8
Avatar
0
jul. 15
3528
I can't see updated ean13 in product_template why ?
product ean13 odooV8
Avatar
Avatar
1
mei 16
4091
How to modify "default_code" field for a "product_template" provided that you have that "product_template" ID Opgelost
python module product product_code odooV8
Avatar
Avatar
1
feb. 23
9060
Where can product_id be retrieved when a new product is created?
python module product product.id odooV8
Avatar
Avatar
Avatar
Avatar
6
okt. 15
10171
No es posible anular la reserva de más productos que los [Productos] que tiene en existencias.
python product
Avatar
Avatar
Avatar
2
apr. 25
3463
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