Siirry sisältöön
Odoo Menu
  • Kirjaudu sisään
  • Kokeile ilmaiseksi
  • Sovellukset
    Talous
    • Kirjanpito
    • Laskutus
    • Kulut
    • Datataulukot (BI)
    • Asiakirjat
    • Allekirjoita
    Myynti
    • CRM
    • Myynti
    • Kassajärjestelmä myymälään
    • Kassajärjestelmä ravintolaan
    • Tilaukset
    • Vuokraus
    Verkkosivut
    • Verkkosivun Rakennustyökalu
    • Verkkokauppa
    • Blogi
    • Foorumi
    • Livechat
    • Verkko-oppiminen
    Toimitusketju
    • Varastointi
    • Tuotanto
    • Tuotteen elinkaaren hallinta (PLM)
    • Ostot
    • Huolto
    • Laatu
    Henkilöstöhallinto
    • Työntekijät
    • Rekrytointi
    • Vapaat
    • Arvioinnit
    • Suositukset
    • Kuljetuskalusto
    Markkinointi
    • Somemarkkinointi
    • Sähköpostimarkkinointi
    • Tekstiviestimarkkinointi
    • Tapahtumat
    • Markkinoinnin automaatio
    • Kyselyt
    Palvelut
    • Projekti
    • Työaikakirjaukset
    • Kenttähuolto
    • Asiakaspalvelu
    • Suunnittelu
    • Ajanvaraukset
    Tuottavuus
    • Viestintä
    • Hyväksynnät
    • IoT
    • IP-puhe
    • Tietokirjasto
    • WhatsApp
    Kolmannen osapuolen sovellukset Odoo-Studio Odoo-Pilvialusta
  • Toimialat
    Vähittäiskauppa
    • Kirjakauppa
    • Vaatekauppa
    • Huonekaluliike
    • Ruokakauppa
    • Laitteistokauppa
    • Lelukauppa
    Ruoka & Majoitus
    • Baari ja Pubi
    • Ravintola
    • Pikaruoka
    • Majatalo
    • Juomien jakelija
    • Hotelli
    Kiinteistöt
    • Kiinteistönvälitystoimisto
    • Arkkitehtitoimisto
    • Rakentaminen
    • Kiinteistönhallinta
    • Puutarhanhoito
    • Kiinteistön omistajien yhdistys
    Konsultointi
    • Tilitoimisto
    • Odoo-kumppani
    • Markkinointitoimisto
    • Lakitoimisto
    • Osaajahankinta
    • Tilintarkastus & sertifiointi
    Tuotanto
    • Tekstiili
    • Metalli
    • Huonekalut
    • Ruoka
    • Panimo
    • Yrityslahjat
    Terveys & Liikunta
    • Urheiluseura
    • Silmälasiliike
    • Kuntokeskus
    • Hyvinvointialan ammattilaiset
    • Apteekki
    • Kampaamo
    Kaupat
    • Yleismies
    • IT-laitteisto & Tuki
    • Aurinkoenergiajärjestelmät
    • Suutari
    • Siivouspalvelut
    • LVI-palvelut
    Muut
    • Voittoa tavoittelematon järjestö
    • Ympäristötoimisto
    • Mainostaulujen vuokraus  
    • Valokuvaus
    • Leasing-pyörät
    • Ohjelmistojen jälleenmyyjä
    Selaa kaikkia toimialoja
  • Yhteisö
    Opi
    • Kurssit
    • Dokumentaatio
    • Todistukset
    • Koulutus
    • Blogi
    • Podcast
    Kannusta kouluttautumaan
    • Koulutusohjelmat
    • Scale Up! Liiketoimintapeli
    • Vieraile Odoolla
    Hanki ohjelmisto
    • Lataa
    • Vertaile versioita
    • Julkaisut
    Tee yhteistyötä
    • Github
    • Foorumi
    • Tapahtumat
    • Käännökset
    • Ryhdy kumppaniksi
    • Kumppanipalvelut
    • Rekisteröi tilitoimistosi
    Hanki palveluja
    • Löydä kumppani
    • Löydä kirjanpitäjä
    • Varaa asiantuntijatapaaminen
    • Implementaatiopalvelut
    • Asiakasreferenssit
    • Tuki
    • Versionkorotukset
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Varaa demo
  • Hinnoittelu
  • Asiakaspalvelu

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

  • CRM
  • e-Commerce
  • Kirjanpito
  • Varastointi
  • PoS
  • Projekti
  • MRP
All apps
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Kaikki kirjoitukset Ihmiset Merkit
Tunnisteet (Näytä kaikki)
odoo accounting v14 pos v15
Tietoa tästä foorumista
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Kaikki kirjoitukset Ihmiset Merkit
Tunnisteet (Näytä kaikki)
odoo accounting v14 pos v15
Tietoa tästä foorumista
Apua

How to store json data with python for Odoo v13?

Tilaa

Saat ilmoituksen, kun tähän viestiin ilmaantuu aktiviteettia

Tämä kysymys on merkitty
v13
1 Vastaa
9906 Näkymät
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
Hylkää
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
Paras vastaus
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
Hylkää
Nautitko keskustelusta? Älä vain lue, vaan osallistu!

Luo tili jo tänään nauttiaksesi yksinoikeusominaisuuksista ja osallistuaksesi mahtavaan yhteisöömme!

Rekisteröidy
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
E-Mail "Branding" in Odoo 13? How to remove Powered by / Sent by Odoo?
v13
Avatar
Avatar
Avatar
2
kesäk. 24
6330
Error login LinkedIn v13 enterprise
v13
Avatar
Avatar
2
maalisk. 24
1814
How we can add internal URL link(like browser) in Dashboard? Ratkaistu
v13
Avatar
Avatar
1
jouluk. 22
5337
Scheduled report of an existing view
v13
Avatar
1
kesäk. 21
3433
res.partner.bank
v13
Avatar
0
maalisk. 21
4101
Yhteisö
  • Kurssit
  • Dokumentaatio
  • Foorumi
Avoin lähdekoodi
  • Lataa
  • Github
  • Runbot
  • Käännökset
Palvelut
  • Odoo.sh hosting
  • Tuki
  • Versionkorotus
  • Räätälöidyt kehitykset
  • Koulutus
  • Löydä kirjanpitäjä
  • Löydä kumppani
  • Ryhdy kumppaniksi
Meistä
  • Yrityksemme
  • Tavaramerkki
  • Ota yhteyttä
  • Työpaikat
  • Tapahtumat
  • Podcast
  • Blogi
  • Asiakkaat
  • Oikeudellinen ilmoitus • Yksityisyys
  • Tietoturva
الْعَرَبيّة 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 on kokoelma avoimen lähdekoodin yrityssovelluksia, jotka kattavat kaikki yrityksesi tarpeet: asiakkuudenhallinta eli CRM, verkkokauppa, kirjanpito, varastointi, kassajärjestelmä, projektinhallinta, jne.

Odoon uniikki arvolupaus on olla samanaikaisesti erittäin helppokäyttöinen ja täysin integroitu.

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