forked from OCA/account-financial-tools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaccount_tax_code.py
29 lines (24 loc) · 1.12 KB
/
account_tax_code.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# -*- encoding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################
from openerp import models, fields, api
class AccountTaxCode(models.Model):
_inherit = 'account.tax.code'
sum_period = fields.Float(compute="_sum_period")
@api.one
def _sum_period(self):
context = self.env.context
if context.get('period_ids'):
move_state = ('posted', )
if context.get('state', False) == 'all':
move_state = ('draft', 'posted', )
self.sum_period = self._sum(
'sum_period', [],
where=' AND line.period_id IN %s AND move.state IN %s',
where_params=(tuple(context['period_ids']),
move_state))[self.id]
else:
self.sum_period = super(AccountTaxCode,
self)._sum_period('sum_period',
[])[self.id]