Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Consulting
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

one2many field show possible unexisting records in view

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
treeviewone2manyvirtual-record
1 Atsakyti
2907 Rodiniai
Portretas
That Guy

Hello,

Odoo V16.

Let's say that I have a new model called Characteristcs and a model ProductCharacteristics that should connect the Product with the Characteristics and contain the value for specific product for chosen characteristic. So the three models look like this:

class ProductTemplate(models.Model):
_inherit = "product.template"

product_characteristic_id = fields.One2many(
comodel_name="product.characteristic", inverse_name="product_template_id", auto_join=True
)


class Characteristics(models.Model):
_name = "characteristics"

name = fields.Char(string="Name", required=True, translate=True)
is_comparable = fields.Boolean(string="Used for Comparison", default=False)


class ProductCharacteristic(models.Model):
_name = "product.characteristic"

product_template_id = fields.Many2one("product.template")
characteristic_id = fields.Many2one("characteristics")
value = fields.Text("Value", required=True)

Now I want to show the possible characteristics on the products form view but I want to show all possible characteristics for a given product in one form/table (whatever possible) so the user does not need to click on the tree view and select a Characteristic that he wants to fill the value for (see pic):


so I get this if I only add the to the product_template view extension xml.

But I want to have this table prefilled. So when the user opens the tab with Characteristics he sees something like this:

And he'll only fill in the values for the characteristics that he wants to fill.

So the main problem is that there are no records in the ProductCharacteristic model for the product in the beginning and thus I can not show this.

So basically I need to somehow prefill the tree with all these possible values.

Can somebody guide me on where to look?

I tried overwriting the read methods (this seems too hacky), investigated the _get_view, but to no avail. Probably I'm just not finding the right method in which I should plug the virtual records so they are displayed in the form..

Would love any comments or thought on the matter :)


0
Portretas
Atmesti
Portretas
Joshi Drishti
Best Answer

Hello Vasil Stoev,

You can try default_get method. The default_get method collects the default values for all the fields when creating new records.

I think this will help you.

Thanks and Regards,

Drishti Joshi

0
Portretas
Atmesti
That Guy
Autorius

Thanks for the suggestion, Drishti Joshi!
The problem with default_get is that it is called only on record creation.
In my case this would mean if I create a new Characteristic I won't be able to show it on existing products if I overwrite default_get for the Product :(

Joshi Drishti

So in this case you can do one thing while creating new characteristics so you can update characteristics to all existing products.
Try once might be this will help you.

That Guy
Autorius

Yep - I can do that. But I can basically plug in the same logic in the create method of the characteristics then.
So currently I have workarounds using the read or the default_get methods but both of those workarounds create actual records (with empty values so the fields are empty in the view). But the ideal would be to not create the records if the User has not entered any values.. Still thinking on how this could be done :(
If it was an editable kanban view I could probably set some fake records and show them as a custom structure (some divs labels with forms in a t-foreach) and then somehow save them.. although this doesn't sound perfect either.

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

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

Registracija
Related Posts Replies Rodiniai Veikla
how to add a button in a one2many tree view Solved
treeview one2many
Portretas
Portretas
Portretas
Portretas
Portretas
4
gruod. 23
18576
Display One2many field value in tree view (Odoo 9)
treeview one2many
Portretas
Portretas
1
rugs. 16
8052
editable treeview without ability to add new items
treeview one2many
Portretas
0
kov. 15
4319
How to display related fields of one2many field in list view?
treeview one2many relations
Portretas
0
rugs. 24
296
Remove from tree view record created with (0,0, {})
treeview one2many flag
Portretas
1
bal. 22
3751
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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