Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Help

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

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

Odoberať

Get notified when there's activity on this post

This question has been flagged
pythonproductean13product.productodooV8
1 Odpoveď
3526 Zobrazenia
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šiť
Avatar
FEDERICO LEONI
Best Answer

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šiť
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!

Registrácia
Related Posts Replies Zobrazenia Aktivita
'ean13' not retrieved from product.product read method
python ean13 model product.product odooV8
Avatar
0
júl 15
3524
I can't see updated ean13 in product_template why ?
product ean13 odooV8
Avatar
Avatar
1
máj 16
4086
How to modify "default_code" field for a "product_template" provided that you have that "product_template" ID Solved
python module product product_code odooV8
Avatar
Avatar
1
feb 23
9032
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
10162
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
3457
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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