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
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • 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
    Iní
    • 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
  • Pomoc

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

How to get a value of a field from a another class OdooV8

Odoberať

Get notified when there's activity on this post

This question has been flagged
fieldsget
4 Replies
11056 Zobrazenia
Avatar
Hichem MELIK

Hello,

I am currently creating a module that will display calculations in invoices. The problem is that I do not know how to retrieve values. I read a lot of documentation but I still do not understand how can i do it .


res_config.py

from openerp import models, fields, api

class unite_beneficiaire(models.Model):
_name='unite.beneficiaire.config.settings'
_inherit='res.config.settings'

default_smic=fields.Float(string='Taux horaire du SMIC', default='9.61',default_model='unite.beneficiaire.config.settings')
default_coeff=fields.Float(string='Coefficient',default='0.85',default_model='unite.beneficiaire.config.settings')
default_traitementbrutannuel=fields.Float(string='Traitement brut annuel minimum', default='17169.12',default_model='unite.beneficiaire.config.settings')


account_invoice.py

from openerp import models, api, _, fields

class account_invoice(models.Model):
_inherit='account.invoice'

def _secteur_public(self, cr, uid, ids, context=None):
    _ub = self.pool.get('unite.beneficiaire.config.settings').browse(cr,uid,ids)
    # i want to get the 'default_traitementbrutannuel' and 'ammout_total' value and return :
     # return (ammout_total/default_traitementbrutannuel)
             


ub=fields.Float(string='Unité bénéficiaire',compute='_secteur_public',readonly=True)

I want to get the 'default_traitementbrutannuel' value of 'unite.beneficiaire.config.settings' class and 'ammout_total' value of the current class and return :

(ammout_total/default_traitementbrutannuel)


thank you 

0
Avatar
Zrušiť
Avatar
Janarthanan
Best Answer
create a field in py file,_secteur_public

ub=fields.Float(string='Unité bénéficiaire',compute='_secteur_public',readonly=True)

@api.multi
def _secteur_public(self):   
     for i in self.env['unite.beneficiaire.config.settings'].search([]):
         val=ammout_total/i.default_traitementbrutannuel
     self.answer=val
1
Avatar
Zrušiť
Avatar
Prakash
Best Answer
  1. Not use models.Model of configuration  instead use  models.TransientModel

  2. Define   get_default_fields and set_fields method 

  3. Use ir.values in get_default_fields and set_fields

  4. Now retrieve the data from  self.env['ir.values']


For Using  ir.values you can refer  this  link

https://github.com/odoo/odoo/blob/7682760dcad232829fbb5d4221f66a1ebb9d6c91/addons/website_payment/models/res_config.py

@api.model

def get_default_acquirer(self, fields):

default_acquirer = False

if 'default_acquirer' in fields:

default_acquirer = self.env['ir.values'].get_default('payment.transaction', 'acquirer_id', company_id=self.env.user.company_id.id)

return {

'default_acquirer': default_acquirer

}

@api.multi

def set_default_acquirer(self):

for wizard in self:

ir_values = self.env['ir.values']

if self.user_has_groups('base.group_configuration'):

ir_values = ir_values.sudo()

ir_values.set_default('payment.transaction', 'acquirer_id', wizard.default_acquirer.id, company_id=self.env.user.company_id.id)

Hope it may help in your case.


1
Avatar
Zrušiť
Avatar
Hichem MELIK
Autor Best Answer

i don't get the step 3 & 4 did you have an example ?

0
Avatar
Zrušiť
Prakash

i have update my answer as above refer this link https://github.com/odoo/odoo/blob/7682760dcad232829fbb5d4221f66a1ebb9d6c91/addons/website_payment/models/res_config.py

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 to display a red * for required fields
fields
Avatar
Avatar
Avatar
Avatar
3
máj 25
3481
How to display a red * for required fields
fields
Avatar
Avatar
1
apr 25
2453
one2one relational field Solved
fields
Avatar
Avatar
Avatar
Avatar
3
sep 24
16233
I cannot see custom field in lead form
fields
Avatar
Avatar
2
feb 24
3498
calculated fields
fields
Avatar
Avatar
1
júl 23
3545
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