Correctly set the period of the moves.
This commit is contained in:
parent
2476c133a9
commit
2daadda1f0
15
account.py
15
account.py
|
@ -27,12 +27,14 @@ class ConsolidationWizard(Wizard):
|
||||||
Line = pool.get('account.move.line')
|
Line = pool.get('account.move.line')
|
||||||
Account = pool.get('account.account')
|
Account = pool.get('account.account')
|
||||||
AccountTemplate = pool.get('account.account.template')
|
AccountTemplate = pool.get('account.account.template')
|
||||||
|
Period = pool.get('account.period')
|
||||||
|
|
||||||
cursor = Transaction().cursor
|
cursor = Transaction().cursor
|
||||||
|
|
||||||
destination = Move.__table__()
|
destination = Move.__table__()
|
||||||
move = Move.__table__()
|
move = Move.__table__()
|
||||||
line = Line.__table__()
|
line = Line.__table__()
|
||||||
|
period = Period.__table__()
|
||||||
account = Account.__table__()
|
account = Account.__table__()
|
||||||
template = AccountTemplate.__table__()
|
template = AccountTemplate.__table__()
|
||||||
|
|
||||||
|
@ -48,10 +50,15 @@ class ConsolidationWizard(Wizard):
|
||||||
query = move.delete(where=move.company == company)
|
query = move.delete(where=move.company == company)
|
||||||
cursor.execute(*query)
|
cursor.execute(*query)
|
||||||
|
|
||||||
query = move.select(company, move.create_date, move.create_uid,
|
query = move.join(period,
|
||||||
|
condition=((move.date >= period.start_date)
|
||||||
|
& (move.date <= period.end_date)
|
||||||
|
& (period.type == 'standard')
|
||||||
|
))
|
||||||
|
query = query.select(company, move.create_date, move.create_uid,
|
||||||
move.write_date, move.write_uid, move.id, move.number, move.date,
|
move.write_date, move.write_uid, move.id, move.number, move.date,
|
||||||
move.post_number, move.post_date, move.state, move.journal,
|
move.post_number, move.post_date, move.state, move.journal,
|
||||||
move.description, move.period, where=(move.company != company))
|
move.description, period.id, where=(move.company != company))
|
||||||
destination = destination.insert([
|
destination = destination.insert([
|
||||||
destination.company, destination.create_date,
|
destination.company, destination.create_date,
|
||||||
destination.create_uid, destination.write_date,
|
destination.create_uid, destination.write_date,
|
||||||
|
@ -74,9 +81,9 @@ class ConsolidationWizard(Wizard):
|
||||||
condition=((account2.template == template.id)
|
condition=((account2.template == template.id)
|
||||||
& (account2.company == company)))
|
& (account2.company == company)))
|
||||||
query = query.join(line,
|
query = query.join(line,
|
||||||
condition=(account.id == line.account))
|
condition=(account.id == line.account))
|
||||||
query = query.join(move,
|
query = query.join(move,
|
||||||
condition=(Cast(line.move, Move.origin.sql_type().base) ==
|
condition=(Cast(line.move, Move.origin.sql_type().base) ==
|
||||||
move.origin))
|
move.origin))
|
||||||
query = query.select(move.id, line.debit, line.credit, line.party,
|
query = query.select(move.id, line.debit, line.credit, line.party,
|
||||||
line.description, line.maturity_date, account2.id, line.state,
|
line.description, line.maturity_date, account2.id, line.state,
|
||||||
|
|
Loading…
Reference in New Issue