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
    • E-learning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Sociale media-marketing
    • E-mailmarketing
    • Sms-marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Artificiële Intelligentie
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelwinkel
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Horeca & Hospitality
    • Bar en café
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van mede-eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brouwerij
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Diensten
    • Klusjesman
    • IT-hardware & ondersteuning
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Alle bedrijfstakken bekijken
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijsprogramma
    • Scale Up! Business Game
    • Odoo bezoeken
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Partner worden
    • Diensten voor 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
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

Get customer(partner_id.name) against a order_id

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
inheritancepython2.7odoo
1 Beantwoorden
8874 Weergaven
Avatar
FalconITSol, Hassan Ali

I had inherited a pos.order But i am unable to add customer of current order in it .if anyone know that how i can fetch the Customer by using the order id.I am beginner in odoo and python . But i tried to understand the pos.order class  but i am not successful in it .  

class pos_order (models.Model):

    _inherit = 'pos.order'



    @ api.multi

    def print_pos_report (self):

     return self.env ['report']. get_action (self, 'point_of_sale.pos_invoice_report')




    @ api.multi

    def print_pos_receipt (self):

        output = []

        discount = 0

        order_id = self.search ([('id', '=', self.id)], limit = 1)

        orderlines = self.env ['pos.order.line']. search ([('order_id', '=', order_id.id)])

        payments = self.env ['account.bank.statement.line']. search ([('pos_statement_id', '=', order_id.id)])

        paymentlines = []

        subtotal = 0

        tax = 0

        change = 0

        for payment in payments:

            if payment.amount> 0:

                temp = {

                    'amount': payment.amount,

                    'name': payment.journal_id.name

                }

                paymentlines.append (temp)

            else:

                change + = payment.amount

             

        for orderline in orderlines:

            new_vals = {

                'product_id': orderline.product_id.name,

                'qty': orderline.qty,

                'price_unit': orderline.price_unit,

                'discount': orderline.discount,

                }

                

            discount + = (orderline.price_unit * orderline.qty * orderline.discount) / 100

            subtotal + = orderline.price_subtotal

            tax + = (orderline.price_subtotal_incl - orderline.price_subtotal)

            

            output.append (new_vals)


        return [output, discount, paymentlines, change, subtotal, tax]

0
Avatar
Annuleer
Avatar
Jerome Guerriat
Beste antwoord

Well, since you inherit pos_order, you have access to all fields of pos_order...

So if you want the current partner_id, just use "self.partner_id" (beware not to have multiple records in self...)


By the way, i did not look through your whole code but even in the beginning there are big mistakes ;)


order_id = self.search ([('id', '=', self.id)], limit = 1)

==> why do you do this? If you use "self.id" in the search function, you are searching "yourself"...

you can use order_id = self, or even more easier, user 'self' in place of order_id


orderlines = self.env ['pos.order.line']. search ([('order_id', '=', order_id.id)])

==> again, you do not need to search to achieve this, since you can directly link the lines from "self"

orderlines = self.lines

1
Avatar
Annuleer
FalconITSol, Hassan Ali
Auteur

I am a totally beginner with python and odoo . So i am trying to learn it with quick examples. Thanks for your time . can you suggest me some strong reference which relates to my task(I want reprint the orders at pos session i had successful in listing orders and printing single order now i want to access customer of the order)

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 do for many2one domain filter?
python2.7 odoo
Avatar
5
sep. 20
9863
How to add a list of product in a view?
python2.7 odoo
Avatar
Avatar
1
okt. 19
7961
how to customize one2many field in odoo
python2.7 odoo
Avatar
0
feb. 19
8257
Domain in xml odoo 10
python2.7 odoo
Avatar
Avatar
2
nov. 18
8347
How to modify “return ” to add a tax line in invoice
python2.7 odoo
Avatar
0
mei 18
4600
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
  • Partner worden
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 Svenska ภาษาไทย 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