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

field.function in tree view

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
v6
2 Antwoorden
14405 Weergaven
Avatar
Tajjajt

hi !

I have in my new module a functional field, whene i put it in my tree view i can't open my view.

here the action code :

    <record id="my_module_normal_action" model="ir.actions.act_window">
    <field name="name">My module</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">mymodule</field>
<field name="domain">[('my_field','=',True)]</field>
    <field name="view_type">form</field>
    <field name="view_id" ref="my_module_tree_view"/>
    <field name="search_view_id" ref="my_module_search_form_view"/>
</record>

my code xml :

<record id="my_module_tree_view" model="ir.ui.view">
            <field name="name">my.module.tree</field>
            <field name="model">mymodule</field>
            <field name="type">tree</field>
            <field eval="7" name="priority"/>
            <field name="arch" type="xml">
                <tree string="my module">
                   <field name="my_string"/>
            <field name="my_field"/>
                </tree>
            </field>
        </record>

in my python code :

  'my_field': fields.function(_get_concatenate_values, method=True, string='Reference', type='char'),

this is the function's code :

def _get_concatenate_values(self, cr, uid, ids, field_name, arg, context=None):
            records=self.browse(cr,uid,ids)
            result={}
            for r in records:
                if(r.field1 and r.field2):
                    result[r.id]= str(r.field1.name)+'.'+ str(r.field2.name)
                return result

"my_field"'s value is the concatenation of the two fields :field1 and field2

thanks for your reply.

0
Avatar
Annuleer
Andreas Brueckl

What version of OpenERP are you using? Your field is called 'code' but you use 'my_string' and 'my_module' in the view?

Tajjajt
Auteur

I use V6.0.2 , my feild's name is 'my_field', 'my_sring' is an other field in my module. so I rectify the python code : 'my_field': fields.function(_get_concatenate_values, method=True, string='Reference', type='char'),

Avatar
Lucio
Beste antwoord

In the definition of the action, you need to add:

<field name="view_mode">tree,form</field>

or

<field name="view_mode">form,tree</field>

depending in the order you want the views to be accessed.

(Or maybe just <field name="view_mode">tree</field> if you do not have a form view.)

I think the problem is in your domain statement in the definition of the action!

<field name="domain">[('my_field','=',True)]</field>

I think you are trying to say that it is not empty, but this restriction is satisfied only if the field has the boolean value True. Change it to:

 <field name="domain">[('my_field','&lt;&gt',False)]</field>

This means that is different to False that, I think, is more acccurate.

Hope it helps!

2
Avatar
Annuleer
Tajjajt
Auteur

It dosnt work !!

here a picture of my problem:

[URL=http://www.imagup.com/data/1176824638.html][IMG]http://data.imagup.com/12/1176824638.png[/IMG][/URL]

I have 3 rows but invisible, when I delete the line <field name="my_field"/> from the tree code it works and I have my liste

Tajjajt
Auteur

link to the picture : http://www.imagup.com/data/1176824638.html

Lucio

Without the 'my_field' field it works just fine? What's the message error you are getting?

Tajjajt
Auteur

yes without 'my_fiels' it works fine, i have no msg error, i can't see my data?

Tajjajt
Auteur

any help !!

Lucio

I updated my answer, maybe that is the problem! I do not see any other possibility of change!

Andreas Brueckl

Please update your question with the code of "_get_concatenate_values"

Lucio

Did it work?

Tajjajt
Auteur

no !! I have the same problem.

Tajjajt
Auteur

I updated my question

Avatar
Tony Gu
Beste antwoord

You defined a domain in act_window based on the function field 'my_field', while you didn't define a "fnct_search" search method for that function field.

Update: Another option would be to add store=True to the function field.

0
Avatar
Annuleer
Lucio

As far as I know, store=True will be used for the value of the field to be stored in the database. But, is this necessary to just show it in a tree view and filter the domain? I think it is not, but then again, I am not sure

Andreas Brueckl

For the domain filter only, the store flag is not required. Only if you want to use in the SearchView.

Lucio

Yes, in that case, I see what you are saying! Thanks!

Tajjajt
Auteur

I added "store=True" to my function field but during the installation of the module I get this error :

=================
Traceback (most recent call last):
  File "netsvc.pyo", line 489, in dispatch
  File "service\web_services.pyo", line 599, in dispatch
  File "osv\osv.pyo", line 122, in wrapper
  File "osv\osv.pyo", line 176, in execute
  File "osv\osv.pyo", line 167, in execute_cr
  File "C:\Program Files\OpenERP 6.0\Server\addons\base\module\wizard\base_module_upgrade.py", line 98, in upgrade_module
  File "pooler.pyo", line 60, in restart_pool
Tajjajt
Auteur
  File "pooler.pyo", line 39, in get_db_and_pool
  File "addons\__init__.pyo", line 883, in load_modules
  File "addons\__init__.pyo", line 719, in load_module_graph
  File "addons\__init__.pyo", line 414, in init_module_objects
  File "osv\orm.pyo", line 2651, in _auto_init
  File "osv\orm.pyo", line 378, in get_pg_type
TypeError: int argument required
=============
Tajjajt
Auteur

can you help me plz ?!

joshuajan
def _get_concatenate_values(self, cr, uid, ids, field_name, arg, context=None):
    records=self.browse(cr,uid,ids)
    result={}
    for r in records:
        if(r.field1 and r.field2):
            result[r.id]= str(r.field1.name)+'.'+ str(r.field2.name)
        #return result
    return result

I think there is a problem of you return value.

Tajjajt
Auteur

can anyone help me plz!

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
How to reset default values for a specific user? Opgelost
v6
Avatar
Avatar
1
dec. 17
14356
how to get url of current page Opgelost
v6
Avatar
Avatar
Avatar
2
dec. 23
23504
How to find all the customer invoices that were paid after the due date?
v6
Avatar
Avatar
1
mrt. 15
6924
Limiting access Controls to Allocation requests in Holidays
v6
Avatar
1
mrt. 15
4822
JasperReports won't evaluate null nor 0
v6
Avatar
0
mrt. 15
4536
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