Skip to Content
Menu
This question has been flagged
4629 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

Avatar
Discard
Related Posts Replies Views Activity
0
Mar 24
252
3
Jan 24
465
0
Dec 23
305
0
Jul 23
648
1
Nov 22
1883