mirror of
https://github.com/bringout/odoomates.git
synced 2026-04-18 07:11:59 +02:00
Add 'Prethodno stanje' (previous balance) to partner ledger report
🤖 assisted by claude
This commit is contained in:
parent
5f0082b0ee
commit
6770322e53
5 changed files with 70 additions and 6 deletions
|
|
@ -540,7 +540,7 @@ msgstr ""
|
||||||
|
|
||||||
#. module: accounting_pdf_reports
|
#. module: accounting_pdf_reports
|
||||||
#. odoo-python
|
#. odoo-python
|
||||||
#: code:addons/accounting_pdf_reports/report/report_aged_partner.py
|
#: code:addons/accounting_pdf_reports/report/report_aged_partner.py:0
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Form content is missing, this report cannot be printed."
|
msgid "Form content is missing, this report cannot be printed."
|
||||||
msgstr "Nedostaju podaci sa forme, izvještaj se ne može ispisati."
|
msgstr "Nedostaju podaci sa forme, izvještaj se ne može ispisati."
|
||||||
|
|
@ -867,6 +867,16 @@ msgstr "Potraživanja i obaveze"
|
||||||
msgid "Reconciled Entries"
|
msgid "Reconciled Entries"
|
||||||
msgstr "Zatvorene stavke"
|
msgstr "Zatvorene stavke"
|
||||||
|
|
||||||
|
#. module: accounting_pdf_reports
|
||||||
|
#: model:ir.model.fields,field_description:accounting_pdf_reports.field_account_report_partner_ledger__previous_balance
|
||||||
|
msgid "Previous Balance"
|
||||||
|
msgstr "Prethodno stanje"
|
||||||
|
|
||||||
|
#. module: accounting_pdf_reports
|
||||||
|
#: model:ir.model.fields,help:accounting_pdf_reports.field_account_report_partner_ledger__previous_balance
|
||||||
|
msgid "Show previous balance before the start date."
|
||||||
|
msgstr "Prikaži prethodno stanje prije početnog datuma."
|
||||||
|
|
||||||
#. module: accounting_pdf_reports
|
#. module: accounting_pdf_reports
|
||||||
#: model_terms:ir.ui.view,arch_db:accounting_pdf_reports.report_general_ledger
|
#: model_terms:ir.ui.view,arch_db:accounting_pdf_reports.report_general_ledger
|
||||||
msgid "Ref"
|
msgid "Ref"
|
||||||
|
|
@ -1038,7 +1048,7 @@ msgstr "Tip"
|
||||||
|
|
||||||
#. module: accounting_pdf_reports
|
#. module: accounting_pdf_reports
|
||||||
#. odoo-python
|
#. odoo-python
|
||||||
#: code:addons/accounting_pdf_reports/report/report_aged_partner.py
|
#: code:addons/accounting_pdf_reports/report/report_aged_partner.py:0
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Unknown Partner"
|
msgid "Unknown Partner"
|
||||||
msgstr "Nepoznat partner"
|
msgstr "Nepoznat partner"
|
||||||
|
|
@ -1081,21 +1091,21 @@ msgstr ""
|
||||||
|
|
||||||
#. module: accounting_pdf_reports
|
#. module: accounting_pdf_reports
|
||||||
#. odoo-python
|
#. odoo-python
|
||||||
#: code:addons/accounting_pdf_reports/wizard/account_general_ledger.py
|
#: code:addons/accounting_pdf_reports/wizard/account_general_ledger.py:0
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "You must define a Start Date"
|
msgid "You must define a Start Date"
|
||||||
msgstr "You must define a Start Datum"
|
msgstr "You must define a Start Datum"
|
||||||
|
|
||||||
#. module: accounting_pdf_reports
|
#. module: accounting_pdf_reports
|
||||||
#. odoo-python
|
#. odoo-python
|
||||||
#: code:addons/accounting_pdf_reports/wizard/aged_partner.py
|
#: code:addons/accounting_pdf_reports/wizard/aged_partner.py:0
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "You must set a period length greater than 0."
|
msgid "You must set a period length greater than 0."
|
||||||
msgstr "Morate postaviti dužinu perioda veću od 0."
|
msgstr "Morate postaviti dužinu perioda veću od 0."
|
||||||
|
|
||||||
#. module: accounting_pdf_reports
|
#. module: accounting_pdf_reports
|
||||||
#. odoo-python
|
#. odoo-python
|
||||||
#: code:addons/accounting_pdf_reports/wizard/aged_partner.py
|
#: code:addons/accounting_pdf_reports/wizard/aged_partner.py:0
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "You must set a start date."
|
msgid "You must set a start date."
|
||||||
msgstr "Morate postaviti početni datum."
|
msgstr "Morate postaviti početni datum."
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,33 @@ class ReportPartnerLedger(models.AbstractModel):
|
||||||
full_account.append(r)
|
full_account.append(r)
|
||||||
return full_account
|
return full_account
|
||||||
|
|
||||||
|
def _previous_balance(self, data, partner):
|
||||||
|
"""Calculate the balance for a partner before the date_from."""
|
||||||
|
date_from = data['form'].get('date_from')
|
||||||
|
if not date_from:
|
||||||
|
return {'debit': 0.0, 'credit': 0.0, 'balance': 0.0}
|
||||||
|
|
||||||
|
reconcile_clause = "" if data['form']['reconciled'] else ' AND "account_move_line".full_reconcile_id IS NULL '
|
||||||
|
params = [
|
||||||
|
partner.id,
|
||||||
|
tuple(data['computed']['move_state']),
|
||||||
|
tuple(data['computed']['account_ids']),
|
||||||
|
date_from,
|
||||||
|
]
|
||||||
|
query = """
|
||||||
|
SELECT COALESCE(sum("account_move_line".debit), 0) as debit,
|
||||||
|
COALESCE(sum("account_move_line".credit), 0) as credit,
|
||||||
|
COALESCE(sum("account_move_line".debit - "account_move_line".credit), 0) as balance
|
||||||
|
FROM account_move_line
|
||||||
|
LEFT JOIN account_move m ON (m.id = "account_move_line".move_id)
|
||||||
|
WHERE "account_move_line".partner_id = %s
|
||||||
|
AND m.state IN %s
|
||||||
|
AND "account_move_line".account_id IN %s
|
||||||
|
AND "account_move_line".date < %s""" + reconcile_clause
|
||||||
|
self.env.cr.execute(query, tuple(params))
|
||||||
|
result = self.env.cr.dictfetchone()
|
||||||
|
return result or {'debit': 0.0, 'credit': 0.0, 'balance': 0.0}
|
||||||
|
|
||||||
def _sum_partner(self, data, partner, field):
|
def _sum_partner(self, data, partner, field):
|
||||||
if field not in ['debit', 'credit', 'debit - credit']:
|
if field not in ['debit', 'credit', 'debit - credit']:
|
||||||
return
|
return
|
||||||
|
|
@ -121,4 +148,5 @@ class ReportPartnerLedger(models.AbstractModel):
|
||||||
'time': time,
|
'time': time,
|
||||||
'lines': self._lines,
|
'lines': self._lines,
|
||||||
'sum_partner': self._sum_partner,
|
'sum_partner': self._sum_partner,
|
||||||
|
'previous_balance': self._previous_balance,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,27 @@
|
||||||
t-options="{'widget': 'float', 'precision': 2}"/>
|
t-options="{'widget': 'float', 'precision': 2}"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<t t-if="data['form'].get('previous_balance') and data['form'].get('date_from')">
|
||||||
|
<t t-set="prev_bal" t-value="previous_balance(data, o)"/>
|
||||||
|
<tr style="background-color: #f0f0f0; font-style: italic;">
|
||||||
|
<td colspan="4">
|
||||||
|
<strong>Prethodno stanje do <t t-esc="data['form']['date_from']" t-options="{'widget': 'date'}"/></strong>
|
||||||
|
</td>
|
||||||
|
<td class="col-amount">
|
||||||
|
<t t-esc="prev_bal['debit']"
|
||||||
|
t-options="{'widget': 'float', 'precision': 2}"/>
|
||||||
|
</td>
|
||||||
|
<td class="col-amount">
|
||||||
|
<t t-esc="prev_bal['credit']"
|
||||||
|
t-options="{'widget': 'float', 'precision': 2}"/>
|
||||||
|
</td>
|
||||||
|
<td class="col-amount">
|
||||||
|
<t t-esc="prev_bal['balance']"
|
||||||
|
t-options="{'widget': 'float', 'precision': 2}"/>
|
||||||
|
</td>
|
||||||
|
<td t-if="data['form']['amount_currency']"/>
|
||||||
|
</tr>
|
||||||
|
</t>
|
||||||
<tr t-foreach="lines(data, o)" t-as="line">
|
<tr t-foreach="lines(data, o)" t-as="line">
|
||||||
<td>
|
<td>
|
||||||
<span t-esc="line['date']"/>
|
<span t-esc="line['date']"/>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ class AccountPartnerLedger(models.TransientModel):
|
||||||
"report if the currency differs from "
|
"report if the currency differs from "
|
||||||
"the company currency.")
|
"the company currency.")
|
||||||
reconciled = fields.Boolean('Reconciled Entries')
|
reconciled = fields.Boolean('Reconciled Entries')
|
||||||
|
previous_balance = fields.Boolean('Previous Balance', default=True,
|
||||||
|
help="Show previous balance before the start date.")
|
||||||
|
|
||||||
def _get_report_base_filename(self):
|
def _get_report_base_filename(self):
|
||||||
if self.partner_ids:
|
if self.partner_ids:
|
||||||
|
|
@ -22,7 +24,8 @@ class AccountPartnerLedger(models.TransientModel):
|
||||||
def _get_report_data(self, data):
|
def _get_report_data(self, data):
|
||||||
data = self.pre_print_report(data)
|
data = self.pre_print_report(data)
|
||||||
data['form'].update({'reconciled': self.reconciled,
|
data['form'].update({'reconciled': self.reconciled,
|
||||||
'amount_currency': self.amount_currency})
|
'amount_currency': self.amount_currency,
|
||||||
|
'previous_balance': self.previous_balance})
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _print_report(self, data):
|
def _print_report(self, data):
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="reconciled"/>
|
<field name="reconciled"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
|
<field name="previous_balance"/>
|
||||||
|
<newline/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</data>
|
</data>
|
||||||
</field>
|
</field>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue