Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Food & Hospitality
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Guest House
    • Distributor nápojů
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Trades
    • Údržbář
    • IT hardware a podpora
    • Solar Energy Systems
    • Výrobce obuvi
    • Úklidové služby
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

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

Odebírat

Get notified when there's activity on this post

This question has been flagged
salesale.order.lineodoo10.0
4 Odpovědi
27536 Zobrazení
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
Zrušit
Avatar
Niyas Raphy (Walnut Software Solutions)
Nejlepší odpověď

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
Zrušit
Avatar
lukondechitula@gmail.com
Nejlepší odpověď

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
Zrušit
Avatar
Ahmed Vahed
Nejlepší odpověď

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
Zrušit
Avatar
Michael Yeung
Nejlepší odpověď

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
Zrušit
Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
How to generate line numbers on quotes Vyřešeno
sale sale.order.line
Avatar
Avatar
1
led 25
4243
How to add freight charges to product cost in sale quoatation
sale sale.order.line
Avatar
Avatar
2
srp 24
6378
What's the use of Allotment Partner in sale order line? Vyřešeno
sale sale.order.line
Avatar
Avatar
Avatar
Avatar
Avatar
6
pro 22
9657
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
čvc 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
úno 19
10919
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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