Automatic Update form OCA2FC Migrator

This commit is contained in:
Flectra Community Bot 2021-05-26 13:28:35 +02:00 committed by Renzo Meister
parent 14b9141d44
commit 8cc5c5acf2
11 changed files with 146 additions and 105 deletions

View File

@ -9,7 +9,7 @@ Available addons
addon | version | summary addon | version | summary
--- | --- | --- --- | --- | ---
[account_financial_report](account_financial_report/) | 2.0.1.2.0| OCA Financial Reports [account_financial_report](account_financial_report/) | 2.0.1.2.3| OCA Financial Reports
[account_tax_balance](account_tax_balance/) | 2.0.1.0.1| Compute tax balances based on date range [account_tax_balance](account_tax_balance/) | 2.0.1.1.0| Compute tax balances based on date range

View File

@ -6,7 +6,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{ {
"name": "Account Financial Reports", "name": "Account Financial Reports",
"version": "2.0.1.2.0", "version": "2.0.1.2.3",
"category": "Reporting", "category": "Reporting",
"summary": "OCA Financial Reports", "summary": "OCA Financial Reports",
"author": "Camptocamp SA," "author": "Camptocamp SA,"

View File

@ -184,6 +184,10 @@ class GeneralLedgerReport(models.AbstractModel):
cost_center_ids, cost_center_ids,
extra_domain, extra_domain,
): ):
# If explicit list of accounts is provided,
# don't include unaffected earnings account
if account_ids:
unaffected_earnings_account = False
base_domain = [] base_domain = []
if company_id: if company_id:
base_domain += [("company_id", "=", company_id)] base_domain += [("company_id", "=", company_id)]
@ -272,29 +276,38 @@ class GeneralLedgerReport(models.AbstractModel):
] ]
accounts_ids = list(gen_ld_data.keys()) accounts_ids = list(gen_ld_data.keys())
unaffected_id = unaffected_earnings_account unaffected_id = unaffected_earnings_account
if unaffected_id not in accounts_ids: if unaffected_id:
accounts_ids.append(unaffected_id) if unaffected_id not in accounts_ids:
self._initialize_account(gen_ld_data, unaffected_id, foreign_currency) accounts_ids.append(unaffected_id)
pl_initial_balance = self._get_pl_initial_balance( self._initialize_account(gen_ld_data, unaffected_id, foreign_currency)
account_ids, company_id, fy_start_date, foreign_currency, base_domain pl_initial_balance = self._get_pl_initial_balance(
) account_ids, company_id, fy_start_date, foreign_currency, base_domain
gen_ld_data[unaffected_id]["init_bal"]["debit"] += pl_initial_balance["debit"] )
gen_ld_data[unaffected_id]["init_bal"]["credit"] += pl_initial_balance["credit"] gen_ld_data[unaffected_id]["init_bal"]["debit"] += pl_initial_balance[
gen_ld_data[unaffected_id]["init_bal"]["balance"] += pl_initial_balance[ "debit"
"balance"
]
gen_ld_data[unaffected_id]["fin_bal"]["debit"] += pl_initial_balance["debit"]
gen_ld_data[unaffected_id]["fin_bal"]["credit"] += pl_initial_balance["credit"]
gen_ld_data[unaffected_id]["fin_bal"]["balance"] += pl_initial_balance[
"balance"
]
if foreign_currency:
gen_ld_data[unaffected_id]["init_bal"]["bal_curr"] += pl_initial_balance[
"bal_curr"
] ]
gen_ld_data[unaffected_id]["fin_bal"]["bal_curr"] += pl_initial_balance[ gen_ld_data[unaffected_id]["init_bal"]["credit"] += pl_initial_balance[
"bal_curr" "credit"
] ]
gen_ld_data[unaffected_id]["init_bal"]["balance"] += pl_initial_balance[
"balance"
]
gen_ld_data[unaffected_id]["fin_bal"]["debit"] += pl_initial_balance[
"debit"
]
gen_ld_data[unaffected_id]["fin_bal"]["credit"] += pl_initial_balance[
"credit"
]
gen_ld_data[unaffected_id]["fin_bal"]["balance"] += pl_initial_balance[
"balance"
]
if foreign_currency:
gen_ld_data[unaffected_id]["init_bal"][
"bal_curr"
] += pl_initial_balance["bal_curr"]
gen_ld_data[unaffected_id]["fin_bal"]["bal_curr"] += pl_initial_balance[
"bal_curr"
]
return gen_ld_data, partners_data, partner_ids return gen_ld_data, partners_data, partner_ids
@api.model @api.model

