Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Odoo Calculate tax via api (erppeek)

By
Jayanth
on 8/2/15, 12:59 AM 576 views

How do I trigger calculation of tax in odoo via ERPPEEK. I want to trigger the tax calculation without me calculating the tax. Is there some possibility from erppeek

I manually create the invoice header and line, I get all the product and tax details, and then I want the trigger.

My code is as below.



import erppeek

from datetime import datetime,date

api = erppeek.Client('http://127.0.0.1:8080','bitnami_openerp','**@gmail.com','******')

api.common.version()

#now create an invoice for the user

#Prepare data

#Get Currency

m_currency = api.model('res.currency')

r_currency = m_currency.read(['name=INR'],['id','name'])

#Get Company

m_company = api.model('res.company')

r_company = m_company.read(['name=Your Company'],['id','name'])

#Get Journal

m_journal = api.model('account.journal')

r_journal = m_journal.read(['name=Sales Journal'],['id','name'])

#Get Account

m_account = api.model('account.account')

r_account = m_account.read(['name=Sundry Debtors'],['id','name'])

#Get Partner

m_partner = api.model('res.partner')

r_partner = m_partner.read(['email=jayanth.bagare@gmail.com'],['id','name'])

#Get Account

m_account = api.model('account.account')

r_account = m_account.read(['id=190'],['id','name'])

#Get Product

m_product = api.model('product.product')

r_product = m_product.read(['id=2'],['id','lst_price','name'])

#Get Tax

m_tax = api.model('account.tax')

r_tax = m_tax.read(['id=49'],['id'])

#Consolidate Invoice Header

data = {"partner_id":r_partner[0]["id"],

"account_id":r_account[0]["id"],

"journal_id":r_journal[0]["id"],

"company_id":r_company[0]["id"],

"currency_id":r_currency[0]["id"],

"amount_untaxed":r_product[0]["lst_price"],

"reference_type":"none",

"amount_tax":"12.36",

"type":"out_invoice",

"date_invoice":date.today().strftime("%Y-%m-%d"),

"amount_total":r_product[0]["lst_price"] + 12.36

}

print data

#Create the invoice header

m_invoice = api.model('account.invoice')

invoice_id = m_invoice.create(data)

#Create Invoice Lines

#Consolidate Invoice Lines

product_id = r_product[0]["id"]

price_unit = r_product[0]["lst_price"]

quantity = "1"

ln_invoice_id = invoice_id.id

account_id = r_account[0]["id"]

print 'Tax is ',r_tax[0]["id"]

data_line = {"product_id":r_product[0]["id"],

"price_unit":r_product[0]["lst_price"],

"quantity":quantity,

"invoice_id":invoice_id.id,

"account_id":r_account[0]["id"],

"company_id":r_company[0]["id"],

"partner_id":r_partner[0]["id"],

"uos_id":1,

"name":r_product[0]["name"],

"invoice_line_tax_id":[(6,0,[r_tax[0]["id"]])]

}

m_invoice_line = api.model('account.invoice.line')

invoice_line_id = m_invoice_line.create(data_line)

print invoice_line_id.id

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/2/15, 12:59 AM
Seen: 576 times
Last updated: 8/2/15, 12:59 AM