Generate Tax on Module Installation
In Accounting module,Taxation is most vital activity which affects the operations of an organization to great extent.In Odoo,when we install Chart Of Accounts(COA),it automatically configures default tax templates and taxes as per accounting package selected while installing COA.If we want to create any additional tax,we can create it manually from Accounting ‣ Configuration ‣ Taxes ‣ Taxes or we can load the required taxes by generating template during module installation itself.Today,we will be discussing the second option for Tax and Tax Template creation.
As per the requirement from one of our clients,we had to configure some taxes automatically upon module installation. We created a data.xml file in our custom module by placing the configurational parameters required for tax template creation.In Odoo,we need to generate Tax Template which upon successful creation executes the function _generate_tax(we need to provide the template as a parameter to this function.This function is located in account.py file at line no:2850 inside account module).
Below is the example for one of the tax which was configured by default on module installation.In this example we actually created a Tax Template and put the necessary parameters for Tax creation.The structure of data.xml file is as follow. In this example we have used python code for tax calculation.
<?xml version=”1.0″ encoding=”utf-8″?>
<record id=”output_sale_tax” model=”account.tax.template”>
<field name=”name”>Input Excise Duty @ 12.36% on MRP</field>
<field name=”python_compute”>result = product.mrp_price * 0.1236</field>
<field name=”python_compute_inv”>result = product.mrp_price * 0.1236</field>
<field name=”chart_template_id” ref=”l10n_in.indian_chart_template_standard”/>
Once our module is installed successfully,you will be able to find the required Tax at Accounting ‣ Configuration ‣ Taxes ‣ Taxes.