Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

How to add data to the Total Amount in Sales Quotation

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
modulespythonxmlcustomizenewbie
1 Antworten
9743 Ansichten
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
Verwerfen
Jayson Wu
Autor

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

Jayson Wu
Autor

@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
Beste Antwort

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
Verwerfen
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
Update Existing Module To Newest Version in Odoo 12 Gelöst
modules python xml update_xml odoo12
Avatar
Avatar
1
Nov. 20
5466
Why I can't see my custom module file
modules newbie
Avatar
Avatar
1
Juli 23
3480
How to customize with a custom module? Gelöst
modules customize
Avatar
Avatar
Avatar
Avatar
Avatar
6
Apr. 23
34378
How to hide view.xml fields group in Account module with attr
python xml
Avatar
Avatar
Avatar
2
Dez. 23
13938
how to remove first empty element from fields.selection Gelöst
python xml
Avatar
Avatar
Avatar
3
Juli 22
24352
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Ausbildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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