Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

how to use requests.post?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
3943 Vistes
Avatar
Muhammad Yaseen

Hello guys:

I want to post data to FBR (Federal Board of Revenue). I am using requests.post method. But i am unable to post data. Please help.

This is my method:

@ api.multi 
def post_data_to_fbr ( self , orders):
fbr_url = "https://esp.fbr.gov.pk:8244/FBR/v1/api/Live/PostData"
#Content type must be included in the header
header = { "Content-Type" : "application / json" }
for order in orders:
    order =   self .browse (order) try : if order and order.session_id and
    
        





order.session_id.config_id and order.session_id.config_id.fbr_authorization:
header.update ({ 'Authorization' : order.session_id.config_id.fbr_authorization})

bill_amount = order.amount_total
TAX_AMOUNT = order.amount_tax
sale_amount = order.order amount_tax
inv_num = ''
if order.partner_id: invoice = self .env [ 'account.invoice' ] .search ([ '&' , ( 'partner_id' , '=' , order.partner_id.id) ,(
'state' , '=' , 'open' )] , limit = 1 )
print ( 'inv' , invoice)
if invoice:
inv_num = invoice.number
order_dic = {
"InvoiceNumber" : inv_num ,
"POSID" : order.session_id .config_id.pos_id , "USIN" : "USIN0" , # "DateTime": datetime.datetime.strptime (order.date_order, "% Y-% m-% d% H:% M:% S"). strftime ("% Y-% m-% d% H:% M:% S"), ""TotalBillAmount" : bill_amount ,
"TotalSaleValue" : sale_amount , "TotalTaxCharged" : tax_amount , "PaymentMode" : 1 , "InvoiceType" : 1 , } if order.partner_id: order_dic.update ({ "BuyerName" : order.partner_id.name , "BuyerPhoneNumber " : order.partner_id.mobile , }) pos_order_lines = self .env [ 'pos.order.line' ] .search ([( 'order_id' , '=' ,order.id)]) print




( 'line' , pos_order_lines)
if order.lines:
items_list = []
print ( 'item' , items_list)
total_qty = 0.0
for line in order.lines: total_qty + = line.qty line_dic = { "ItemCode" : line.product_id .default_code , "ItemName" : line.product_id.name , "Quantity" : line.qty , "PCTCode" : line.product_id.pct_code , "TaxRate" : 0.0 ,


"SaleValue" : line.price_unit ,
# "TotalAmount": line.price_subtotal, # "TaxCharged": line.price_subtotal_incl - line.price_subtotal, "InvoiceType" : 1 , "RefUSIN" : "" } items_list.append (line_dic) order_dic .update ({ "Items" : items_list , "TotalQuantity" : total_qty }) print ( 'num' , order_dic [ 'InvoiceNumber' ] , order_dic [ 'DateTime ' ])








order.write ({ 'post_data_fbr' : True, 'invoice_number' : order_dic [ 'InvoiceNumber' ]})
payment_response = requests.post (fbr_url , data = json.dumps (order_dic) , headers = header , verify = False, timeout = 20 )
# payment_response = requests.post (fbr_url, data = json.dumps (order_dic), headers = header)
print ( 'payment' , payment_response) print ( 'res' , payment_response.json ())

r_json = payment_response.json ()
print ( 'r_json' , r_json)
# invoice_number = r_json.get ( 'InvoiceNumber')
invoice_number = order_dic [ 'InvoiceNumber' ]
order.write ({ 'fbr_respone' : r_json , 'post_data_fbr' : True , 'invoice_number' : invoice_number})

except Exception as e:
values ​​= dict (
exception = e ,
traceback = traceback.format_exc () , ) order.write ({ 'fbr_respone'
: values})
0
Avatar
Descartar
Avais

did you find any solution ?

Enjoying the discussion? Don't just read, join in!

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

Registrar-se
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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