[ADD] : Added Upstream Patch for Analytic.
This commit is contained in:
parent
cc9a88e2d2
commit
1e1d7f9f6d
@ -21,21 +21,24 @@ class AccountAnalyticAccount(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def _compute_debit_credit_balance(self):
|
def _compute_debit_credit_balance(self):
|
||||||
analytic_line_obj = self.env['account.analytic.line']
|
analytic_line_obj = self.env['account.analytic.line']
|
||||||
domain = [('account_id', 'in', self.mapped('id'))]
|
domain = [('account_id', 'in', self.ids)]
|
||||||
if self._context.get('from_date', False):
|
if self._context.get('from_date', False):
|
||||||
domain.append(('date', '>=', self._context['from_date']))
|
domain.append(('date', '>=', self._context['from_date']))
|
||||||
if self._context.get('to_date', False):
|
if self._context.get('to_date', False):
|
||||||
domain.append(('date', '<=', self._context['to_date']))
|
domain.append(('date', '<=', self._context['to_date']))
|
||||||
|
|
||||||
account_amounts = analytic_line_obj.search_read(domain, ['account_id', 'amount'])
|
credit_groups = analytic_line_obj.read_group(
|
||||||
account_ids = set([line['account_id'][0] for line in account_amounts])
|
domain=domain + [('amount', '>=', 0.0)],
|
||||||
data_debit = {account_id: 0.0 for account_id in account_ids}
|
fields=['account_id', 'amount'],
|
||||||
data_credit = {account_id: 0.0 for account_id in account_ids}
|
groupby=['account_id']
|
||||||
for account_amount in account_amounts:
|
)
|
||||||
if account_amount['amount'] < 0.0:
|
data_credit = {l['account_id'][0]: l['amount'] for l in credit_groups}
|
||||||
data_debit[account_amount['account_id'][0]] += account_amount['amount']
|
debit_groups = analytic_line_obj.read_group(
|
||||||
else:
|
domain=domain + [('amount', '<', 0.0)],
|
||||||
data_credit[account_amount['account_id'][0]] += account_amount['amount']
|
fields=['account_id', 'amount'],
|
||||||
|
groupby=['account_id']
|
||||||
|
)
|
||||||
|
data_debit = {l['account_id'][0]: l['amount'] for l in debit_groups}
|
||||||
|
|
||||||
for account in self:
|
for account in self:
|
||||||
account.debit = abs(data_debit.get(account.id, 0.0))
|
account.debit = abs(data_debit.get(account.id, 0.0))
|
||||||
|
Loading…
Reference in New Issue
Block a user