Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

How do I select the parent record automatically when I open the form-view created by a one2 many relationship?

Naroči se

Get notified when there's activity on this post

This question has been flagged
one2manyformviewone2many_listodoo12
1 Odgovori
5588 Prikazi
Avatar
Simone

I extended res_partner and linked to a "unique code" model like this:

Partner Model :

class Partner(models.Model): _inherit='res.partner'... anagrafiche_codiceunivoco_ids = fields.One2many('utilitypower.codiceunivoco','id_anagrafica',string ='Anagrafica Codice Univoco')

CodiceUnivoco model:

class CodiceUnivoco(models.Model): _name ='utilitypower.codiceunivoco' _description = 'Codice Univoco' codice = fields.Char('Codice Univoco',required=True) id_anagrafica = fields.Many2one('res.partner', string='Cliente')

Res_partner view :

<xpath expr="//notebook" position="inside">  <page name="codice_univoco" string="Codice Univoco"> <field name="anagrafiche_codiceunivoco_ids" string="Codice Univoco" widget="one2many_list" >  <tree> <field name="codice"></field> </tree> </field> </page>

codiceunivoco_view :

<record id="view_form_codiceunivoco" model="ir.ui.view">  <field name="name">Codice Univoco Form</field>  <field name="model">utilitypower.codiceunivoco</field> <field name="arch" type="xml">  <form string="Codice Univoco"> <header></header> <sheet> <group> <field name="codice"></field> <field name="id_anagrafica" widget="man2one_list" /> </group> </sheet> </form> </field> </record>

what I want is that when from the res_partner view I add a record to "univocal code" (via widget one2many_list) and the module view of "univocal code" opens, the record with the client is set with the one from which I opened the module or in alternatively the customer field is hidden.

How can i do this?

0
Avatar
Opusti
Avatar
faOtools
Best Answer

One2many already adds by default an active partner into the field id_anagrafica. It is done as soon as you save a partner (no when you add a line). In order to show a partner right when you press 'Add a line', add to your field a context:

<field name="anagrafiche_codiceunivoco_ids" context="{'default_id_anagrafica': active_id}"/>

 Hiding a related partner might be also reasonable, since it anyway would be saved. To that end:

<field name="id_anagrafica" invisible="1"/>



1
Avatar
Opusti
Simone
Avtor

thank you for your answer, i tried your first solution and let me know if i correctly understand :

with context i know that i can pass some informations and in this case with default_fieldname we try to set the default value, active_id i guess that is the active id of the partner from wich we open the insert form of a "codiceunivoco".

so in res_partner form_extended view i added:

<field name="anagrafiche_codiceunivoco_ids" string="Codice Univoco" widget="one2many_list" context="{'default_id_anagrafica': active_id}">

<tree>

<field name="codice"></field>

</tree>

</field>

but when i click to add line the many2one_list in "codiceunivoco" form view doesn't have the client selected.

For the second option i forgot to explaine that i have to hide the field when is called by the partner form but it must be visible when the "codiceunivoco" form view is called by another menu_action.

I think that i can do this with context or domain in id_anagrafica but i can't find how to have the partner_id.

Simone
Avtor

First option is exactly what i want, thank you for your answer.

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

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Access One2many fields values?
one2many odoo12
Avatar
Avatar
1
sep. 23
4424
form view was changed when reloading the page
formview odoo12
Avatar
Avatar
2
jul. 22
1494
The operation cannot be completed: - Create/update: a mandatory field is not set. - Delete: another model requires the record being deleted. If possible, archive it instead. Model: Pemesanan Bahan Detail (restaurant.pemesanan_bahan_detail), Field: Bahan (bahan_id
one2many odoo12
Avatar
Avatar
1
sep. 21
27652
tree view for one2Many not populating
one2many one2many_list
Avatar
Avatar
2
okt. 20
3850
Odoo Server Error Expected singleton: gc.level(24, 25) for One2many field Solved
one2many odoo12
Avatar
Avatar
Avatar
2
jul. 20
4846
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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