minor fix
This commit is contained in:
parent
3ab07cdae5
commit
e1e6ceba3a
|
@ -366,21 +366,25 @@ class Liquidation(Workflow, ModelSQL, ModelView):
|
|||
amount.append(moveline.credit)
|
||||
|
||||
for adjust in line.adjustments:
|
||||
if adjust.account.id not in grouped.keys():
|
||||
grouped[adjust.account.id] = {
|
||||
key = adjust.account.id
|
||||
if key not in grouped.keys():
|
||||
grouped[key]={
|
||||
'amount': [],
|
||||
'description': adjust.description,
|
||||
'lines': [],
|
||||
}
|
||||
if hasattr(adjust, 'analytic_account') and adjust.analytic_account:
|
||||
grouped[key]['analytic']= adjust.analytic_account
|
||||
grouped[adjust.account.id]['amount'].append(adjust.amount)
|
||||
amount.append(adjust.amount)
|
||||
|
||||
for account_id, values in grouped.items():
|
||||
_amount = sum(values['amount'])
|
||||
debit = _amount
|
||||
credit = _ZERO
|
||||
|
||||
lines_moves.append(self._prepare_line(values['description'],
|
||||
account_id, debit=debit, credit=credit))
|
||||
account_id, debit=debit, credit=credit, analytic=values.get('analytic', None)))
|
||||
if lines_moves:
|
||||
lines_moves.append(self._prepare_line(
|
||||
self.description,
|
||||
|
@ -390,7 +394,7 @@ class Liquidation(Workflow, ModelSQL, ModelView):
|
|||
))
|
||||
return lines_moves, grouped
|
||||
|
||||
def _prepare_line(self, description, account_id, debit=_ZERO, credit=_ZERO, party_to_pay=None):
|
||||
def _prepare_line(self, description, account_id, debit=_ZERO, credit=_ZERO, party_to_pay=None, analytic=None):
|
||||
if debit < _ZERO:
|
||||
credit = debit
|
||||
debit = _ZERO
|
||||
|
@ -410,6 +414,14 @@ class Liquidation(Workflow, ModelSQL, ModelView):
|
|||
'account': account_id,
|
||||
'party': party_id,
|
||||
}
|
||||
if analytic:
|
||||
res['analytic_lines']= [
|
||||
('create', [{
|
||||
'debit': res['debit'],
|
||||
'credit': res['credit'],
|
||||
'account': analytic.id,
|
||||
'date': self.liquidation_date
|
||||
}])]
|
||||
return res
|
||||
|
||||
def _get_dates(self):
|
||||
|
@ -539,7 +551,7 @@ class Liquidation(Workflow, ModelSQL, ModelView):
|
|||
})
|
||||
wages[wage_type.id] = value
|
||||
|
||||
Liquidation.write([self], {'lines': [('create', wages.values())]})
|
||||
self.write([self], {'lines': [('create', wages.values())]})
|
||||
if self.kind == 'contract':
|
||||
self.process_loans_to_pay()
|
||||
|
||||
|
|
Loading…
Reference in New Issue