Siirry sisältöön
Odoo Menu
  • Kirjaudu sisään
  • Kokeile ilmaiseksi
  • Sovellukset
    Talous
    • Kirjanpito
    • Laskutus
    • Kulut
    • Datataulukot (BI)
    • Asiakirjat
    • Allekirjoita
    Myynti
    • CRM
    • Myynti
    • Kassajärjestelmä myymälään
    • Kassajärjestelmä ravintolaan
    • Tilaukset
    • Vuokraus
    Verkkosivut
    • Verkkosivun Rakennustyökalu
    • Verkkokauppa
    • Blogi
    • Foorumi
    • Livechat
    • Verkko-oppiminen
    Toimitusketju
    • Varastointi
    • Tuotanto
    • Tuotteen elinkaaren hallinta (PLM)
    • Ostot
    • Huolto
    • Laatu
    Henkilöstöhallinto
    • Työntekijät
    • Rekrytointi
    • Vapaat
    • Arvioinnit
    • Suositukset
    • Kuljetuskalusto
    Markkinointi
    • Somemarkkinointi
    • Sähköpostimarkkinointi
    • Tekstiviestimarkkinointi
    • Tapahtumat
    • Markkinoinnin automaatio
    • Kyselyt
    Palvelut
    • Projekti
    • Työaikakirjaukset
    • Kenttähuolto
    • Asiakaspalvelu
    • Suunnittelu
    • Ajanvaraukset
    Tuottavuus
    • Viestintä
    • Hyväksynnät
    • IoT
    • IP-puhe
    • Tietokirjasto
    • WhatsApp
    Kolmannen osapuolen sovellukset Odoo-Studio Odoo-Pilvialusta
  • Toimialat
    Vähittäiskauppa
    • Kirjakauppa
    • Vaatekauppa
    • Huonekaluliike
    • Ruokakauppa
    • Laitteistokauppa
    • Lelukauppa
    Ruoka & Majoitus
    • Baari ja Pubi
    • Ravintola
    • Pikaruoka
    • Majatalo
    • Juomien jakelija
    • Hotelli
    Kiinteistöt
    • Kiinteistönvälitystoimisto
    • Arkkitehtitoimisto
    • Rakentaminen
    • Kiinteistönhallinta
    • Puutarhanhoito
    • Kiinteistön omistajien yhdistys
    Konsultointi
    • Tilitoimisto
    • Odoo-kumppani
    • Markkinointitoimisto
    • Lakitoimisto
    • Osaajahankinta
    • Tilintarkastus & sertifiointi
    Tuotanto
    • Tekstiili
    • Metalli
    • Huonekalut
    • Ruoka
    • Panimo
    • Yrityslahjat
    Terveys & Liikunta
    • Urheiluseura
    • Silmälasiliike
    • Kuntokeskus
    • Hyvinvointialan ammattilaiset
    • Apteekki
    • Kampaamo
    Kaupat
    • Yleismies
    • IT-laitteisto & Tuki
    • Aurinkoenergiajärjestelmät
    • Suutari
    • Siivoustarvikkeet
    • LVI-palvelut
    Muut
    • Voittoa tavoittelematon järjestö
    • Ympäristötoimisto
    • Mainostaulujen vuokraus  
    • Valokuvaus
    • Leasing-pyörät
    • Ohjelmistojen jälleenmyyjä
    Selaa kaikkia toimialoja
  • Yhteisö
    Opi
    • Tutoriaalit
    • Dokumentaatio
    • Todistukset
    • Koulutus
    • Blogi
    • Podcast
    Kannusta kouluttautumaan
    • Koulutusohjelmat
    • Scale Up! Liiketoimintapeli
    • Vieraile Odoolla
    Hanki ohjelmisto
    • Lataa
    • Vertaile versioita
    • Julkaisut
    Tee yhteistyötä
    • Github
    • Foorumi
    • Tapahtumat
    • Käännökset
    • Ryhdy kumppaniksi
    • Kumppanipalvelut
    • Rekisteröi tilitoimistosi
    Hanki palveluja
    • Löydä kumppani
    • Löydä kirjanpitäjä
    • Varaa asiantuntijatapaaminen
    • Implementaatiopalvelut
    • Asiakasreferenssit
    • Tuki
    • Versionkorotukset
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Varaa demo
  • Hinnoittelu
  • Asiakaspalvelu

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

  • CRM
  • e-Commerce
  • Kirjanpito
  • Varastointi
  • PoS
  • Projekti
  • MRP
All apps
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Kaikki kirjoitukset Ihmiset Merkit
Tunnisteet (Näytä kaikki)
odoo accounting v14 pos v15
Tietoa tästä foorumista
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Kaikki kirjoitukset Ihmiset Merkit
Tunnisteet (Näytä kaikki)
odoo accounting v14 pos v15
Tietoa tästä foorumista
Apua

Product attributes / dimensions / property structure: Best design?

Tilaa

Saat ilmoituksen, kun tähän viestiin ilmaantuu aktiviteettia

Tämä kysymys on merkitty
databaseinheritancev7ormstructure
11124 Näkymät
Avatar
CB

In an MRP context, I have several products that have varying attributes I need to keep track of. For example, we have Doors that need to track edge profiles / wood species / panel types and drawer pulls that we need to track, say, material and shape.

One approach would be to append all of the data to product.product:

class product_product(osv.osv):
    _name = _inherit = 'product.product'
    _columns = {
        'product_type': fields.selection(('', ''), ('door', 'Door'), ('pull', 'Pull')),
        'door_edge_profile': fields.char(size=40),
        'door_wood_species': fields.char(size=40),
        'pull_material': fields.char(size=40),
        'pull_shape': fields.char(size=40),
    }

This approach works, but is rather denormalized - all products have these extra fields, and they may or may not be used. The data is stored as columns appended to product.product.

Another approach is a separate class per product type:

class product_door(osv.osv):
    _name = 'product.product.door',
    _inherit = 'product.product',
    _columns = {
        'door_edge_profile': fields.char(size=40),
        'door_wood_species': fields.char(size=40),
    }

class product_pull(osv.osv):
    _name = 'product.product.pull',
    _inherit = 'product.product',
    _columns = {
        'pull_material': fields.char(size=40),
        'pull_shape': fields.char(size=40),
    }

This approach also works, but the data is now split between two tables, with a product_id column hanging off the child tables. This is nice because the code is easy to separate / deal with, but makes the UI component harder - The end user will need to visit a different section when editing door or pull details, and none of the existing views will incorporate any data about the door or product.

A third approach i've discovered is a little hacky, but works:

class product_door(osv.osv):
    _name = 'product.product.door',
    _columns = {
        'door_edge_profile': fields.char(size=40),
        'door_wood_species': fields.char(size=40),
    }

class product_pull(osv.osv):
    _name = 'product.product.pull',
    _columns = {
        'pull_material': fields.char(size=40),
        'pull_shape': fields.char(size=40),
    }


class product_product(osv.osv):
    _name = _inherit = 'product.product'
    _inherits = {
        'product.product.door': 'door_id',
        'product.product.pull': 'pull_id',
    }

This approach keeps the data in it's own tables, and composes the fields into the product instance. The effect on the UI is the same as option 2 (in that it's somewhat negative), and the data is nicely separated. However, this implies again that every product has door or pull attributes in terms of the db design.

I really like SQLAlchemy's inheritance mapping, so i'll use those names when i'm talking about them further.

The first example I showed, which seems like the "default way" people seem to add to OpenERP models, is single table inheritance.

The second example is Joined Table Inheritance, where the child tables point to their parent.

The third example is 'backwards' joined table inheritance, or composition.

====

Separate from these concerns is using, say, product_variant_multi and encode the product attributes as Dimensions. Or, one could not use Dimensions, and instead apply 'mrp.property' properties to the product. This is more of an EAV data store, but I'm not certain that this complexity is worth it.


So, how do most OpenERP users generally model their databases?

Thanks for the advice.

7
Avatar
Hylkää
Gabriel

Thanks CB for the summary. That's a very pertinent question when we are dealing with large range of product and attributes!

However, I could not get your third example working on v7. Are you sure we can have both Class inheritance (same name (product.product)) and multiple inheritance from other tables at the same time, without changing the final table name? But that would be great as existing views would still be working.

I would add to the possible designs, the product_custom_attributes module.

Looking forward to reading other OpenERP users suggestions.

CB
Tekijä

I believe the third method works, as OpenERP considers the composed columns as part of this object's columns via orm.BaseModel._get_column_infos. I think this would allow views and code to treat the columns in much the same way that normal columns in the first method would work. However, _inherits does not allow one to propagate method calls. The reason is the commented method orm.BaseModel.__getattr__ which has a note about breaking super(). Also, specifically in orm.BaseModel._read_flat, you can see that it iterates over the _inherits tables and adds the data to read()'s result.

Nautitko keskustelusta? Älä vain lue, vaan osallistu!

Luo tili jo tänään nauttiaksesi yksinoikeusominaisuuksista ja osallistuaksesi mahtavaan yhteisöömme!

Rekisteröidy
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
What is the ORM used in version 7 of OpenERP? Ratkaistu
database v7 orm
Avatar
Avatar
Avatar
9
helmik. 17
12161
How to select a different database on login screen Ratkaistu
database v7
Avatar
4
heinäk. 24
33918
Creating database results in "database already exists"
database v7
Avatar
Avatar
1
maalisk. 15
8408
write/create id database
database orm
Avatar
Avatar
1
maalisk. 15
6053
How to select one database by default ? Ratkaistu
configuration database v7
Avatar
Avatar
Avatar
Avatar
Avatar
6
heinäk. 24
84758
Yhteisö
  • Tutoriaalit
  • Dokumentaatio
  • Foorumi
Avoin lähdekoodi
  • Lataa
  • Github
  • Runbot
  • Käännökset
Palvelut
  • Odoo.sh hosting
  • Tuki
  • Versionkorotus
  • Räätälöidyt kehitykset
  • Koulutus
  • Löydä kirjanpitäjä
  • Löydä kumppani
  • Ryhdy kumppaniksi
Meistä
  • Yrityksemme
  • Tavaramerkki
  • Ota yhteyttä
  • Työpaikat
  • Tapahtumat
  • Podcast
  • Blogi
  • Asiakkaat
  • Oikeudellinen ilmoitus • Yksityisyys
  • Tietoturva
الْعَرَبيّة 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 on kokoelma avoimen lähdekoodin yrityssovelluksia, jotka kattavat kaikki yrityksesi tarpeet: asiakkuudenhallinta eli CRM, verkkokauppa, kirjanpito, varastointi, kassajärjestelmä, projektinhallinta, jne.

Odoon uniikki arvolupaus on olla samanaikaisesti erittäin helppokäyttöinen ja täysin integroitu.

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