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
    • Guest House
    • Drankenhandelaar
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Solar Energy Systems
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC Services
    Others
    • Nonprofit Organization
    • 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)
Accounting Invoice #accounting Bank Analytic
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
Accounting Invoice #accounting Bank Analytic
Over dit forum
  1. Accounting
  2. Forum

Computed Field depending on the sum of a column in another model

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
community
2333 Weergaven
Avatar
joules

Hello odoo community, please i am new into odoo and need help. I have a class project_analysis that has project_line_ids field which is a many2one field refrencing another model  AccountInvoiceLine which takes all amount and description per line for single project ( project_analysis). I therefore added a computed field total_amount in the first model and tried to write a function which will refrence the second model so i can calculate all the money spent in a particular project. 

code**



class project_analysis(models.Model): _name = 'fastra.project.analysis' #_inherits = ['account']
    status is used when payments have been registered for the entirety of the invoice in a journal configured to post entries at bank reconciliation only, and some of them haven't been reconciled with a bank statement line yet.\n" " * The 'Paid 'status is set automatically when the invoice is paid. Its related journal entries may or may not be reconciled.\n" " * The 'Cancelled' status is used when user cancel invoice.") date_invoice = fields.Date(string='Date', readonly=True, states={' draft': [('readonly', False)]}, index=True, help="Keep empty to use the current date", copy=False) partner_id = fields.Many2one('res.partner', string='
    vat = fields.Monetary(string='VAT')
    pr = fields.Monetary(string='P.R')
    po_number = fields.Char('PO Number')
    project = fields.Char('Project Name')
    wht = fields.Monetary('WHT')
    invoice_line_ids = fields.One2many('project.analysis.line', 'job_line_ids', string='Project Lines', readonly=True, states={'draft': [('readonly', False)]}, copy=True)
    amount = fields.Monetary('Total Amount Paid')
    amount_total = fields.Float(string='Total Amount', compute='_compute_total_amount', store=False, # optional )

    # method with the value computation logic for book age since the realease date: @api.multi @api.depends('invoice_line_ids.job_line_ids') def _compute_total_amount(self): totalAmount = 0 for a in self.filtered('invoice_line_ids.job_line_ids '): totalAmount += a.amount a.amount_total = totalAmount

class AccountInvoiceLine(models.Model): _name = "project.analysis.line" _description = "Project Line"
    job_id = fields.Many2one('product.product', string ='Job', ondelete='restrict', index=True)
    job_line_ids = fields.Many2one( 'fastra.project.analysis', string='Job Reference', ondelete='cascade', index=True)
    amount = fields.Float(string='Amount', required=True)

    #price_total = fields.Monetary(string='Amount',readonly=True, help="Total amount for the job")
    account_analytic_id = fields.Many2one('account.analytic.account', string='Project Account')
    name = fields.Text(string='Description', required=True)
    account_id = fields.Many2one('account.account', string='Account', domain=[('deprecated', '=', False)], help= "The expense account related to the selected job.")

0
Avatar
Annuleer
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
What’s the best architecture to manage multi-tenant odoo community setup with white-label support?
community
Avatar
Avatar
1
okt. 25
659
refresh screen save data automatically
community
Avatar
Avatar
2
jul. 24
3195
tax location
community
Avatar
Avatar
2
mei 24
8429
can not do invoice in community version
community
Avatar
Avatar
1
feb. 24
2713
Access logs on Odoo Community Opgelost
community
Avatar
Avatar
1
nov. 22
6734
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