Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Food & Hospitality
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Guest House
    • Distributor nápojů
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Trades
    • Údržbář
    • IT hardware a podpora
    • Solar Energy Systems
    • Výrobce obuvi
    • Úklidové služby
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

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

Odebírat

Get notified when there's activity on this post

This question has been flagged
pythonproductean13product.productodooV8
1 Odpovědět
3529 Zobrazení
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
Zrušit
Avatar
FEDERICO LEONI
Nejlepší odpověď

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
Zrušit
E.M.
Autor

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.
Autor

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.

Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
'ean13' not retrieved from product.product read method
python ean13 model product.product odooV8
Avatar
0
čvc 15
3526
I can't see updated ean13 in product_template why ?
product ean13 odooV8
Avatar
Avatar
1
kvě 16
4087
How to modify "default_code" field for a "product_template" provided that you have that "product_template" ID Vyřešeno
python module product product_code odooV8
Avatar
Avatar
1
úno 23
9055
Where can product_id be retrieved when a new product is created?
python module product product.id odooV8
Avatar
Avatar
Avatar
Avatar
6
říj 15
10170
No es posible anular la reserva de más productos que los [Productos] que tiene en existencias.
python product
Avatar
Avatar
Avatar
2
dub 25
3461
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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