[ADD]: account: l10n fullness and inheritancy: Add new wizard to create Tax from tax template which template installable false

bzr revid: ron@tinyerp.com-20110804130954-bnu2pym8tuljwn3i
This commit is contained in:
ron@tinyerp.com 2011-08-04 18:39:54 +05:30
parent 86d02aaec4
commit 0bc21db7e5
4 changed files with 113 additions and 0 deletions

View File

@ -97,6 +97,7 @@ module named account_voucher.
'wizard/account_reconcile_view.xml',
'wizard/account_reconcile_partner_process_view.xml',
'wizard/account_automatic_reconcile_view.xml',
'wizard/account_tax_generate_view.xml',
'project/wizard/project_account_analytic_line_view.xml',
'account_end_fy.xml',
'account_invoice_view.xml',

View File

@ -65,6 +65,8 @@ import account_change_currency
import account_report_balance_sheet
import account_report_profit_loss
import account_tax_generate
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,73 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv, fields
class account_tax_generate(osv.osv_memory):
_name = 'account.tax.generate'
_description = 'Tax Generate'
def _get_templates(self, cr, uid, context=None):
return self.pool.get('account.tax.template').search(cr, uid, [('installable', '=', False)], context=context)
_columns = {
'template_ids': fields.many2many('account.tax.template', 'tax_template_rel', 'wizard_id', 'template_id', 'Taxes Template', domain = [('installable','=',False)]),
}
_defaults = {
'template_ids': _get_templates,
}
def tax_generate(self, cr, uid, ids, context=None):
for tax in self.browse(cr, uid, ids, context=context)[0].template_ids:
vals_tax = {
'name':tax.name,
'sequence': tax.sequence,
'amount':tax.amount,
'type':tax.type,
'applicable_type': tax.applicable_type,
'domain':tax.domain,
'parent_id': tax.parent_id and ((tax.parent_id.id in tax_template_ref) and tax_template_ref[tax.parent_id.id]) or False,
'child_depend': tax.child_depend,
'python_compute': tax.python_compute,
'python_compute_inv': tax.python_compute_inv,
'python_applicable': tax.python_applicable,
'base_code_id': tax.base_code_id and ((tax.base_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.base_code_id.id]) or False,
'tax_code_id': tax.tax_code_id and ((tax.tax_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.tax_code_id.id]) or False,
'base_sign': tax.base_sign,
'tax_sign': tax.tax_sign,
'ref_base_code_id': tax.ref_base_code_id and ((tax.ref_base_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.ref_base_code_id.id]) or False,
'ref_tax_code_id': tax.ref_tax_code_id and ((tax.ref_tax_code_id.id in tax_code_template_ref) and tax_code_template_ref[tax.ref_tax_code_id.id]) or False,
'ref_base_sign': tax.ref_base_sign,
'ref_tax_sign': tax.ref_tax_sign,
'include_base_amount': tax.include_base_amount,
'description':tax.description,
'company_id': self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id,
'type_tax_use': tax.type_tax_use,
'price_include': tax.price_include
}
new_tax = self.pool.get('account.tax').create(cr, uid, vals_tax)
self.pool.get('account.tax.template').write(cr, uid , [tax.id], {'installable': True})
return {}
account_tax_generate()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_tax_generate" model="ir.ui.view">
<field name="name">account.tax.generate.form</field>
<field name="model">account.tax.generate</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Tax Generate">
<separator string="Taxes Generate from Templates..." colspan="4"/>
<newline/>
<field name="template_ids" nolabel="1"/>
<separator colspan="4" />
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel" />
<button icon="gtk-execute" string="Generate Taxes"
name="tax_generate" type="object" />
</group>
</form>
</field>
</record>
<record id="action_account_tax_generate" model="ir.actions.act_window">
<field name="name">Generate Taxes</field>
<field name="res_model">account.tax.generate</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_tax_generate"/>
<field name="target">new</field>
</record>
<menuitem sequence="30" action="action_account_tax_generate" id="menu_generate_taxes" parent="next_id_27" />
</data>
</openerp>