Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

How to get the field values from another module?

Naroči se

Get notified when there's activity on this post

This question has been flagged
totalamountsaleorder
2 Odgovori
13372 Prikazi
Avatar
William Draper

Hello,

I want to get the field values of the sale order amount_total and will be my input on the next page. Since I will create a new page that will calculate the quotation sales order total amount together its discounts. 

I tried to do this:     total_price = fields.Monetary('sale.order.amount_total', string="Price Initial") 

The result was my odoo went 500 status. compiler error. 

class sale_com(models.Model):
      _inherit ='sale.order'

     total_price = fields.Monetary('sale.order.amount_total', string="Price Initial")  <- this gave me an error

0
Avatar
Opusti
Avatar
Ashish Singh
Best Answer

Hi, William

It is because you are trying to create related field using model name, but a related field required at relational field (Many2one) not model.

So in order to achieve this requirement you can use below ways.

  • Make it computed same as "amount_total" field like below

    • total_price = fields.Monetary(string='Price Initial', store=True, readonly=True, compute='_amount_all', tracking=4)
    • Inherit the "_amount_all" method,

      •     @api.depends('order_line.price_total')
            def _amount_all(self):
                """
                Compute the total amounts of the SO.
                """
                for order in self:
                    amount_untaxed = amount_tax = 0.0
                    for line in order.order_line:
                        amount_untaxed += line.price_subtotal
                        amount_tax += line.price_tax
                    order.update({
                        'amount_untaxed': amount_untaxed,
                        'amount_tax': amount_tax,
                        'amount_total': amount_untaxed + amount_tax,
                        'total_price': amount_untaxed + amount_tax,
                    })
  • Else instead of overriding existing computed method you can define your method like below,

    • total_price = fields.Monetary(string='Price Initial', store=True, readonly=True, compute='_total_price_method', tracking=4)
    • define the "_total_price_method" method,

      •     @api.depends('order_line.price_total')
            def _total_price_method(self):
                for order in self:
                    order.update({
                        'total_price': order.amount_total,
                    })
Feel free to ask in case you have any doubt related to the above point.


Thanks,
Ashish Singh (Team Lead)
Webkul Software Private Limited
1
Avatar
Opusti
Avatar
William Draper
Avtor Best Answer

I am still new to odoo development more like 2 weeks ago. Do you mean Inherit the "_amount_all" method is by creating a new function similar to this? For example:

class sale_commission(models.Model):
    _inherit = 'sale.order'

    
total_price = fields.Monetary(string='Price Initial', store=True, readonly=True, compute='_prod_price', tracking=4) @api.depends('order_line.price_total')

    def _prod_price(self):
        """
        Compute the total amounts of the SO.
        """
        for order in self:
            amount_untaxed = amount_tax = 0.0
            for line in order.order_line:
                amount_untaxed += line.price_subtotal
                amount_tax += line.price_tax
            order.update({
                'amount_untaxed': amount_untaxed,
                'amount_tax': amount_tax,
                'amount_total': amount_untaxed + amount_tax,
                'total_price': amount_untaxed + amount_tax,
            })

Thank you so much.

0
Avatar
Opusti
Ashish Singh

Hi, William

No for inheriting a method you need to define the method with the actual method name "_amount_all" not with the new name and as it is computed method then you need to define the same definition as actual method have.

If you don't want to inherit the existing method then you can simply define you function like below,

@api.depends('order_line.price_total')

def _prod_price(self):

for order in self:

order.update({

'total_price': order.amount_total,

})

Thanks,

Enjoying the discussion? Don't just read, join in!

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
How to modify amount_total from pos_order
order total amount
Avatar
Avatar
Avatar
4
maj 16
5552
How to add a reduction amount to the amount total in POS order
order total amount coupon
Avatar
0
maj 16
5408
Solve "Reference must be unique per company" following step by step Solved
saleorder
Avatar
Avatar
1
apr. 24
4545
How to display 'total' under a column containing numeric values in tree view Solved
total
Avatar
Avatar
1
okt. 24
26806
no currency symbol displayed at net amound and total price
currency price total amount symbol
Avatar
0
okt. 21
3247
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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