Change common funcitons name:
read_account_vals --> read_account_vals get_account_values_by_party --> html get_account_values_by_party To ensure that the html reports use them and not the jasper reports ones, while the both modules are installed. Fix bug with general_ledger printed with parties.
This commit is contained in:
parent
68a49497cf
commit
fee1824623
13
common.py
13
common.py
|
@ -51,8 +51,8 @@ class Account(metaclass=PoolMeta):
|
|||
cls.general_ledger_balance.states['invisible'] = True
|
||||
|
||||
@classmethod
|
||||
def read_account_vals(cls, accounts, with_moves=False,
|
||||
exclude_party_moves=False):
|
||||
def html_read_account_vals(cls, accounts, with_moves=False,
|
||||
exclude_party_moves=False, final_accounts=False):
|
||||
pool = Pool()
|
||||
Account = pool.get('account.account')
|
||||
Move = pool.get('account.move')
|
||||
|
@ -68,9 +68,12 @@ class Account(metaclass=PoolMeta):
|
|||
cursor = transaction.connection.cursor()
|
||||
move_join = 'INNER' if with_moves else 'LEFT'
|
||||
if not accounts:
|
||||
accounts = Account.search([
|
||||
domain = [
|
||||
('company', '=', transaction.context.get('company')),
|
||||
])
|
||||
]
|
||||
if final_accounts:
|
||||
domain.append(('childs', '=', None))
|
||||
accounts = Account.search(domain)
|
||||
account_ids = [a.id for a in accounts]
|
||||
group_by = (table_a.id,)
|
||||
columns = (group_by + (Sum(Coalesce(line.debit, 0)).as_('debit'),
|
||||
|
@ -125,7 +128,7 @@ class Party(metaclass=PoolMeta):
|
|||
__name__ = 'party.party'
|
||||
|
||||
@classmethod
|
||||
def get_account_values_by_party(cls, parties, accounts, company):
|
||||
def html_get_account_values_by_party(cls, parties, accounts, company):
|
||||
'''
|
||||
Function to compute credit,debit and balance for party ids.
|
||||
'''
|
||||
|
|
|
@ -77,6 +77,8 @@ class PrintGeneralLedgerStart(ModelView):
|
|||
all_accounts = fields.Boolean('All accounts with and without balance',
|
||||
help='If unchecked only print accounts with previous balance different'
|
||||
' from 0 or with moves')
|
||||
final_accounts = fields.Boolean('Only final accounts',
|
||||
help='If unchecked print all tree accounts from 1 to all digits')
|
||||
parties = fields.Many2Many('party.party', None, None, 'Parties',
|
||||
context={
|
||||
'company': Eval('company'),
|
||||
|
@ -104,6 +106,10 @@ class PrintGeneralLedgerStart(ModelView):
|
|||
def default_all_accounts():
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def default_final_accounts():
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
return Transaction().context.get('company')
|
||||
|
@ -144,6 +150,7 @@ class PrintGeneralLedger(Wizard):
|
|||
'end_date': self.start.end_date,
|
||||
'accounts': [x.id for x in self.start.accounts],
|
||||
'all_accounts': self.start.all_accounts,
|
||||
'final_accounts': self.start.final_accounts,
|
||||
'parties': [x.id for x in self.start.parties],
|
||||
'output_format': self.start.output_format,
|
||||
}
|
||||
|
@ -326,9 +333,10 @@ class GeneralLedgerReport(HTMLReport):
|
|||
with Transaction().set_context(date=initial_balance_date):
|
||||
init_values = {}
|
||||
if not parties:
|
||||
init_values = Account.read_account_vals(accounts,
|
||||
with_moves=False, exclude_party_moves=True)
|
||||
init_party_values = Party.get_account_values_by_party(
|
||||
init_values = Account.html_read_account_vals(accounts,
|
||||
with_moves=False, exclude_party_moves=True,
|
||||
final_accounts=data.get('final_accounts', False))
|
||||
init_party_values = Party.html_get_account_values_by_party(
|
||||
parties, accounts, company)
|
||||
|
||||
records = {}
|
||||
|
@ -459,48 +467,41 @@ class GeneralLedgerReport(HTMLReport):
|
|||
'total_credit': credit,
|
||||
}
|
||||
|
||||
if parties or parties_general_ledger:
|
||||
if parties:
|
||||
account_ids = [k for k, _ in init_party_values.items()]
|
||||
accounts = dict((a.id, a) for a in Account.browse(account_ids))
|
||||
if parties:
|
||||
parties = dict((p.id, p) for p in parties)
|
||||
elif parties_general_ledger:
|
||||
parties = dict((p, Party(p))
|
||||
for a, av in init_party_values.items()
|
||||
for p, pv in av.items()
|
||||
if p and p not in parties_general_ledger)
|
||||
parties = dict((p.id, p) for p in parties)
|
||||
|
||||
if parties:
|
||||
for k, v in init_party_values.items():
|
||||
account = accounts[k]
|
||||
for p, z in v.items():
|
||||
# check if party is in current general ledger
|
||||
if p in parties_general_ledger:
|
||||
continue
|
||||
party = parties[p]
|
||||
if account.type.receivable or account.type.payable:
|
||||
currentKey = (account, party)
|
||||
else:
|
||||
currentKey = (account,)
|
||||
sequence += 1
|
||||
credit = z.get('credit', Decimal(0))
|
||||
debit = z.get('debit', Decimal(0))
|
||||
balance = z.get('balance', Decimal(0))
|
||||
for k, v in init_party_values.items():
|
||||
account = accounts[k]
|
||||
for p, z in v.items():
|
||||
# check if party is in current general ledger
|
||||
if p in parties_general_ledger:
|
||||
continue
|
||||
party = parties[p]
|
||||
if account.type.receivable or account.type.payable:
|
||||
currentKey = (account, party)
|
||||
else:
|
||||
currentKey = (account,)
|
||||
sequence += 1
|
||||
credit = z.get('credit', Decimal(0))
|
||||
debit = z.get('debit', Decimal(0))
|
||||
balance = z.get('balance', Decimal(0))
|
||||
|
||||
key = _get_key(currentKey)
|
||||
if records.get(key):
|
||||
records[key]['total_debit'] += debit
|
||||
records[key]['total_credit'] += credit
|
||||
else:
|
||||
records[key] = {
|
||||
'account': account.name,
|
||||
'code': account.code or str(account.id),
|
||||
'lines': [],
|
||||
'party_required': account.party_required,
|
||||
'previous_balance': (balance + credit - debit),
|
||||
'total_debit': debit,
|
||||
'total_credit': credit,
|
||||
}
|
||||
key = _get_key(currentKey)
|
||||
if records.get(key):
|
||||
records[key]['total_debit'] += debit
|
||||
records[key]['total_credit'] += credit
|
||||
else:
|
||||
records[key] = {
|
||||
'account': account.name,
|
||||
'code': account.code or str(account.id),
|
||||
'lines': [],
|
||||
'party_required': account.party_required,
|
||||
'previous_balance': (balance + credit - debit),
|
||||
'total_debit': debit,
|
||||
'total_credit': credit,
|
||||
}
|
||||
|
||||
accounts = {}
|
||||
for record in records.keys():
|
||||
|
|
10
locale/ca.po
10
locale/ca.po
|
@ -22,6 +22,10 @@ msgctxt "field:account_reports.print_general_ledger.start,end_period:"
|
|||
msgid "End Period"
|
||||
msgstr "Període final"
|
||||
|
||||
msgctxt "field:account_reports.print_general_ledger.start,final_accounts:"
|
||||
msgid "Only final accounts"
|
||||
msgstr "Només comptes finals"
|
||||
|
||||
msgctxt "field:account_reports.print_general_ledger.start,fiscalyear:"
|
||||
msgid "Fiscal Year"
|
||||
msgstr "Exercici fiscal"
|
||||
|
@ -98,6 +102,12 @@ msgstr ""
|
|||
"Si no està marcat, només imprimeix comptes amb saldo anterior diferent de 0 "
|
||||
"o amb moviments"
|
||||
|
||||
msgctxt "help:account_reports.print_general_ledger.start,final_accounts:"
|
||||
msgid "If unchecked print all tree accounts from 1 to all digits"
|
||||
msgstr ""
|
||||
"Si no està marcat, imprimeix todes les comptes de l'arbre de comptes des "
|
||||
"d'1 dígit a tots"
|
||||
|
||||
msgctxt "model:account_reports.print_general_ledger.start,name:"
|
||||
msgid "Print General Ledger"
|
||||
msgstr "Imprimeix llibre major"
|
||||
|
|
10
locale/es.po
10
locale/es.po
|
@ -22,6 +22,10 @@ msgctxt "field:account_reports.print_general_ledger.start,end_period:"
|
|||
msgid "End Period"
|
||||
msgstr "Período final"
|
||||
|
||||
msgctxt "field:account_reports.print_general_ledger.start,final_accounts:"
|
||||
msgid "Only final accounts"
|
||||
msgstr "Solo cuentas finales"
|
||||
|
||||
msgctxt "field:account_reports.print_general_ledger.start,fiscalyear:"
|
||||
msgid "Fiscal Year"
|
||||
msgstr "Ejercicio fiscal"
|
||||
|
@ -98,6 +102,12 @@ msgstr ""
|
|||
"Si no está marcado, solo imprime cuentas con saldo anterior diferente de 0 o"
|
||||
" con movimientos"
|
||||
|
||||
msgctxt "help:account_reports.print_general_ledger.start,final_accounts:"
|
||||
msgid "If unchecked print all tree accounts from 1 to all digits"
|
||||
msgstr ""
|
||||
"Si no está marcado, imprime todas las cuentas del árbol de cuentas desde 1 "
|
||||
"dígito a todos"
|
||||
|
||||
msgctxt "model:account_reports.print_general_ledger.start,name:"
|
||||
msgid "Print General Ledger"
|
||||
msgstr "Imprimir libro mayor"
|
||||
|
|
|
@ -20,6 +20,8 @@ copyright notices and license terms. -->
|
|||
<field name="accounts" colspan="4"/>
|
||||
<label name="all_accounts"/>
|
||||
<field name="all_accounts"/>
|
||||
<label name="final_accounts"/>
|
||||
<field name="final_accounts"/>
|
||||
<label name="output_format"/>
|
||||
<field name="output_format"/>
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue