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)
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

How to compute the sum of order line field and place it in sale order?

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
salesale.order.lineodoo10.0
4 Antwoorden
27579 Weergaven
Avatar
tyrion

I have a sale.order.line field commission_line that computes the commission amount of the product line.

class SaleOrderlineInherited(models.Model):
_inherit = 'sale.order.line'
commission_line_percentage = fields.Float(related='product_id.product_tmpl_id.commission_percentage')
commission_line = fields.Float(string='Commission', compute='get_commission')
@api.depends('commission_line_percentage')
    def get_commission(self):
for record in self:
record['commission_line'] = (record.price_subtotal * record.commission_line_percentage) / 100
return None

The above code runs fine. Next I want to calculate all the sum of commission_line fields to get the total commission from the sale.order. I tried this code.

class CustommSaleOrder(models.Model):
_inherit = 'sale.order'
commission = fields.Char(string='Total Commission', compute='calculate_total_commission')
def calculate_total_commission(self):
print 'came in'
summ = None
for record in self.env['sale.order.line']:
print 'commission'
summ += record.commission_line_percentage
self.env['sale.order'].commission = summ
return None

This doesn't work. How to correct the code so as to get the sum of all commission_line as the total commission?

Thanks in advance.


0
Avatar
Annuleer
Avatar
Niyas Raphy (Walnut Software Solutions)
Beste antwoord

Hi,

Try like this,

@api.depends('order_line.commission_line')
def _commission_amount(self):
for order in self:
comm_total = 0.0
for line in order.order_line:
comm_total += line.commission_line
order.update({'commission': comm_total })


Thanks

5
Avatar
Annuleer
Avatar
lukondechitula@gmail.com
Beste antwoord

Try

@api.depends('order_line')
def _commission_amount(self):
for order in self:
comm_total = 0.0
for line in order.order_line:
comm_total += line.commission_line

0
Avatar
Annuleer
Avatar
Ahmed Vahed
Beste antwoord

Neither of the above worked for me. I created a float variable x_studio_nett_untaxed_total_1 with Related field order_line.x_studio_nett_total - another field I created. It is only using the first line of the order as the total. I have tried both ways above.

Related Field : order_line.x_studio_nett_total

De[endencies : order_line.x_studio_nett_total, x_studio_nett_untaxed_total_1

Computed : 

@api.depends('order_line.x_studio_nett_total')

def _line_total(self) :

for order in self:

  line_total = 0.0

  for line in order.order_line:  

    line_total += line.x_studio_nett_total

  order.update({'x_studio_nett_untaxed_total_1':line_total})

0
Avatar
Annuleer
Avatar
Michael Yeung
Beste antwoord

Sorry for off topic! @Niyas, you are the best! I applied the formula on the total discount for SO with computed field. Sharing for reference...

float field on sale.order.line, x_price_discount_amount;

float field on sale.order, x_price_discount_amount_total, depends=order_line.x_price_discount_amount

for record in self:
  discount_total = 0.0
  for line in record.order_line:  
    discount_total += line.x_price_discount_amount
  record['x_price_discount_amount_total'] = discount_total

It works! Thanks so much.

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
How to generate line numbers on quotes Opgelost
sale sale.order.line
Avatar
Avatar
1
jan. 25
4271
How to add freight charges to product cost in sale quoatation
sale sale.order.line
Avatar
Avatar
2
aug. 24
6388
What's the use of Allotment Partner in sale order line? Opgelost
sale sale.order.line
Avatar
Avatar
Avatar
Avatar
Avatar
6
dec. 22
9683
how to find out where the "record" is stored, in which file and part of the pyton?
sale sale.order.line record sale.order odoo10.0
Avatar
0
jul. 19
669
[odoo 10] How to set a product category field to the sale order line?
sale sale.order.line sale.order sales.order odoo10.0
Avatar
Avatar
Avatar
Avatar
6
feb. 19
10939
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