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č

Open a View in Pop Up in a one to many relationship

Naroči se

Get notified when there's activity on this post

This question has been flagged
viewpopupcustom_module
1 Odgovori
7750 Prikazi
Avatar
Cyrus Waithaka

Hi good people.

I am creating an addon to add a questionnaire to the partners view. I want this to be done under a "Questionnaire" tab that I have added to the partners view.

I have created the questionnaire model as follows

class customer_questionnaire(osv.osv):

  _name = "customer.questionnaire"

_columns = {
    #'partner': fields.many2one('res.partner', 'Partner', ondelete='cascade', select=1),
    'name': fields.char('Name', size=15, required=True), #several fields

I then extend Partners object as follows to add a questionnaire field:

class Partner(osv.osv):
    '''Partner'''
    _inherit = 'res.partner'
    _columns = {
    'questionnaire': fields.one2many('customer.questionnaire', 'partner', 'Confidential Questionnaire', help="Click to view/edit user's confidential questionnaire."),
    }

Here is the view that is adding the tab under customers page and a questionnaire field with a tree:

<page string='Questionnaire'>
                        <separator string="Customer Questionnaire" colspan="4" />
                        <field name="questionnaire" nolabel="1" colspan="4" readonly="1">
                            <tree string="Questionnaires">
                                <field name="work_hours" />
                                <field name="commute" />
                            </tree>
                            <form string="Questionnaires">
                                <field name="work_hours" />
                                <field name="commute" />
                            </form>
                        </field>
                    </page>

This still doesnt open the questionnaire view in pop up. I suppose I am missing something. What am I doing wrong? Can someone please outline the steps that I need to follow to open the questionnaire when I click on a row in the tab. Like how the contacts tab under company customers is made.

Thank you

 

2
Avatar
Opusti
Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Best Answer

Hello Cyrus,

There are several mistakes which you need to correct.
1. You have to uncomment partner many2one field in customer.questionnaire object.
2. I don't see any fields named "work_hours" and "commute". Instead of them, you have to define "name" field in xml (or create appropriate field in py under customer.questionnaire object)
3. You have to remove readonly attribute from xml.

Corrected code:

Corrected code:

class customer_questionnaire(osv.osv):
    _name = "customer.questionnaire"
    _columns = {
        'partner': fields.many2one('res.partner', 'Partner', ondelete='cascade', select=1),
        'name': fields.char('Name', size=15, required=True), #several fields
    }

<page string='Questionnaire'>
    <separator string="Customer Questionnaire" colspan="4"/>
    <field name="questionnaire" nolabel="1" colspan="4">
        <tree string="Questionnaires">
            <field name="name"/>
        </tree>
        <form string="Questionnaires">
            <field name="name" />
        </form>
    </field>
</page>

2
Avatar
Opusti
Cyrus Waithaka
Avtor

Hi Sudhir, Thank you for your answer. Sorry, I did not paste the entire code. But I have tried your suggestions with no luck. Is the pop up created automatically once I add the relationship field on the view or am I required to define a function that creates the pop up? Here is the entire xml https://www.dropbox.com/s/1vs55p0r18hxzbk/customer_questionaire.xml?dl=0 and then my .py file https://www.dropbox.com/s/9it6dr1drhfqxv9/customer_questionaire.py?dl=0

Sudhir Arya (ERP Harbor Consulting Services)

Yes, system creates pop by default. You just have to define o2m field in xml.

Cyrus Waithaka
Avtor

It's creating the tab and the tree view fine but clicking on the field/rows does not generate the pop up. I have shared a link to download my code. please check it out from this link https://www.dropbox.com/sh/ius9524594pk7l6/AAC5P9UCP1ePmhWmhbjkP9cLa?dl=0 Thank you in advance

Cyrus Waithaka
Avtor

It works now. An add item button is automatically added if you do the relationships properly. The readonly attribute was the issue. I however do not have enough points to vote your answer. Thank you anyway Sudhir :-)

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
How to return a popup when click in validate of account.invoice? Solved
wizard view popup return
Avatar
Avatar
2
mar. 15
10644
How to make pop ups after actions? Solved
popup
Avatar
Avatar
Avatar
2
jul. 25
9797
Odoo10: how to set the tree (list) view as default view for Customers and Products in Sales module Solved
view
Avatar
Avatar
Avatar
Avatar
4
jan. 24
24547
Attrs attribute Solved
view
Avatar
Avatar
2
jan. 24
3386
Translate pop up in Odoo 14
popup
Avatar
0
nov. 23
2119
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