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-profitorganisatie
    • 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

Make a fake many2one field without storing it to the database?

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
storemany2onerelatedstore=False
3 Antwoorden
7951 Weergaven
Avatar
Eric

Hello, 

   Is there a way you can have a fake many2one field on a model without storing it on the database?  I know the related field will do this, but the problem with that is it also changes the related record's value once I make a change to the related field and I dont want to do that.

For example, lets say I have a related field named 'company_rel' which is linked to a partner_id (many2one) field that points to the company_id field like this:

     'company_rel': fields.related('partner_id', 'company_id', relation='res.company', type='many2one', string='company')

If I add the company_rel field to the form view, and change the value, then it also changes the value for the related partner as well, which is what I dont want to do. 

I also tried using the dummy field type, which almost works, but when I make a selection from the drop down list, it returns a False value when I try to use the selected id in another method.

I also tried making a regular many2one field where I set the store=False attribute, but that didnt work either 

Is there a way to make a fake many2one field so that I can use the selected id in another method without storing it to the field to the database?

0
Avatar
Annuleer
Axel Mendoza

How are you trying to use the selected value of the many2one?. Dummy should work, please expose the use that you need to do with the fake field many2one

Avatar
Eric
Auteur Beste antwoord


0
Avatar
Annuleer
Axel Mendoza

That solution is not thread safe because multiple users using the same form will be replacing the value of the _new_dummy_id_variable property of the class. How you need to call another_method method? beause dummy fields will lost it's value only when you save the form because of the set void method. Used in on_changes or to filter others fields it will work until you save and load the form again

Axel Mendoza

If you don't describe properly what you need, we are blind to give you a solution

Eric
Auteur

That is true. I didn't think about other users possibly changing the property at the same time. What I am trying to do is check what the partners pricelist is set to before creating a new sales order. If the partner has a 'Manual' pricelist selected for them, then a dialog opens up prompting the user to select another valid pricelist for the order so that the right pricing is calculated for the products. Otherwise it creates the order with the other valid pricelists. The point of the dummy field is to list the other pricelists for the user to choose from without actually changing it on the partner record. So when the dialog opens, it displays the dummy pricelist field for the user to select, then creates the order with the new pricelist id. Im just not sure how to do this in odoo without adding a many2one field on the database. Thank you for your help

Axel Mendoza

solved?

Avatar
Temur
Beste antwoord

Try to use computed field, with combination of all tree: compute='_my_compute_func', inverse='_my_inverse_func' and store=False, in this case it will be "fake" field as you refer to it and will not be saved to database. you can use selected id inside of _my_inverse_func, OR in addition of this combination, you can have onchange function on this field as well... in the later case, if your application logic is applied under onchange function, then inverse function should present anyway, but it can be simple placeholder (just to allow editing of field in UI) as:

@api.multi
def _my_inverse_func(self):
    pass

...
NOTE: that onchange way will work only if you'll use selected id immediately, while user edits the UI. if you're planing to access this field later from the code, then you should stick with the first option and properly implement both, compute and inverse functions, i.e. _my_compute_func must compute value of this field (the id) and assign it to the field. then it'll not return "false" as in your case.

0
Avatar
Annuleer
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
Many2one related field Opgelost
many2one related
Avatar
Avatar
3
sep. 21
10149
Representation of Many2one in view Opgelost
many2one related
Avatar
Avatar
Avatar
4
jan. 20
3889
More than one Many2one fields on same model + related fields
many2one related
Avatar
0
nov. 18
5086
how can i get the wage field in "hr.contract" value into the "hr.employee" "hr_wage" field is it possible with many2one and related ? TypeError: Model 'hr.employee' inherits from non-existing model 'hr.contract'.
many2one related
Avatar
0
apr. 17
4560
KeyError: 'Field name referenced in related field definition does not exist.' Opgelost
many2one related 15
Avatar
Avatar
1
jan. 25
3012
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