[IMP]:account:Improves the tax report and its wizard

bzr revid: azaz.201186@gmail.com-20101014073155-rotp4wrjegmonxn3
This commit is contained in:
saz-OpenERP 2010-10-14 13:01:55 +05:30
parent 65c67b59ed
commit 007623bba3
4 changed files with 66 additions and 34 deletions

View File

@ -37,9 +37,26 @@ class tax_report(rml_parse.rml_parse):
'get_company': self._get_company,
'get_currency': self._get_currency,
'get_lines': self._get_lines,
'get_years': self.get_years,
})
def get_years(self,form):
res={}
fiscal_year_name = self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'])
if fiscal_year_name:
res['fname'] = fiscal_year_name[0][1]
res['periods'] = ''
if form['periods']:
periods_l = self.pool.get('account.period').read(self.cr, self.uid, form['periods'], ['name'])
for period in periods_l:
if res['periods']=='':
res['periods'] = period['name']
else:
res['periods'] += ", "+ period['name']
return res
def _get_lines(self, based_on, period_list, company_id=False, parent=False, level=0, context={}):
res = self._get_codes(based_on, company_id, parent, level, period_list, context=context)

View File

@ -105,6 +105,16 @@
</stylesheet>
<story>
<para style="P2">Tax Statement</para>
<para style="P2"><font color="white"> </font></para>
<blockTable colWidths="538" style="Tableau1">
<tr>
<td><para style="P12">Year : [[ get_years(data['form'])['fname'] ]]</para></td>
</tr>
<tr>
<td><para style="P12">Periods : [[ get_years(data['form'])['periods'] ]]</para></td>
</tr>
</blockTable>
<para style="P2"><font color="white"> </font></para>
<blockTable colWidths="340.0,55.0,55.0,90.0" style="Table2" repeatRows="1">
<tr>
<td><para style="P12">Tax Name</para></td>

View File

@ -22,42 +22,45 @@
from osv import osv, fields
class account_vat_declaration(osv.osv_memory):
_name = 'account.vat.declaration'
_description = 'Account Vat Declaration'
_name = 'account.vat.declaration'
_description = 'Account Vat Declaration'
_inherit = "account.common.account.report"
_columns = {
'based_on': fields.selection([('invoices','Invoices'),
('payments','Payments'),],
'Based On', required=True),
'company_id': fields.many2one('res.company', 'Company', required=True),
'periods': fields.many2many('account.period', 'vat_period_rel', 'vat_id', 'period_id', 'Periods', help="All periods if empty"),
'fiscalyear': fields.many2many('account.fiscalyear','vat_fiscal_rel','fiscal_id','Fiscal Year'),
}
def _get_company(self, cr, uid, context={}):
user_obj = self.pool.get('res.users')
company_obj = self.pool.get('res.company')
user = user_obj.browse(cr, uid, uid, context=context)
if user.company_id:
return user.company_id.id
else:
return company_obj.search(cr, uid, [('parent_id', '=', False)])[0]
_columns = {
'based_on': fields.selection([('invoices','Invoices'),
('payments','Payments'),],
'Based On', required=True),
'company_id': fields.many2one('res.company', 'Company', required=True),
'periods': fields.many2many('account.period', 'vat_period_rel', 'vat_id', 'period_id', 'Periods', help="All periods if empty"),
}
def _get_company(self, cr, uid, context={}):
user_obj = self.pool.get('res.users')
company_obj = self.pool.get('res.company')
user = user_obj.browse(cr, uid, uid, context=context)
if user.company_id:
return user.company_id.id
else:
return company_obj.search(cr, uid, [('parent_id', '=', False)])[0]
_defaults = {
'based_on': 'invoices',
'company_id': _get_company
_defaults = {
'based_on': 'invoices',
'company_id': _get_company
}
}
def create_vat(self, cr, uid, ids, context={}):
if context is None:
context = {}
datas = {'ids': context.get('active_ids', [])}
datas['model'] = 'account.tax.code'
datas['form'] = self.read(cr, uid, ids)[0]
return {
'type': 'ir.actions.report.xml',
'report_name': 'account.vat.declaration',
'datas': datas,
}
def create_vat(self, cr, uid, ids, context={}):
if context is None:
context = {}
datas = {'ids': context.get('active_ids', [])}
datas['model'] = 'account.tax.code'
datas['form'] = self.read(cr, uid, ids)[0]
return {
'type': 'ir.actions.report.xml',
'report_name': 'account.vat.declaration',
'datas': datas,
}
account_vat_declaration()

View File

@ -10,10 +10,12 @@
<form string="Select Period">
<field name="company_id" groups="base.group_multi_company" widget='selection'/>
<newline/>
<field name="based_on" invisible="1"/>
<field name="based_on"/>
<newline/>
<separator string="Select Period(s)" colspan="4"/>
<field name="periods" nolabel="1" colspan="2"/>
<field name="periods" nolabel="1" colspan="4"/>
<separator string="Select FiscalYear(s)" colspan="4"/>
<field name="fiscalyear" nolabel="1" colspan="4"/>
<group col="2" colspan="4">
<button icon='gtk-cancel' special="cancel" string="Cancel" />
<button name="create_vat" string="Print Tax Statement" colspan="1" type="object" icon="gtk-ok"/>