Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

How to store json data with python for Odoo v13?

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
v13
1 Balas
9897 Tampilan
Avatar
Fabian Anguiano

I wrote a simple Flask server that catches JSON data from a Post webhook and creates a sales record within Odoo v13. At the time this solution worked since my Json data only has 2 items that I needed"ItemID" and "ItemQuantity". However, now the Flask server needs to support multiple "ItemID" and "ItemQuantity". I am not sure how to best go about this.

This is the Flask server

from flask import Flask, request, abort
import xmlrpc.client


app = Flask(__name__)


# Tells the server what route and method to use
@app.route('/webhook', methods=['POST'])
def webhook():
    if request.method == 'POST':

 # Cathces the post webhook from 3D Cart and goes in, gets the product sku and the quantity. Assigns them to variables x & quantity

        content = request.json
        changetos = {'700598114683':2,
                     '763736666666':3,
                     '34232323233333':4}
        x = content[0]['OrderItemList'][0]['ItemID']
        x = changetos.get(x, x)
        quantity = content[0]['OrderItemList'][0]['ItemQuantity']
        print(content[0]['OrderItemList'][0]['ItemID'])


# Logs in to Odoo server
        url = ""
        db = "randomDB"
        username = "random"
        password = "random"

        common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
        print(common.version())

        uid = common.authenticate(db, username, password, {})
        print(uid)




 # Takes variables that were saved from the JSON post webhook and plugs into the sales record

        so_id = models.execute_kw(db, uid, password, 'sale.order', 'create', [{
            'partner_id': 10,
            'order_line': [(0, 0, {'product_id':x,'product_uom_qty': quantity})]
        }])

        return '', 200
    else:
        abort(400)


if __name__ == '__main__':
    app.run()

This is the json data that will create a sales record for the first "ItemID" and "ItemQuantity", but will not create one for the second instance of "ItemID" and "ItemQuantity".

[
{
    "InvoiceNumberPrefix": "AB-",
    "InvoiceNumber": 1000,
    "OrderID": 1,
    "CustomerID": 1,
    "OrderDate": "2016-03-17T09:52:38",
    "OrderStatusID": 1,
    "LastUpdate": "2016-03-17T09:52:38",
    "UserID": "John Doe",
    "SalesPerson": "Jane Doe",
    "ContinueURL": "http://www.some-url.com",
    "BillingFirstName": "John",
    "BillingLastName": "Doe",
    "BillingCompany": "3dcart",
    "BillingAddress": "6691 Nob Hill Rd.",
    "BillingAddress2": "Suite 100",
    "BillingCity": "Tamarac",
    "BillingState": "FL",
    "BillingZipCode": "33321",
    "BillingCountry": "US",
    "BillingPhoneNumber": "800-828-6650",
    "BillingEmail": "john@doe.com",
    "BillingPaymentMethod": "Online Credit Card",
    "BillingOnLinePayment": "true",
    "BillingPaymentMethodID": "1",
    "ShipmentList": [
      {
        "ShipmentID": 1,
        "ShipmentLastUpdate": "2016-03-17T09:52:38",
        "ShipmentBoxes": 1,
        "ShipmentInternalComment": "Some comment",
        "ShipmentOrderStatus": 4,
        "ShipmentAddress": "123 Main St.",
        "ShipmentAddress2": "Apt 123",
        "ShipmentAlias": "Someone else",
        "ShipmentCity": "Tamarac",
        "ShipmentCompany": "3dcart",
        "ShipmentCost": 12.15,
        "ShipmentCountry": "US",
        "ShipmentEmail": "someone@3dcart.com",
        "ShipmentFirstName": "Someone",
        "ShipmentLastName": "Else",
        "ShipmentMethodID": 1,
        "ShipmentMethodName": "UPS Ground",
        "ShipmentShippedDate": "2016-03-17",
        "ShipmentPhone": "800-555-1212",
        "ShipmentState": "FL",
        "ShipmentZipCode": "33319",
        "ShipmentTax": 0.00,
        "ShipmentWeight": 1.25,
        "ShipmentTrackingCode": "ABC123",
        "ShipmentUserID": "John Doe",
        "ShipmentNumber": 1,
        "ShipmentAddressTypeID": 1
      },
      {
        "ShipmentID": 2,
        "ShipmentLastUpdate": "2016-03-17T09:52:38",
        "ShipmentBoxes": 1,
        "ShipmentInternalComment": "Another comment",
        "ShipmentOrderStatus": "2",
        "ShipmentAddress": "6691 Nob Hill Rd.",
        "ShipmentAddress2": "Suite 100",
        "ShipmentAlias": "John",
        "ShipmentCity": "Tamarac",
        "ShipmentCompany": "3dcart",
        "ShipmentCost": 7.83,
        "ShipmentCountry": "US",
        "ShipmentEmail": "sjohn@doe.com",
        "ShipmentFirstName": "John",
        "ShipmentLastName": "Doe",
        "ShipmentMethodID": 2,
        "ShipmentMethodName": "USPS Priority",
        "ShipmentShippedDate": "",
        "ShipmentPhone": "800-828-6650",
        "ShipmentState": "FL",
        "ShipmentZipCode": "33321",
        "ShipmentTax": 0.00,
        "ShipmentWeight": 1.25,
        "ShipmentTrackingCode": "ABC123",
        "ShipmentUserID": "John Doe",
        "ShipmentNumber": 2,
        "ShipmentAddressTypeID": 2
      }
    ],
    "OrderItemList": [
      {
        "CatalogID": 1,
        "ItemIndexID": 1,
        "ItemID": "700598114683",
        "ItemShipmentID": 1,
        "ItemQuantity": 7,
        "ItemWarehouseID": 1,
        "ItemDescription": "Sample Product",
        "ItemUnitPrice": 9.99,
        "ItemWeight": 1.25,
        "ItemOptionPrice": 0.00,
        "ItemAdditionalField1": "3dcart internal use only",
        "ItemAdditionalField2": "3dcart internal use only",
        "ItemAdditionalField3": "3dcart internal use only",
        "ItemPageAdded": "Sample-Product.html",
        "ItemDateAdded": "2016-03-17T09:52:38",
        "ItemUnitCost": 4.57,
        "ItemUnitStock": 1,
        "ItemOptions": "Comma separated list of option IDs selected when item was added to cart (example: 123,456,789)",
        "ItemCatalogIDOptions": "Comma separated list of bundled item catalog IDs (example: 123,456,789)"
      },
      {
        "CatalogID": 1,
        "ItemIndexID": 1,
        "ItemID": "763736666666",
        "ItemShipmentID": 2,
        "ItemQuantity": 5,
        "ItemWarehouseID": 1,
        "ItemDescription": "Sample Product",
        "ItemUnitPrice": 9.99,
        "ItemWeight": 1.25,
        "ItemOptionPrice": 0.00,
        "ItemAdditionalField1": "3dcart internal use only",
        "ItemAdditionalField2": "3dcart internal use only",
        "ItemAdditionalField3": "3dcart internal use only",
        "ItemPageAdded": "Sample-Product.html",
        "ItemDateAdded": "2016-03-17T09:52:38",
        "ItemUnitCost": 1.1,
        "ItemUnitStock": 1,
        "ItemOptions": "Comma separated list of option IDs selected when item was added to cart (example: 123,456,789)",
        "ItemCatalogIDOptions": "Comma separated list of bundled item catalog IDs (example: 123,456,789)"
      }
    ],
    "OrderDiscount": 0.00,
    "SalesTax": 0.00,
    "SalesTax2": 0.00,
    "SalesTax3": 0.00,
    "OrderAmount": 39.96,
    "AffiliateCommission": 0.00,
    "TransactionList": [
      {
        "TransactionIndexID": 1,
        "OrderID": 22517,
        "TransactionID": "123XXX123",
        "TransactionDateTime": "2016-03-17T09:52:38",
        "TransactionType": "Authorize",
        "TransactionMethod": "AUTHORIZENET",
        "TransactionAmount": 10.99,
        "TransactionApproval": "SXLXXX",
        "TransactionReference": "rlsjSskdjDD/RpGDKHndihdnD",
        "TransactionGatewayID": 1,
        "TransactionCVV2": "CVVRESPONSE",
        "TransactionAVS": "AVSRESPONSE",
        "TransactionResponseText": "Transaction Response Text",
        "TransactionResponseCode": "Transaction Response Code",
        "TransactionCaptured": 1
      },
      {
        "TransactionIndexID": 1,
        "OrderID": 22517,
        "TransactionID": "123XXX123",
        "TransactionDateTime": "2016-03-17T09:52:38",
        "TransactionType": "Authorize",
        "TransactionMethod": "AUTHORIZENET",
        "TransactionAmount": 10.99,
        "TransactionApproval": "SXLXXX",
        "TransactionReference": "rlsjSskdjDD/RpGDKHndihdnD",
        "TransactionGatewayID": 1,
        "TransactionCVV2": "CVVRESPONSE",
        "TransactionAVS": "AVSRESPONSE",
        "TransactionResponseText": "Transaction Response Text",
        "TransactionResponseCode": "Transaction Response Code",
        "TransactionCaptured": 1
      }
    ],
    "CardType": "Visa",
    "CardNumber": "XXXXXXXXXXXX1111",
    "CardName": "John Doe",
    "CardExpirationMonth": "09",
    "CardExpirationYear": "2019",
    "CardIssueNumber": "XXXXXXXXXXXX1111",
    "CardStartMonth": "01",
    "CardStartYear": "1999",
    "CardAddress": "123 Anywhere St., Small Town, 33333",
    "CardVerification": "123",
    "RewardPoints": "",
    "QuestionList": 
    [
      {
        "OrderID": 1,
        "QuestionID": 1,
        "QuestionTitle": "Security Question",
        "QuestionAnswer": "Cat/Dog",
        "QuestionType": "checkbox",
        "QuestionCheckoutStep": 1,
        "QuestionSorting": 1,
        "QuestionDiscountGroup": 1
      },
      {
        "OrderID": 1,
        "QuestionID": 1,
        "QuestionTitle": "Verification Question",
        "QuestionAnswer": "Wet/Dry",
        "QuestionType": "checkbox",
        "QuestionCheckoutStep": 1,
        "QuestionSorting": 1,
        "QuestionDiscountGroup": 1
      }
    ],
    "Referer": "Google",
    "IP": "123.456.789",
    "CustomerComments": "Customer comments at checkout",
    "InternalComments": "Comments added to the order by the merchant",
    "ExternalComments": "Comments by the merchant that the customer can see"
  }
]

Not sure how to best go about this. I have tried using loops but have not had any success

1
Avatar
Buang
Mai Pham

Hi,

I am struggling with webhook and odoo too and surfing for any ideas. Can you tell me the reason why you have to make another server to catch the webhook and then connect to odoo to do the other stuff? Why can't we just handle the webhook directly via odoo (this is actually the thing I am trying with using odoo controllers but not successful). I don't know whether I am missing something.

Avatar
Muhammad Yusuf
Jawaban Terbai
so_id = models.execute_kw(db, uid, password, 'sale.order', 'create', [{
            'partner_id': 10, }])
lopp over items x
so_line_ids = models.execute_kw(db, uid, password, 'sale.order', 'create', [{ 'product_id':x.product_id,'product_uom_qty':x.product_uom_qty,order_id:so_id.id or so_id
}])
Not sure about the syntax but this is how it works in REST API first create SO then use it's id in SOL then it will be attached to that SO
0
Avatar
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
E-Mail "Branding" in Odoo 13? How to remove Powered by / Sent by Odoo?
v13
Avatar
Avatar
Avatar
2
Jun 24
6330
Error login LinkedIn v13 enterprise
v13
Avatar
Avatar
2
Mar 24
1808
How we can add internal URL link(like browser) in Dashboard? Diselesaikan
v13
Avatar
Avatar
1
Des 22
5330
Scheduled report of an existing view
v13
Avatar
1
Jun 21
3428
res.partner.bank
v13
Avatar
0
Mar 21
4082
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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