View File

@ -313,8 +313,8 @@
<t t-if="balance['type'] == 'group_type'"> <t t-if="balance['type'] == 'group_type'">
<t <t
t-set="domain" t-set="domain"
t-value="[('account_id', 'in', line.compute_account_ids.ids), t-value="[('account_id', 'in', balance['account_ids']),
('date', '&lt;', date_from.strftime('%Y-%m-%d'))]" ('date', '&lt;', date_from)]"
/> />
<span t-att-domain="domain" res-model="account.move.line"> <span t-att-domain="domain" res-model="account.move.line">
<t <t
@ -363,9 +363,9 @@
<t t-if="balance['type'] == 'group_type'"> <t t-if="balance['type'] == 'group_type'">
<t <t
t-set="domain" t-set="domain"
t-value="[('account_id', 'in', line.compute_account_ids.ids), t-value="[('account_id', 'in', balance['account_ids']),
('date', '&gt;=', line.report_id.date_from.strftime('%Y-%m-%d')), ('date', '&gt;=', date_from),
('date', '&lt;=', line.report_id.date_to.strftime('%Y-%m-%d')), ('date', '&lt;=', date_to),
('debit', '&lt;&gt;', 0)]" ('debit', '&lt;&gt;', 0)]"
/> />
<span t-att-domain="domain" res-model="account.move.line"> <span t-att-domain="domain" res-model="account.move.line">
@ -417,9 +417,9 @@
<t t-if="balance['type'] == 'group_type'"> <t t-if="balance['type'] == 'group_type'">
<t <t
t-set="domain" t-set="domain"
t-value="[('account_id', 'in', line.compute_account_ids.ids), t-value="[('account_id', 'in', balance['account_ids']),
('date', '&gt;=', line.report_id.date_from.strftime('%Y-%m-%d')), ('date', '&gt;=', date_from),
('date', '&lt;=', line.report_id.date_to.strftime('%Y-%m-%d')), ('date', '&lt;=', date_to),
('credit', '&lt;&gt;', 0)]" ('credit', '&lt;&gt;', 0)]"
/> />
<span t-att-domain="domain" res-model="account.move.line"> <span t-att-domain="domain" res-model="account.move.line">
@ -471,9 +471,9 @@
<t t-if="balance['type'] == 'group_type'"> <t t-if="balance['type'] == 'group_type'">
<t <t
t-set="domain" t-set="domain"
t-value="[('account_id', 'in', line.compute_account_ids.ids), t-value="[('account_id', 'in', balance['account_ids']),
('date', '&gt;=', line.report_id.date_from.strftime('%Y-%m-%d')), ('date', '&gt;=', date_from),
('date', '&lt;=', line.report_id.date_to.strftime('%Y-%m-%d'))]" ('date', '&lt;=', date_to)]"
/> />
<span t-att-domain="domain" res-model="account.move.line"> <span t-att-domain="domain" res-model="account.move.line">
<t <t
@ -561,7 +561,7 @@
<div class="act_as_cell amount"> <div class="act_as_cell amount">
<t <t
t-set="domain" t-set="domain"
t-value="[('account_id', '=', line.account_id.id)]" t-value="[('account_id', '=', balance['id'])]"
/> />
<span <span
t-att-domain="domain" t-att-domain="domain"
@ -599,8 +599,8 @@
<div class="act_as_cell amount"> <div class="act_as_cell amount">
<t <t
t-set="domain" t-set="domain"
t-value="[('account_id', '=', line.report_account_id.account_id.id), t-value="[('account_id', '=', account_id),
('partner_id', '=', line.partner_id.id)]" ('partner_id', '=', partner_id)]"
/> />
<span <span
t-att-domain="domain" t-att-domain="domain"
@ -622,7 +622,7 @@
<div class="act_as_cell amount"> <div class="act_as_cell amount">
<t <t
t-set="domain" t-set="domain"
t-value="[('account_id', '=', line.account_id.id)]" t-value="[('account_id', '=', balance['id'])]"
/> />
<span <span
t-att-domain="domain" t-att-domain="domain"
@ -654,8 +654,8 @@
<t t-if="type == 'partner_type'"> <t t-if="type == 'partner_type'">
<t <t
t-set="domain" t-set="domain"
t-value="[('account_id', '=', line.report_account_id.account_id.id), t-value="[('account_id', '=', account_id),
('partner_id', '=', line.partner_id.id)]" ('partner_id', '=', partner_id)]"
/> />
<span <span
t-att-domain="domain" t-att-domain="domain"

View File

@ -72,34 +72,17 @@
</div> </div>
<div class="act_as_cell amount" style="width: 15%;"> <div class="act_as_cell amount" style="width: 15%;">
<t <t
t-set="domain" t-att-style="style"
t-value="[('tax_ids', 'in', [tax.tax_id.id for tax in tag.tax_ids]), t-raw="tag_or_group['net']"
('date', '&gt;=', o.date_from), t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
('date', '&lt;=', o.date_to)]"
/> />
<span t-att-domain="domain" res-model="account.move.line">
<t
t-att-style="style"
t-raw="tag_or_group['net']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
</div> </div>
<div class="act_as_cell amount" style="width: 15%;"> <div class="act_as_cell amount" style="width: 15%;">
<t <t
t-set="domain" t-att-style="style"
t-value="[('tax_line_id', 'in', [tax.tax_id.id for tax in tag.tax_ids]), t-raw="tag_or_group['tax']"
('date', '&gt;=', o.date_from), t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
('date', '&lt;=', o.date_to),
('tax_exigible', '=', True)]"
/> />
<span t-att-domain="domain" res-model="account.move.line">
<t
t-att-style="style"
t-raw="tag_or_group['tax']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</span>
</div> </div>
</div> </div>
<t t-if="tax_detail"> <t t-if="tax_detail">
@ -111,7 +94,7 @@
style="padding-left: 20px; width: 65%;" style="padding-left: 20px; width: 65%;"
> >
<span <span
t-att-res-id="tax.tax_id.id" t-att-res-id="tax['id']"
t-att-res-model="res_model" t-att-res-model="res_model"
view-type="form" view-type="form"
> >
@ -121,9 +104,9 @@
<div class="act_as_cell amount" style="width: 15%;"> <div class="act_as_cell amount" style="width: 15%;">
<t <t
t-set="domain" t-set="domain"
t-value="[('tax_ids', 'in', tax.tax_id.ids), t-value="[('tax_ids', 'in', tax['id']),
('date', '&gt;=', o.date_from), ('date', '&gt;=', date_from),
('date', '&lt;=', o.date_to), ('date', '&lt;=', date_to),
('tax_exigible', '=', True)]" ('tax_exigible', '=', True)]"
/> />
<span <span
@ -140,9 +123,9 @@
<div class="act_as_cell amount" style="width: 15%;"> <div class="act_as_cell amount" style="width: 15%;">
<t <t
t-set="domain" t-set="domain"
t-value="[('tax_line_id', '=', tax.tax_id.id), t-value="[('tax_line_id', '=', tax['id']),
('date', '&gt;=', o.date_from), ('date', '&gt;=', date_from),
('date', '&lt;=', o.date_to), ('date', '&lt;=', date_to),
('tax_exigible', '=', True)]" ('tax_exigible', '=', True)]"
/> />
<span <span

View File

@ -347,6 +347,9 @@ class TrialBalanceReport(models.AbstractModel):
accounts_domain = [("company_id", "=", company_id)] accounts_domain = [("company_id", "=", company_id)]
if account_ids: if account_ids:
accounts_domain += [("id", "in", account_ids)] accounts_domain += [("id", "in", account_ids)]
# If explicit list of accounts is provided,
# don't include unaffected earnings account
unaffected_earnings_account = False
accounts = self.env["account.account"].search(accounts_domain) accounts = self.env["account.account"].search(accounts_domain)
tb_initial_acc = [] tb_initial_acc = []
for account in accounts: for account in accounts:
@ -452,19 +455,23 @@ class TrialBalanceReport(models.AbstractModel):
) )
accounts_ids = list(total_amount.keys()) accounts_ids = list(total_amount.keys())
unaffected_id = unaffected_earnings_account unaffected_id = unaffected_earnings_account
if unaffected_id not in accounts_ids: if unaffected_id:
accounts_ids.append(unaffected_id) if unaffected_id not in accounts_ids:
total_amount[unaffected_id] = {} accounts_ids.append(unaffected_id)
total_amount[unaffected_id]["initial_balance"] = 0.0 total_amount[unaffected_id] = {}
total_amount[unaffected_id]["balance"] = 0.0 total_amount[unaffected_id]["initial_balance"] = 0.0
total_amount[unaffected_id]["credit"] = 0.0 total_amount[unaffected_id]["balance"] = 0.0
total_amount[unaffected_id]["debit"] = 0.0 total_amount[unaffected_id]["credit"] = 0.0
total_amount[unaffected_id]["ending_balance"] = 0.0 total_amount[unaffected_id]["debit"] = 0.0
if foreign_currency: total_amount[unaffected_id]["ending_balance"] = 0.0
total_amount[unaffected_id]["initial_currency_balance"] = 0.0 if foreign_currency:
total_amount[unaffected_id]["ending_currency_balance"] = 0.0 total_amount[unaffected_id]["initial_currency_balance"] = 0.0
total_amount[unaffected_id]["ending_currency_balance"] = 0.0
accounts_data = self._get_accounts_data(accounts_ids) accounts_data = self._get_accounts_data(accounts_ids)
pl_initial_balance, pl_initial_currency_balance = self._get_pl_initial_balance( (
pl_initial_balance,
pl_initial_currency_balance,
) = self._get_pl_initial_balance(
account_ids, account_ids,
journal_ids, journal_ids,
partner_ids, partner_ids,
@ -474,15 +481,16 @@ class TrialBalanceReport(models.AbstractModel):
show_partner_details, show_partner_details,
foreign_currency, foreign_currency,
) )
total_amount[unaffected_id]["ending_balance"] += pl_initial_balance if unaffected_id:
total_amount[unaffected_id]["initial_balance"] += pl_initial_balance total_amount[unaffected_id]["ending_balance"] += pl_initial_balance
if foreign_currency: total_amount[unaffected_id]["initial_balance"] += pl_initial_balance
total_amount[unaffected_id][ if foreign_currency:
"ending_currency_balance" total_amount[unaffected_id][
] += pl_initial_currency_balance "ending_currency_balance"
total_amount[unaffected_id][ ] += pl_initial_currency_balance
"initial_currency_balance" total_amount[unaffected_id][
] += pl_initial_currency_balance "initial_currency_balance"
] += pl_initial_currency_balance
return total_amount, accounts_data, partners_data return total_amount, accounts_data, partners_data
def _get_hierarchy_groups( def _get_hierarchy_groups(

View File

@ -89,7 +89,7 @@ class TestGeneralLedgerReport(AccountTestInvoicingCommon):
move = self.env["account.move"].create(move_vals) move = self.env["account.move"].create(move_vals)
move.action_post() move.action_post()
def _get_report_lines(self, with_partners=False): def _get_report_lines(self, with_partners=False, account_ids=False):
centralize = True centralize = True
if with_partners: if with_partners:
centralize = False centralize = False
@ -101,6 +101,7 @@ class TestGeneralLedgerReport(AccountTestInvoicingCommon):
"target_move": "posted", "target_move": "posted",
"hide_account_at_0": False, "hide_account_at_0": False,
"company_id": company.id, "company_id": company.id,
"account_ids": account_ids,
"fy_start_date": self.fy_date_start, "fy_start_date": self.fy_date_start,
"centralize": centralize, "centralize": centralize,
} }
@ -178,6 +179,9 @@ class TestGeneralLedgerReport(AccountTestInvoicingCommon):
self.income_account.id, general_ledger self.income_account.id, general_ledger
) )
self.assertFalse(check_income_account) self.assertFalse(check_income_account)
self.assertTrue(
self.check_account_in_report(self.unaffected_account.id, general_ledger)
)
# Add a move at the previous day of the first day of fiscal year # Add a move at the previous day of the first day of fiscal year
# to check the initial balance # to check the initial balance
@ -267,6 +271,21 @@ class TestGeneralLedgerReport(AccountTestInvoicingCommon):
self.assertEqual(income_fin_balance["credit"], 0) self.assertEqual(income_fin_balance["credit"], 0)
self.assertEqual(income_fin_balance["balance"], 1000) self.assertEqual(income_fin_balance["balance"], 1000)
# Re Generate the general ledger line
res_data = self._get_report_lines(
account_ids=(self.receivable_account + self.income_account).ids
)
general_ledger = res_data["general_ledger"]
self.assertTrue(
self.check_account_in_report(self.receivable_account.id, general_ledger)
)
self.assertTrue(
self.check_account_in_report(self.income_account.id, general_ledger)
)
self.assertFalse(
self.check_account_in_report(self.unaffected_account.id, general_ledger)
)
# Add another move at the end day of fiscal year # Add another move at the end day of fiscal year
# to check that it correctly used on report # to check that it correctly used on report
self._add_move( self._add_move(

View File

@ -251,6 +251,7 @@ class TestJournalReport(AccountTestInvoicingCommon):
line_form.account_id = self.expense_account line_form.account_id = self.expense_account
line_form.tax_ids.add(self.tax_15_p) line_form.tax_ids.add(self.tax_15_p)
line_form.tax_ids.add(self.tax_20_p) line_form.tax_ids.add(self.tax_20_p)
move_form.invoice_date = move_form.date
invoice = move_form.save() invoice = move_form.save()
invoice.action_post() invoice.action_post()

View File

@ -159,7 +159,9 @@ class TestTrialBalanceReport(AccountTestInvoicingCommon):
move = self.env["account.move"].create(move_vals) move = self.env["account.move"].create(move_vals)
move.action_post() move.action_post()
def _get_report_lines(self, with_partners=False, hierarchy_on="computed"): def _get_report_lines(
self, with_partners=False, account_ids=False, hierarchy_on="computed"
):
company = self.env.user.company_id company = self.env.user.company_id
trial_balance = self.env["trial.balance.report.wizard"].create( trial_balance = self.env["trial.balance.report.wizard"].create(
{ {
@ -169,6 +171,7 @@ class TestTrialBalanceReport(AccountTestInvoicingCommon):
"hide_account_at_0": True, "hide_account_at_0": True,
"hierarchy_on": hierarchy_on, "hierarchy_on": hierarchy_on,
"company_id": company.id, "company_id": company.id,
"account_ids": account_ids,
"fy_start_date": self.fy_date_start, "fy_start_date": self.fy_date_start,
"show_partner_details": with_partners, "show_partner_details": with_partners,
} }
@ -243,8 +246,8 @@ class TestTrialBalanceReport(AccountTestInvoicingCommon):
self.assertTrue(self.account200 in self.group2.compute_account_ids) self.assertTrue(self.account200 in self.group2.compute_account_ids)
def test_01_account_balance_computed(self): def test_01_account_balance_computed(self):
# Make sure there's no account of type "Current Year Earnings" in the # Change code of the P&L for not being automatically included
# groups - We change the code # in group 1 balances
earning_accs = self.env["account.account"].search( earning_accs = self.env["account.account"].search(
[ [
( (
@ -256,8 +259,7 @@ class TestTrialBalanceReport(AccountTestInvoicingCommon):
] ]
) )
for acc in earning_accs: for acc in earning_accs:
if acc.code.startswith("1") or acc.code.startswith("2"): acc.code = "999" + acc.code
acc.code = "999" + acc.code
# Generate the general ledger line # Generate the general ledger line
res_data = self._get_report_lines() res_data = self._get_report_lines()
trial_balance = res_data["trial_balance"] trial_balance = res_data["trial_balance"]
@ -270,6 +272,9 @@ class TestTrialBalanceReport(AccountTestInvoicingCommon):
self.account200.id, trial_balance self.account200.id, trial_balance
) )
self.assertFalse(check_income_account) self.assertFalse(check_income_account)
self.assertTrue(
self.check_account_in_report(self.unaffected_account.id, trial_balance)
)
# Add a move at the previous day of the first day of fiscal year # Add a move at the previous day of the first day of fiscal year
# to check the initial balance # to check the initial balance
@ -332,6 +337,18 @@ class TestTrialBalanceReport(AccountTestInvoicingCommon):
) )
self.assertTrue(check_income_account) self.assertTrue(check_income_account)
# Re Generate the trial balance line with an account filter
res_data = self._get_report_lines(
account_ids=(self.account100 + self.account200).ids
)
trial_balance = res_data["trial_balance"]
self.assertTrue(self.check_account_in_report(self.account100.id, trial_balance))
self.assertTrue(self.check_account_in_report(self.account200.id, trial_balance))
# Unaffected account should not be present
self.assertFalse(
self.check_account_in_report(self.unaffected_account.id, trial_balance)
)
# Check the initial and final balance # Check the initial and final balance
account_receivable_lines = self._get_account_lines( account_receivable_lines = self._get_account_lines(
self.account100.id, trial_balance self.account100.id, trial_balance

View File

@ -6,7 +6,7 @@
{ {
"name": "Tax Balance", "name": "Tax Balance",
"summary": "Compute tax balances based on date range", "summary": "Compute tax balances based on date range",
"version": "2.0.1.0.1", "version": "2.0.1.1.0",
"category": "Invoices & Payments", "category": "Invoices & Payments",
"website": "https://gitlab.com/flectra-community/account-financial-reporting", "website": "https://gitlab.com/flectra-community/account-financial-reporting",
"author": "Agile Business Group, Therp BV, Tecnativa, ACSONE SA/NV, " "author": "Agile Business Group, Therp BV, Tecnativa, ACSONE SA/NV, "

View File

@ -15,42 +15,42 @@
<button <button
type="object" type="object"
name="view_tax_regular_lines" name="view_tax_regular_lines"
string="View tax regular lines" title="View tax regular lines"
icon="fa-search-plus" icon="fa-search-plus"
/> />
<field name="base_balance_regular" sum="Base Total" /> <field name="base_balance_regular" sum="Base Total" />
<button <button
type="object" type="object"
name="view_base_regular_lines" name="view_base_regular_lines"
string="View base regular lines" title="View base regular lines"
icon="fa-search-plus" icon="fa-search-plus"
/> />
<field name="balance_refund" sum="Total" /> <field name="balance_refund" sum="Total" />
<button <button
type="object" type="object"
name="view_tax_refund_lines" name="view_tax_refund_lines"
string="View tax refund lines" title="View tax refund lines"
icon="fa-search-plus" icon="fa-search-plus"
/> />
<field name="base_balance_refund" sum="Base Total" /> <field name="base_balance_refund" sum="Base Total" />
<button <button
type="object" type="object"
name="view_base_refund_lines" name="view_base_refund_lines"
string="View base refund lines" title="View base refund lines"
icon="fa-search-plus" icon="fa-search-plus"
/> />
<field name="balance" sum="Total" /> <field name="balance" sum="Total" />
<button <button
type="object" type="object"
name="view_tax_lines" name="view_tax_lines"
string="View tax lines" title="View tax lines"
icon="fa-search-plus" icon="fa-search-plus"
/> />
<field name="base_balance" sum="Base Total" /> <field name="base_balance" sum="Base Total" />
<button <button
type="object" type="object"
name="view_base_lines" name="view_base_lines"
string="View base lines" title="View base lines"
icon="fa-search-plus" icon="fa-search-plus"
/> />
</tree> </tree>