Added Fiscal Position template utility,one example is ready for l10n_be
bzr revid: jvo@tinyerp.com-20090113144049-lrg166koof0v82b5
This commit is contained in:
parent
6d0ab1856a
commit
74299c212e
|
@ -1868,6 +1868,45 @@ class account_tax_template(osv.osv):
|
|||
|
||||
account_tax_template()
|
||||
|
||||
# Fiscal Position Templates
|
||||
|
||||
class account_fiscal_position_template(osv.osv):
|
||||
_name = 'account.fiscal.position.template'
|
||||
_description = 'Template for Fiscal Position'
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Fiscal Position Template', size=64, translate=True, required=True),
|
||||
'account_ids': fields.one2many('account.fiscal.position.account.template', 'position_id', 'Accounts Mapping'),
|
||||
'tax_ids': fields.one2many('account.fiscal.position.tax.template', 'position_id', 'Taxes Mapping')
|
||||
}
|
||||
|
||||
account_fiscal_position_template()
|
||||
|
||||
class account_fiscal_position_tax_template(osv.osv):
|
||||
_name = 'account.fiscal.position.tax.template'
|
||||
_description = 'Fiscal Position Template Taxes Mapping'
|
||||
_rec_name = 'position_id'
|
||||
|
||||
_columns = {
|
||||
'position_id': fields.many2one('account.fiscal.position.template', 'Fiscal Position', required=True, ondelete='cascade'),
|
||||
'tax_src_id': fields.many2one('account.tax.template', 'Tax Source', required=True),
|
||||
'tax_dest_id': fields.many2one('account.tax.template', 'Replacement Tax')
|
||||
}
|
||||
|
||||
account_fiscal_position_tax_template()
|
||||
|
||||
class account_fiscal_position_account_template(osv.osv):
|
||||
_name = 'account.fiscal.position.account.template'
|
||||
_description = 'Fiscal Position Template Accounts Mapping'
|
||||
_rec_name = 'position_id'
|
||||
_columns = {
|
||||
'position_id': fields.many2one('account.fiscal.position.template', 'Fiscal Position', required=True, ondelete='cascade'),
|
||||
'account_src_id': fields.many2one('account.account.template', 'Account Source', required=True),
|
||||
'account_dest_id': fields.many2one('account.account.template', 'Account Destination', required=True)
|
||||
}
|
||||
|
||||
account_fiscal_position_account_template()
|
||||
|
||||
# Multi charts of Accounts wizard
|
||||
|
||||
class wizard_multi_charts_accounts(osv.osv_memory):
|
||||
|
@ -1909,6 +1948,8 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
|||
obj_acc_tax = self.pool.get('account.tax')
|
||||
obj_journal = self.pool.get('account.journal')
|
||||
obj_acc_template = self.pool.get('account.account.template')
|
||||
obj_fiscal_position_template = self.pool.get('account.fiscal.position.template')
|
||||
obj_fiscal_position = self.pool.get('account.fiscal.position')
|
||||
|
||||
# Creating Account
|
||||
obj_acc_root = obj_multi.chart_template_id.account_root_id
|
||||
|
@ -2114,6 +2155,36 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
|||
#create the property
|
||||
property_obj.create(cr, uid, vals)
|
||||
|
||||
fp_ids = obj_fiscal_position_template.search(cr, uid,[])
|
||||
|
||||
if fp_ids:
|
||||
for position in obj_fiscal_position_template.browse(cr, uid, fp_ids):
|
||||
|
||||
vals_fp = {
|
||||
'company_id' : company_id,
|
||||
'name' : position.name,
|
||||
}
|
||||
new_fp = obj_fiscal_position.create(cr, uid, vals_fp)
|
||||
|
||||
obj_tax_fp = self.pool.get('account.fiscal.position.tax')
|
||||
obj_ac_fp = self.pool.get('account.fiscal.position.account')
|
||||
|
||||
for tax in position.tax_ids:
|
||||
vals_tax = {
|
||||
'tax_src_id' : tax_template_ref[tax.tax_src_id.id],
|
||||
'tax_dest_id' : tax_template_ref[tax.tax_dest_id.id],
|
||||
'position_id' : new_fp,
|
||||
}
|
||||
obj_tax_fp.create(cr, uid, vals_tax)
|
||||
|
||||
for acc in position.account_ids:
|
||||
vals_acc = {
|
||||
'account_src_id' : acc_template_ref[acc.account_src_id.id],
|
||||
'account_dest_id' : acc_template_ref[acc.account_dest_id.id],
|
||||
'position_id' : new_fp,
|
||||
}
|
||||
obj_ac_fp.create(cr, uid, vals_acc)
|
||||
|
||||
return {
|
||||
'view_type': 'form',
|
||||
"view_mode": 'form',
|
||||
|
|
|
@ -1682,7 +1682,63 @@
|
|||
<field name="balance" operator="+"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
</record>
|
||||
|
||||
<!-- Fiscal Position Templates -->
|
||||
|
||||
<record id="view_account_position_template_form" model="ir.ui.view">
|
||||
<field name="name">account.fiscal.position.template.form</field>
|
||||
<field name="model">account.fiscal.position.template</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Fiscal Position Template">
|
||||
<field name="name" select="1"/>
|
||||
<newline/>
|
||||
<field name="tax_ids" colspan="4">
|
||||
<tree string="Taxes Mapping" editable="bottom">
|
||||
<field name="tax_src_id" domain="[('parent_id','=',False)]"/>
|
||||
<field name="tax_dest_id" domain="[('parent_id','=',False)]"/>
|
||||
</tree>
|
||||
<form string="Taxes Mapping">
|
||||
<field name="tax_src_id" domain="[('parent_id','=',False)]"/>
|
||||
<field name="tax_dest_id" domain="[('parent_id','=',False)]"/>
|
||||
</form>
|
||||
</field>
|
||||
<field name="account_ids" colspan="4">
|
||||
<tree string="Accounts Mapping" editable="bottom">
|
||||
<field name="account_src_id"/>
|
||||
<field name="account_dest_id"/>
|
||||
</tree>
|
||||
<form string="Accounts Mapping">
|
||||
<field name="account_src_id"/>
|
||||
<field name="account_dest_id"/>
|
||||
</form>
|
||||
</field>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_account_position_template_tree" model="ir.ui.view">
|
||||
<field name="name">account.fiscal.position.template.tree</field>
|
||||
<field name="model">account.fiscal.position.template</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Fiscal Position">
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_fiscal_position_template_form" model="ir.actions.act_window">
|
||||
<field name="name">Fiscal Position Templates</field>
|
||||
<field name="res_model">account.fiscal.position.template</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
action="action_account_fiscal_position_template_form"
|
||||
id="menu_action_account_fiscal_position_form_template"
|
||||
parent="account_template_folder" sequence="20"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -42,7 +42,9 @@
|
|||
'author': 'Tiny',
|
||||
'depends': ['account', 'account_report', 'base_vat', 'base_iban', 'account_chart'],
|
||||
'init_xml': [],
|
||||
'update_xml': ['account_pcmn_belgium.xml', 'l10n_be_wizard.xml', 'l10n_be_sequence.xml'],
|
||||
'update_xml': ['account_pcmn_belgium.xml', 'l10n_be_wizard.xml',
|
||||
'l10n_be_sequence.xml', 'fiscal_templates.xml',
|
||||
],
|
||||
'demo_xml': [],
|
||||
'installable': True,
|
||||
'certificate': '31977724637',
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
|
||||
<!-- Fiscal Position Templates -->
|
||||
|
||||
<record id="fiscal_position_template_1" model="account.fiscal.position.template">
|
||||
<field name="name">Fiscal Position for Sale</field>
|
||||
</record>
|
||||
|
||||
<record id="fiscal_position_template_2" model="account.fiscal.position.template">
|
||||
<field name="name">Fiscal Position for Purchase</field>
|
||||
</record>
|
||||
|
||||
<!-- Fiscal Position Tax Templates -->
|
||||
|
||||
<record id="fiscal_position_tax_template_1" model="account.fiscal.position.tax.template">
|
||||
<field name="position_id" ref="fiscal_position_template_1" />
|
||||
<field name="tax_src_id" ref="l10n_be.vat_6" />
|
||||
<field name="tax_dest_id" ref="l10n_be.vat_12" />
|
||||
</record>
|
||||
|
||||
<record id="fiscal_position_tax_template_2" model="account.fiscal.position.tax.template">
|
||||
<field name="position_id" ref="fiscal_position_template_1" />
|
||||
<field name="tax_src_id" ref="l10n_be.vat_21" />
|
||||
<field name="tax_dest_id" ref="l10n_be.vat_21_buy" />
|
||||
</record>
|
||||
|
||||
<record id="fiscal_position_tax_template_3" model="account.fiscal.position.tax.template">
|
||||
<field name="position_id" ref="fiscal_position_template_2" />
|
||||
<field name="tax_src_id" ref="l10n_be.vat_XO_1" />
|
||||
<field name="tax_dest_id" ref="l10n_be.vat_XO_2" />
|
||||
</record>
|
||||
|
||||
<record id="fiscal_position_tax_template_4" model="account.fiscal.position.tax.template">
|
||||
<field name="position_id" ref="fiscal_position_template_2" />
|
||||
<field name="tax_src_id" ref="l10n_be.vat_I0_1" />
|
||||
<field name="tax_dest_id" ref="l10n_be.vat_I0_2" />
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Fiscal Position Account Templates -->
|
||||
|
||||
<record id="fiscal_position_account_template_1" model="account.fiscal.position.account.template">
|
||||
<field name="position_id" ref="fiscal_position_template_1" />
|
||||
<field name="account_src_id" ref="l10n_be.a408" />
|
||||
<field name="account_dest_id" ref="l10n_be.a480" />
|
||||
</record>
|
||||
|
||||
<record id="fiscal_position_account_template_2" model="account.fiscal.position.account.template">
|
||||
<field name="position_id" ref="fiscal_position_template_1" />
|
||||
<field name="account_src_id" ref="l10n_be.a419" />
|
||||
<field name="account_dest_id" ref="l10n_be.a4201" />
|
||||
</record>
|
||||
|
||||
<record id="fiscal_position_account_template_3" model="account.fiscal.position.account.template">
|
||||
<field name="position_id" ref="fiscal_position_template_2" />
|
||||
<field name="account_src_id" ref="l10n_be.a4200" />
|
||||
<field name="account_dest_id" ref="l10n_be.a4168" />
|
||||
</record>
|
||||
|
||||
<record id="fiscal_position_account_template_4" model="account.fiscal.position.account.template">
|
||||
<field name="position_id" ref="fiscal_position_template_2" />
|
||||
<field name="account_src_id" ref="l10n_be.a4210" />
|
||||
<field name="account_dest_id" ref="l10n_be.a4164" />
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue