[IMP] Account: Tax report converted to common report and make some improvents (make same as other account repots)
bzr revid: mra@mra-laptop-20101020121719-e8z153wy65r2f8xg
This commit is contained in:
parent
aaa65b3136
commit
f33edb9fde
|
@ -26,7 +26,8 @@ from report import report_sxw
|
|||
|
||||
class tax_report(rml_parse.rml_parse):
|
||||
_name = 'report.account.vat.declaration'
|
||||
def __init__(self, cr, uid, name, context={}):
|
||||
|
||||
def __init__(self, cr, uid, name, context=None):
|
||||
super(tax_report, self).__init__(cr, uid, name, context=context)
|
||||
self.localcontext.update({
|
||||
'time': time,
|
||||
|
@ -39,24 +40,31 @@ class tax_report(rml_parse.rml_parse):
|
|||
'get_years': self.get_years,
|
||||
})
|
||||
|
||||
def get_years(self, form):
|
||||
res = {}
|
||||
self.period_ids = []
|
||||
period_obj = self.pool.get('account.period')
|
||||
fy_obj = self.pool.get('account.fiscalyear')
|
||||
res['periods'] = ''
|
||||
res['fname'] = ''
|
||||
|
||||
def get_years(self,form):
|
||||
res={}
|
||||
fiscal_year_name = self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'])
|
||||
|
||||
fiscal_year_name = fy_obj.name_get(self.cr, self.uid, form['fiscalyear_id'])
|
||||
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'])
|
||||
|
||||
if form['period_from'] and form['period_to']:
|
||||
self.period_ids = period_obj.build_ctx_periods(self.cr, self.uid, form['period_from'], form['period_to'])
|
||||
periods_l = period_obj.read(self.cr, self.uid, self.period_ids, ['name'])
|
||||
for period in periods_l:
|
||||
if res['periods']=='':
|
||||
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={}):
|
||||
def _get_lines(self, based_on, company_id=False, parent=False, level=0, context=None):
|
||||
period_list = self.period_ids
|
||||
res = self._get_codes(based_on, company_id, parent, level, period_list, context=context)
|
||||
|
||||
if period_list:
|
||||
|
@ -95,12 +103,11 @@ class tax_report(rml_parse.rml_parse):
|
|||
ind_general+=1
|
||||
i+=1
|
||||
return top_result
|
||||
#return array_result
|
||||
|
||||
def _get_period(self, period_id, context={}):
|
||||
return self.pool.get('account.period').browse(self.cr, self.uid, period_id, context=context).name
|
||||
|
||||
def _get_general(self, tax_code_id, period_list,company_id, based_on, context={}):
|
||||
def _get_general(self, tax_code_id, period_list, company_id, based_on, context={}):
|
||||
res=[]
|
||||
obj_account = self.pool.get('account.account')
|
||||
periods_ids = tuple(period_list)
|
||||
|
@ -232,4 +239,4 @@ class tax_report(rml_parse.rml_parse):
|
|||
report_sxw.report_sxw('report.account.vat.declaration', 'account.tax.code',
|
||||
'addons/account/report/account_tax_report.rml', parser=tax_report, header="internal")
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -108,13 +108,13 @@
|
|||
<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>
|
||||
<td><para style="P12">Fiscal Year : [[ get_years(data['form'])['fname'] ]]</para></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><para style="P12">Periods : [[ get_years(data['form'])['periods'] or removeParentNode('tr')]]</para></td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
<para style="P2"><font color="white"> </font></para>
|
||||
<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>
|
||||
|
@ -123,7 +123,7 @@
|
|||
<td><para style="P12a">Tax Amount</para></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><para style="P5"><font>[[ repeatIn(get_lines(data['form']['based_on'],data['form']['periods'],data['form']['company_id']), 'o') ]]</font><font color="white">[[ (o['level']) ]]</font> <font>[[ (len(o['level'])<5 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]]</font><font>[[ o['code'] ]] [[ o['name'] ]] </font></para></td>
|
||||
<td><para style="P5"><font>[[ repeatIn(get_lines(data['form']['based_on'], data['form']['company_id']), 'o') ]]</font><font color="white">[[ (o['level']) ]]</font> <font>[[ (len(o['level'])<5 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]]</font><font>[[ o['code'] ]] [[ o['name'] ]] </font></para></td>
|
||||
<td><para style="P6"><font>[[ len(o['level'])<5 and setTag('para','para',{'fontName':"Helvetica-Bold"}) or removeParentNode('font')]]</font><font>[[ o['type']=='view' and removeParentNode('font') ]][[ formatLang(o['debit']) ]]</font><font>[[ o['type']<>'view' and removeParentNode('font') ]][[ formatLang(o['debit']) ]]</font></para></td>
|
||||
<td><para style="P6"><font>[[ len(o['level'])<5 and setTag('para','para',{'fontName':"Helvetica-Bold"}) or removeParentNode('font')]]</font><font>[[ o['type']=='view' and removeParentNode('font') ]][[ formatLang(o['credit']) ]]</font><font>[[ o['type']<>'view' and removeParentNode('font') ]][[ formatLang(o['credit'])]]</font></para></td>
|
||||
<td><para style="P6"><font>[[ len(o['level'])<5 and setTag('para','para',{'fontName':"Helvetica-Bold"}) or removeParentNode('font')]]</font><font>[[ o['type']=='view' and removeParentNode('font') ]][[ formatLang(o['tax_amount']) ]] [[ company.currency_id.symbol ]]</font><font>[[ o['type']<>'view' and removeParentNode('font') ]][[ formatLang(o['tax_amount']) ]] [[ company.currency_id.symbol ]]</font> </para></td>
|
||||
|
|
|
@ -24,41 +24,48 @@ from osv import osv, fields
|
|||
class account_vat_declaration(osv.osv_memory):
|
||||
_name = 'account.vat.declaration'
|
||||
_description = 'Account Vat Declaration'
|
||||
_inherit = "account.common.account.report"
|
||||
_inherit = "account.common.report"
|
||||
_columns = {
|
||||
'based_on': fields.selection([('invoices','Invoices'),
|
||||
('payments','Payments'),],
|
||||
'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',required=True),
|
||||
}
|
||||
# 'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||
'chart_tax_id': fields.many2one('account.tax.code', 'Chart of Tax', help='Select Charts of Taxes', required=True, domain = [('parent_id','=',False)]),
|
||||
}
|
||||
|
||||
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]
|
||||
def _get_tax(self, cr, uid, context=None):
|
||||
taxes = self.pool.get('account.tax.code').search(cr, uid, [('parent_id','=',False)], limit=1)
|
||||
return taxes and taxes[0] or False
|
||||
|
||||
# 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:
|
||||
# company_id = user.company_id.id
|
||||
# else:
|
||||
# company_id = company_obj.search(cr, uid, [('parent_id', '=', False)])
|
||||
# company_id = company_id and company_id[0] or False
|
||||
# return company_id
|
||||
|
||||
_defaults = {
|
||||
'based_on': 'invoices',
|
||||
'company_id': _get_company
|
||||
}
|
||||
'chart_tax_id': _get_tax
|
||||
}
|
||||
|
||||
def create_vat(self, cr, uid, ids, context={}):
|
||||
def create_vat(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
datas = {'ids': context.get('active_ids', [])}
|
||||
datas['model'] = 'account.tax.code'
|
||||
datas['form'] = self.read(cr, uid, ids)[0]
|
||||
datas['form']['company_id'] = self.pool.get('account.tax.code').browse(cr, uid, [datas['form']['chart_tax_id']], context=context)[0].company_id.id
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.vat.declaration',
|
||||
'datas': datas,
|
||||
}
|
||||
|
||||
account_vat_declaration()
|
||||
|
||||
#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -7,15 +7,13 @@
|
|||
<field name="model">account.vat.declaration</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Select Period">
|
||||
<field name="company_id" groups="base.group_multi_company" widget='selection'/>
|
||||
<newline/>
|
||||
<form string="Taxes Report">
|
||||
<field name="chart_tax_id" widget='selection'/>
|
||||
<field name="fiscalyear_id"/>
|
||||
<field name="based_on"/>
|
||||
<newline/>
|
||||
<separator string="Select Period(s)" colspan="4"/>
|
||||
<field name="periods" nolabel="1" colspan="4"/>
|
||||
<separator string="Select FiscalYear(s)" colspan="4"/>
|
||||
<field name="fiscalyear" nolabel="1" colspan="4"/>
|
||||
<separator string="Periods" colspan="4"/>
|
||||
<field name="period_from" domain="[('fiscalyear_id', '=', fiscalyear_id)]" attrs="{'readonly':[('filter','!=','filter_period')], 'required':[('filter', '=', 'filter_period')]}" />
|
||||
<field name="period_to" domain="[('fiscalyear_id', '=', fiscalyear_id)]" attrs="{'readonly':[('filter','!=','filter_period')], 'required':[('filter', '=', 'filter_period')]}" />
|
||||
<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"/>
|
||||
|
@ -42,4 +40,4 @@
|
|||
icon="STOCK_PRINT"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</openerp>
|
Loading…
Reference in New Issue