Rohan Nayani(Open ERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-l10n-control-dev-split-fiscal-position-func-from-execute-func-ron
into lp:~openerp-dev/openobject-addons/trunk-l10n-control-dev.
Requested reviews:
Rucha (Open ERP) (rpa-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-l10n-control-dev-split-fiscal-position-func-from-execute-func-ron/+merge/71002
Hello,
* Create Function generate_fiscal_position() in
account.fiscal.position.template for generate Fiscal Position , Fiscal Position
Accounts and Fiscal Position Taxes from templates. This function splited from
execute method of wizard.multi.charts.accounts.
* Create Demo data for testing purpose.
Thanks
RON
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-l10n-control-dev-split-fiscal-position-func-from-execute-func-ron/+merge/71002
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-l10n-control-dev.
=== modified file 'account/account.py'
--- account/account.py 2011-08-09 10:06:26 +0000
+++ account/account.py 2011-08-10 08:48:38 +0000
@@ -2650,6 +2650,47 @@
'tax_ids': fields.one2many('account.fiscal.position.tax.template', 'position_id', 'Tax Mapping')
}
+ def generate_fiscal_position(self, cr, uid, chart_temp_id, taxes_ids, acc_template_ref, company_id, context=None):
+ """
+ This method generate Fiscal Position , Fiscal Position Accounts and Fiscal Position Taxes from templates.
+ @param cr: A database cursor.
+ @param uid: ID of the user currently logged in.
+ @param chart_temp_id: Chart Template Id.
+ @param taxes_ids: Taxes templates reference for generating account.fiscal.position.tax.
+ @param acc_template_ref: Account templates reference for generating account.fiscal.position.account.
+ @param company_id: company_id selected from wizard.multi.charts.accounts.
+ """
+
+ if context is None:
+ context = {}
+ obj_tax_fp = self.pool.get('account.fiscal.position.tax')
+ obj_ac_fp = self.pool.get('account.fiscal.position.account')
+ obj_fiscal_position = self.pool.get('account.fiscal.position')
+ fp_ids = self.search(cr, uid, [('chart_template_id', '=', chart_temp_id)])
+ if fp_ids:
+ for position in self.browse(cr, uid, fp_ids, context=context):
+ vals_fp = {
+ 'company_id': company_id,
+ 'name': position.name,
+ }
+ new_fp = obj_fiscal_position.create(cr, uid, vals_fp)
+
+ for tax in position.tax_ids:
+ vals_tax = {
+ 'tax_src_id': taxes_ids['tax_template_ref'][tax.tax_src_id.id],
+ 'tax_dest_id': tax.tax_dest_id and taxes_ids['tax_template_ref'][tax.tax_dest_id.id] or False,
+ '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 {}
+
account_fiscal_position_template()
class account_fiscal_position_tax_template(osv.osv):
@@ -2788,7 +2829,6 @@
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')
obj_data = self.pool.get('ir.model.data')
analytic_journal_obj = self.pool.get('account.analytic.journal')
obj_tax_code = self.pool.get('account.tax.code')
@@ -2798,6 +2838,7 @@
obj_acc_root = obj_multi.chart_template_id.account_root_id
tax_code_root_id = obj_multi.chart_template_id.tax_code_root_id.id
company_id = obj_multi.company_id.id
+ chart_temp_id = obj_multi.chart_template_id.id
#new code
acc_template_ref = {}
@@ -2824,7 +2865,7 @@
'installable': True,
'type': 'percent',
'sequence': 0,
- 'chart_template_id': obj_multi.chart_template_id.id or False,
+ 'chart_template_id': chart_temp_id or False,
}, context=context)
#create all the tax code
@@ -3092,35 +3133,9 @@
#create the property
property_obj.create(cr, uid, vals)
- fp_ids = obj_fiscal_position_template.search(cr, uid, [('chart_template_id', '=', obj_multi.chart_template_id.id)])
-
- if fp_ids:
- obj_tax_fp = self.pool.get('account.fiscal.position.tax')
- obj_ac_fp = self.pool.get('account.fiscal.position.account')
-
- for position in obj_fiscal_position_template.browse(cr, uid, fp_ids, context=context):
-
- vals_fp = {
- 'company_id': company_id,
- 'name': position.name,
- }
- new_fp = obj_fiscal_position.create(cr, uid, vals_fp)
-
- for tax in position.tax_ids:
- vals_tax = {
- 'tax_src_id': taxes_ids['tax_template_ref'][tax.tax_src_id.id],
- 'tax_dest_id': tax.tax_dest_id and taxes_ids['tax_template_ref'][tax.tax_dest_id.id] or False,
- '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)
+ #Generate Fiscal Position , Fiscal Position Accounts and Fiscal Position Taxes from templates
+ obj_fiscal_position_template.generate_fiscal_position(cr, uid, chart_temp_id, taxes_ids, acc_template_ref, company_id, context=context)
+
if obj_multi.sale_tax and taxes_ids['taxes_id']:
ir_values_obj.set(cr, uid, key='default', key2=False, name="taxes_id", company=obj_multi.company_id.id,
models =[('product.product',False)], value=[taxes_ids['taxes_id'][obj_multi.sale_tax.id]])
=== modified file 'l10n_multilang/l10n_multilang_test.xml'
--- l10n_multilang/l10n_multilang_test.xml 2011-07-28 11:41:14 +0000
+++ l10n_multilang/l10n_multilang_test.xml 2011-08-10 08:48:38 +0000
@@ -78,6 +78,21 @@
<field name="user_type" ref="account_type_view"/>
</record>
+ <record id="a7000" model="account.account.template">
+ <field name="name">Sales in India</field>
+ <field name="code">7000</field>
+ <field name="type">other</field>
+ <field name="user_type" ref="account_type_view"/>
+ <field ref="chart_a0" name="parent_id"/>
+ </record>
+ <record id="a7001" model="account.account.template">
+ <field name="name">Sales in the member countries of the C.E.E.</field>
+ <field name="code">7001</field>
+ <field name="type">other</field>
+ <field name="user_type" ref="account_type_view"/>
+ <field ref="chart_a0" name="parent_id"/>
+ </record>
+
<!-- Tax Code template for A-->
<record id="atax0" model="account.tax.code.template">
<field name="name">Tax Template Root A</field>
@@ -158,6 +173,15 @@
<field name="chart_template_id" ref="account_chart_template_a"/>
</record>
+ <record id="attn_VAT-OUT-00-EU-S" model="account.tax.template">
+ <field name="sequence">60</field>
+ <field name="description">VAT-OUT-00-EU-S</field>
+ <field name="name">Services EU</field>
+ <field name="amount">0</field>
+ <field name="type">percent</field>
+ <field name="chart_template_id" ref="account_chart_template_a"/>
+ </record>
+
<!-- Tax for template B-->
<record id="attn_VAT-OUT-4-S" model="account.tax.template">
<field name="sequence">12</field>
@@ -193,6 +217,18 @@
<field name="chart_template_id" ref="account_chart_template_b"/>
</record>
+ <record id="afpttn_intracom_7" model="account.fiscal.position.tax.template">
+ <field name="position_id" ref="afptn_intracom"/>
+ <field name="tax_src_id" ref="attn_VAT-OUT-21-S"/>
+ <field name="tax_dest_id" ref="attn_VAT-OUT-00-EU-S"/>
+ </record>
+
+ <record id="fiscal_position_account_template_3" model="account.fiscal.position.account.template">
+ <field name="position_id" ref="afptn_intracom" />
+ <field name="account_src_id" ref="a7000" />
+ <field name="account_dest_id" ref="a7001" />
+ </record>
+
</data>
</openerp>
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp