如何通过ERPPEEK触发odoo中的税收计算。 我想在不计算税额的情况下触发税收计算。是否有可能来自erppeek
我手动创建发票标题和行,我获得所有产品和税务详细信息,然后我想要触发器。
我的代码如下。
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
答案 0 :(得分:3)
正如我可以看到您已经将Tax与发票行相关联,因此应该处理它但如果这不起作用,那么您可以触发模型account.invoice
的方法button_reset_taxes
将采取整个发票的税收计算。
可能的代码:
m_invoice = api.model('account.invoice')
m_invoice.button_reset_taxes(invoice_id)
或类似的东西我可能错误的erppeek语法。但最重要的是在创建发票和发票行结束时致电button_reset_taxes
贝斯茨
答案 1 :(得分:0)
[....]
invoice = api.model('account.invoice').create(data)
[....]
invoice_line = api.model('account.invoice.line').create(data_line)
invoice.button_reset_taxes()