Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Help

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

string indices must be integers , many2one

Odoberať

Get notified when there's activity on this post

This question has been flagged
relationship
4 Replies
8187 Zobrazenia
Avatar
huongcute

Hi everybody, I want to ask you a question. I have an error :TypeError: string indices must be integers

code .py

class danh_sach_nv(osv.Model):
    _name = 'danh.sach.nv'
    _rec_name = 'ma_nv'
    

            
    _columns = {
                       'ma_nv':fields.char('Mã NV',size=30),

                       'luong_dc':fields.related('ma_nv', 'luong_dc', type='many2one', relation='dieu.chinh', store=True, string='Lương điều chỉnh', readonly = 'True'),

                  }

class dieu_chinh(osv.Model):
    _name = 'dieu.chinh'

 _columns = {
                    'state': fields.selection([('draft', 'Draft'),('cancel', 'Cancel'),('done', 'Confirmed') ],                                       'Status',readonly=True,track_visibility='onchange'),
                   'image_nv':fields.related('ma_nv', 'image_nv',readonly = 'True', type ='binary', string = 'Ảnh đại diện'),
                   'ma_nv':fields.many2one('danh.sach.nv', 'Mã NV'),

                   'luong_dc':fields.integer('Lương điều chỉnh'),

}

 

 

Can you help me?I dont understan I have why I have an error?

Thank all

0
Avatar
Zrušiť
vadivel

Hi huongcute you must change this line: 'luong_dc':fields.related('ma_nv', 'luong_dc', type='many2one', relation='dieu.chinh', store=True, string='Lương điều chỉnh', readonly = 'True'), instead of ma_nv you must give the class name(many2one).Thats why the error occured...Thank u

vadivel

Sorry other class's(dieu_chinh) field name

Avatar
Anil Kesariya
Best Answer

Here you go!
You have used related field luong_dc from dieu.chinh model which is defined as integer inside, but in danh.sach.nv model as you have use as relational field you have given many2one. but field type must be same. if you are realting each other.

Hope this will helps you.

Anil.

0
Avatar
Zrušiť
Avatar
Emipro Technologies Pvt. Ltd.
Best Answer

Hi,

There is wrong defination of the fields.related.

 _columns = {
                       'ma_nv':fields.char('Mã NV',size=30),

                       'luong_dc':fields.related('ma_nv', 'luong_dc', type='many2one', relation='dieu.chinh', store=True, string='Lương điều chỉnh', readonly = 'True'),

                  }

In the above columns you have define 'ma_nv' is 'fields.char' and then you have define 'luong_dc' as 'fields.relate' to the relation with 'ma_nv'. This is wrong, you can only relate any field with 'many2one' field. So, you have to take 'ma_nv' of 'may2one' type or you have to remove 'luong_dc' from 'fields.related' and make it 'fields.many2one'.

 

 

0
Avatar
Zrušiť
Avatar
Deepa Venkatesh
Best Answer

Before creating a related fields, one should have many2one field ... only then a related relation can be establised..

For example:

              'partner_id': fields.many2one('res.partner', 'Partner')

               'partner_email': fields.related('partner_id', 'email', ....)

As you can see, I have establised a relation to partner object first, then i can establish related for the same....

and also data type/property for the related field should be of target objects' column's data type...

 

0
Avatar
Zrušiť
Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Best Answer

In short you should define related field like this:

 'luong_dc':fields.related('ma_nv', 'luong_dc', type='integer, store=True, string='Lương điều chỉnh', readonly=True),

One more thing, readonly value should not be in string form (readonly='True'). It should be readonly=True.

You can get more idea about Related field.

0
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
how many reated records ?
relationship
Avatar
0
okt 23
1725
Relate to one field OR another (Odoo Studio - odoo.sh v13) Solved
relationship
Avatar
Avatar
3
apr 20
4027
Studio - Dropbox with relation to list of Manufacturing Orders detail? (odoo.sh v13) Solved
relationship
Avatar
1
feb 20
2793
Select field to show relation
relationship
Avatar
Avatar
1
mar 15
4793
Contacts relationship
relationship contacts
Avatar
Avatar
Avatar
2
sep 25
1111
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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