Skip to content

Commit

Permalink
[FIX] account - add a selection list on target_move in wizard for tax…
Browse files Browse the repository at this point in the history
  • Loading branch information
yvaucher authored and Stefan Rijnhart committed Jul 2, 2014
1 parent 207dcf8 commit 7eee34a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
21 changes: 15 additions & 6 deletions addons/account/report/account_tax_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,25 @@ def __init__(self, cr, uid, name, context=None):
'get_start_period': self.get_start_period,
'get_end_period': self.get_end_period,
'get_basedon': self._get_basedon,
'get_target_move': self._get_target_move,
})

def _get_basedon(self, form):
return form['form']['based_on']

def _get_lines(self, based_on, company_id=False, parent=False, level=0, context=None):
def _get_lines(self, based_on, target_move, 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:
res = self._add_codes(based_on, res, period_list, context=context)
res = self._add_codes(based_on, target_move, res, period_list, context=context)
else:
self.cr.execute ("select id from account_fiscalyear")
fy = self.cr.fetchall()
self.cr.execute ("select id from account_period where fiscalyear_id = %s",(fy[0][0],))
periods = self.cr.fetchall()
for p in periods:
period_list.append(p[0])
res = self._add_codes(based_on, res, period_list, context=context)
res = self._add_codes(based_on, target_move, res, period_list, context=context)

i = 0
top_result = []
Expand Down Expand Up @@ -171,18 +172,26 @@ def _get_codes(self, based_on, company_id, parent=False, level=0, period_list=No
res += self._get_codes(based_on, company_id, code.id, level+1, context=context)
return res

def _add_codes(self, based_on, account_list=None, period_list=None, context=None):
def _add_codes(self, based_on, target_move, account_list=None, period_list=None, context=None):
if account_list is None:
account_list = []
if period_list is None:
period_list = []
if context is None:
context = {}
res = []
obj_tc = self.pool.get('account.tax.code')
for account in account_list:
ids = obj_tc.search(self.cr, self.uid, [('id','=', account[1].id)], context=context)
sum_tax_add = 0
for period_ind in period_list:
for code in obj_tc.browse(self.cr, self.uid, ids, {'period_id':period_ind,'based_on': based_on}):
for period_id in period_list:
ctx = context.copy()
ctx.update(
period_id=period_id,
based_on=based_on,
state=target_move,
)
for code in obj_tc.browse(self.cr, self.uid, ids, context=ctx):
sum_tax_add = sum_tax_add + code.sum_period

code.sum_period = sum_tax_add
Expand Down
7 changes: 5 additions & 2 deletions addons/account/report/account_tax_report.rml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@
</tr>
</blockTable>
</td>
<td><para style="terp_default_Centre_8">[[ get_basedon(data) or '' ]]</para></td>
<td>
<para style="terp_default_Centre_8">[[ get_basedon(data) or '' ]]</para>
<para style="terp_default_Centre_8">[[ get_target_move(data) or '' ]]</para>
</td>
</tr>
</blockTable>
<para style="P2"><font color="white"> </font></para>
Expand All @@ -150,7 +153,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']['company_id']), 'o') ]]</font><font color="white">[[ (o['level']) ]]</font> <font>[[ (len(o['level'])&lt;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']['target_move'],data['form']['company_id']), 'o') ]]</font><font color="white">[[ (o['level']) ]]</font> <font>[[ (len(o['level'])&lt;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'])&lt;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']&lt;&gt;'view' and removeParentNode('font') ]][[ formatLang(o['debit']) ]]</font></para></td>
<td><para style="P6"><font>[[ len(o['level'])&lt;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']&lt;&gt;'view' and removeParentNode('font') ]][[ formatLang(o['credit'])]]</font></para></td>
<td><para style="P6"><font>[[ len(o['level'])&lt;5 and setTag('para','para',{'fontName':"Helvetica-Bold"}) or removeParentNode('font')]]</font><font>[[ o['type']=='view' and removeParentNode('font') ]][[ formatLang(o['tax_amount'], currency_obj=company.currency_id) ]]</font><font>[[ o['type']&lt;&gt;'view' and removeParentNode('font') ]][[ formatLang(o['tax_amount'], currency_obj=company.currency_id) ]]</font> </para></td>
Expand Down
1 change: 1 addition & 0 deletions addons/account/wizard/account_vat_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<field name="chart_tax_id" widget='selection'/>
<field name="fiscalyear_id"/>
<field name="display_detail"/>
<field name="target_move"/>
<!--- <field name="based_on"/>--> <!-- the option based_on 'payment' is probably not fully compliant with what the users understand with that term. So, currently, it's seems better to remove it from the view to avoid further problems -->
</group>

Expand Down

0 comments on commit 7eee34a

Please sign in to comment.