fix post move liquidation

This commit is contained in:
Wilson Gomez 2022-12-23 09:34:32 -05:00
parent c029e82dcd
commit f635cc5cf7

View file

@ -156,7 +156,6 @@ class Liquidation(Workflow, ModelSQL, ModelView):
def default_state(): def default_state():
return 'draft' return 'draft'
@staticmethod @staticmethod
def default_currency(): def default_currency():
Company = Pool().get('company.company') Company = Pool().get('company.company')
@ -357,7 +356,7 @@ class Liquidation(Workflow, ModelSQL, ModelView):
for moveline in line.move_lines: for moveline in line.move_lines:
to_reconcile.append(moveline) to_reconcile.append(moveline)
account_id = moveline.account.id account_id = moveline.account.id
amount_line = abs(moveline.debit - moveline.credit) amount_line = moveline.debit - moveline.credit * -1
if account_id not in grouped.keys(): if account_id not in grouped.keys():
grouped[account_id] = { grouped[account_id] = {
'amount': [], 'amount': [],
@ -428,7 +427,7 @@ class Liquidation(Workflow, ModelSQL, ModelView):
'party': party_id, 'party': party_id,
} }
if analytic: if analytic:
res['analytic_lines']= [ res['analytic_lines'] = [
('create', [{ ('create', [{
'debit': res['debit'], 'debit': res['debit'],
'credit': res['credit'], 'credit': res['credit'],
@ -598,7 +597,7 @@ class Liquidation(Workflow, ModelSQL, ModelView):
('origin', 'in', ['staff.loan.line,' + str(m)]), ('origin', 'in', ['staff.loan.line,' + str(m)]),
]) ])
party = m.loan.party_to_pay.id if m.loan.party_to_pay else None party = m.loan.party_to_pay.id if m.loan.party_to_pay else None
res = self.get_line_(m.loan.wage_type, m.amount, 1, m.loan.account_debit.id, party=party) res = self.get_line_(m.loan.wage_type, m.amount * -1, 1, m.loan.account_debit.id, party=party)
res['move_lines'] = [('add', move_lines)] res['move_lines'] = [('add', move_lines)]
res['liquidation'] = self.id res['liquidation'] = self.id
line_, = LiquidationLine.create([res]) line_, = LiquidationLine.create([res])