Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

How to add data to the Total Amount in Sales Quotation

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
modulespythonxmlcustomizenewbie
1 Svar
9783 Visninger
Avatar
Jayson Wu

Hi,

I'm trying to add 2 more fields on "Sales Quotation" (Shipping and Bank Charges). I'm done with adding the said fields to the form. Now, my problem is, my float fields are not recognized by the function that I created which would add everything up (Total Amount + Shipping + Bank Charges). I've tried adding a number to the Total Amount function and it successfully adds that number.

Here are my codes:

sales_quotation.py

from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
import time
from openerp import pooler
from openerp.osv import fields, osv
from openerp.tools.translate import _
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP, float_compare
import openerp.addons.decimal_precision as dp
from openerp import netsvc

class sale_order(osv.osv):

    def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
        res = super(sale_order, self)._amount_all(cr, uid, ids, field_name, arg, context)
        for order in self.browse(cr, uid, ids, context=context):
            res[order.id]['amount_total'] += 0 **If I tried to replace 0 with a number it adds up, but if I use res[order.id]['banks'] or res[order.id]['shiping'] it won't add up.**
        return res
    
    def _get_order(self, cr, uid, ids, context=None):
        result = {}
        for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context):
            result[line.order_id.id] = True
        return result.keys()
        
    _inherit = 'sale.order'
    _columns = {
        'amount_total': fields.function(_amount_all, digits_compute= dp.get_precision('Sale Price'), string= 'Total', store= {'sale.order.line': (_get_order, None, 10),}, multi= "sums", help= "The total amount"),
        'amount_untaxed': fields.function(_amount_all, digits_compute= dp.get_precision('Sale Price'), string='Untaxed Amount', store= {'sale.order.line': (_get_order, None, 10),}, multi= "sums", help="The amount without tax"),
        'shiping': fields.float('Shiping'),
        'banks': fields.float('Banking'),
    }
sale_order()

sales_quotation_view.xml

<openerp>
    <data>
        <record model="ir.ui.view" id="view_order_form2_inherit">
            <field name="name">sale.order.inherit2</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                    <field name="amount_untaxed" position="before">
                        <group class="oe_subtotal_footer oe_right" colspan="2" name="custom_added">
                            <field name="shiping" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                            <field name="banks" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                        </group>
                    </field>
            </field>
        </record>
    </data>
</openerp>

Thanks!

 

Edit:

I also tried to change the fields Shiping and Banks from fields.float().

        'shiping': fields.function(_amount_all, digits_compute= dp.get_precision('Sale Price'), string='Untaxed Amount', store= {'sale.order.line': (_get_order, None, 10),}, multi= "sums", help="The shipping charge"),

        'banks': fields.function(_amount_all, digits_compute= dp.get_precision('Sale Price'), string='Untaxed Amount', store= {'sale.order.line': (_get_order, None, 10),}, multi= "sums", help="The bank charge amount"),

and replace the computation by:

res[order.id]['amount_total'] += res[order.id]['shiping'] + res[order.id]['banks']

and since if we change the field.float to fields.function the field becomes read only so I added readonly="0" to the xml view.

The shiping and banks are now adding up to the amount total, however, if I apply changes to the shiping and banks, it is not registering (so only the first value of shiping and banks are the ones who are added to the amount total) .

0
Avatar
Kassér
Jayson Wu
Forfatter

@prakash Hi I tried your code, but it is still not adding. Unfortunately, there are no error messages.

Jayson Wu
Forfatter

@prakash, it is now adding. However, I can only do it once. If I typed another value to the boxes, and pressed udpate, it will not change.

Avatar
Prakash
Bedste svar

Try the below code:-

 

 def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
        res = super(sale_order, self)._amount_all(cr, uid, ids, field_name, arg, context)
        for order in self.browse(cr, uid, ids, context=context):
            res[order.id]['amount_total'] += order.amount_total + order.banks + order.shipping
        return res

1
Avatar
Kassér
Enjoying the discussion? Don't just read, join in!

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

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
Update Existing Module To Newest Version in Odoo 12 Løst
modules python xml update_xml odoo12
Avatar
Avatar
1
nov. 20
5501
Why I can't see my custom module file
modules newbie
Avatar
Avatar
1
jul. 23
3526
How to customize with a custom module? Løst
modules customize
Avatar
Avatar
Avatar
Avatar
Avatar
6
apr. 23
34476
How to hide view.xml fields group in Account module with attr
python xml
Avatar
Avatar
Avatar
2
dec. 23
14017
how to remove first empty element from fields.selection Løst
python xml
Avatar
Avatar
Avatar
3
jul. 22
24436
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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