minor fix post voucher in second_currency
This commit is contained in:
parent
750ee44372
commit
3f56ed7244
49
voucher.py
49
voucher.py
|
@ -1,6 +1,6 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from datetime import date, datetime, timedelta
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
from sql import Table
|
||||
|
||||
|
@ -457,7 +457,6 @@ class Voucher(Workflow, ModelSQL, ModelView):
|
|||
Move = pool.get('account.move')
|
||||
MoveLine = pool.get('account.move.line')
|
||||
Period = pool.get('account.period')
|
||||
Currency = pool.get('currency.currency')
|
||||
|
||||
period_id = Period.find(self.company.id, date=self.date)
|
||||
move, = Move.create([{
|
||||
|
@ -469,23 +468,9 @@ class Voucher(Workflow, ModelSQL, ModelView):
|
|||
'description': self.description,
|
||||
}])
|
||||
|
||||
with Transaction().set_context(date=self.date):
|
||||
amount = Currency.compute(self.currency,
|
||||
self.amount_to_pay, self.company.currency)
|
||||
|
||||
if self.voucher_type == 'receipt':
|
||||
debit = amount
|
||||
credit = Decimal('0.0')
|
||||
else:
|
||||
debit = Decimal('0.0')
|
||||
credit = amount
|
||||
|
||||
to_reconcile = {}
|
||||
move_lines = []
|
||||
if self.voucher_type in ['receipt', 'payment', 'multipayment']:
|
||||
to_line = self.get_move_line(move, debit, credit)
|
||||
move_lines.append(to_line)
|
||||
|
||||
|
||||
for line in self.lines:
|
||||
if not line.amount or line.amount == _ZERO:
|
||||
continue
|
||||
|
@ -494,6 +479,19 @@ class Voucher(Workflow, ModelSQL, ModelView):
|
|||
move_lines.append(move_line)
|
||||
if line.move_line and line.amount != _ZERO:
|
||||
to_reconcile[line] = [line.move_line]
|
||||
|
||||
amount = sum(ln['credit'] - ln['debit'] for ln in move_lines)
|
||||
|
||||
if self.voucher_type == 'receipt':
|
||||
debit = amount
|
||||
credit = Decimal('0.0')
|
||||
else:
|
||||
debit = Decimal('0.0')
|
||||
credit = amount
|
||||
if self.voucher_type in ['receipt', 'payment', 'multipayment']:
|
||||
to_line = self.get_move_line(move, debit, credit)
|
||||
move_lines.append(to_line)
|
||||
|
||||
lines = MoveLine.create(move_lines)
|
||||
for line in lines:
|
||||
if line.origin in to_reconcile:
|
||||
|
@ -589,6 +587,7 @@ class Voucher(Workflow, ModelSQL, ModelView):
|
|||
if to_reconcile_lines:
|
||||
lines_list.append(to_reconcile_lines)
|
||||
if lines_list:
|
||||
print(lines_list, 'lines final reconcile')
|
||||
MoveLine.reconcile(*lines_list, writeoff=writeoff)
|
||||
|
||||
@classmethod
|
||||
|
@ -865,7 +864,7 @@ class VoucherLine(ModelSQL, ModelView):
|
|||
party_id = self.voucher.party.id
|
||||
else:
|
||||
party_id = self.party.id if self.party else None
|
||||
if self.voucher.account.party_required == False:
|
||||
if not self.voucher.account.party_required:
|
||||
party_id = None
|
||||
res = {
|
||||
'description': self.voucher.description,
|
||||
|
@ -1310,13 +1309,13 @@ class Note(Workflow, ModelSQL, ModelView):
|
|||
|
||||
Move.post([move])
|
||||
|
||||
for l in move.lines:
|
||||
if l.origin and l.origin.move_line and l.origin.move_line.move.origin and\
|
||||
l.origin.move_line.move.origin.__name__ == 'account.invoice':
|
||||
invoice = l.origin.move_line.move.origin
|
||||
if invoice.account != l.account:
|
||||
for line in move.lines:
|
||||
if line.origin and line.origin.move_line and line.origin.move_line.move.origin and\
|
||||
line.origin.move_line.move.origin.__name__ == 'account.invoice':
|
||||
invoice = line.origin.move_line.move.origin
|
||||
if invoice.account != line.account:
|
||||
continue
|
||||
invoice.add_payment_lines({invoice: [l]})
|
||||
invoice.add_payment_lines({invoice: [line]})
|
||||
|
||||
def reconcile_lines(self):
|
||||
MoveLine = Pool().get('account.move.line')
|
||||
|
@ -1734,7 +1733,7 @@ class CreateVoucher(Wizard):
|
|||
('voucher.date', '>=', self.start.start_date),
|
||||
('voucher.date', '<=', self.start.end_date),
|
||||
])
|
||||
not_accounts_ids = [l.move_line.id for l in voucher_lines if l.move_line]
|
||||
not_accounts_ids = [ln.move_line.id for ln in voucher_lines if ln.move_line]
|
||||
for party in template.parties:
|
||||
to_create['party'] = party.id
|
||||
dom_ = [
|
||||
|
|
Loading…
Reference in New Issue