-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] oxigen_account: convert the trial balance to multi-company
- Loading branch information
Showing
11 changed files
with
261 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from . import models, wizards | ||
from . import models, wizards, report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import trial_balance | ||
from . import abstract_report | ||
from . import trial_balance_xlsx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright NuoBiT - Frank Cespedes <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
from odoo import models | ||
|
||
|
||
class AccountFinancialAbstractReport(models.AbstractModel): | ||
_inherit = "report.account_financial_report.abstract_report" | ||
|
||
def _get_accounts_data(self, accounts_ids): | ||
accounts_data = super()._get_accounts_data(accounts_ids) | ||
accounts = self.env["account.account"].browse(accounts_ids) | ||
for account in accounts: | ||
accounts_data[account.id]["company"] = account.company_id.name | ||
return accounts_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!-- Copyright NuoBiT - Frank Cespedes <[email protected]> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) --> | ||
<odoo> | ||
<template | ||
id="report_trial_balance_lines_header_oxigen" | ||
inherit_id="account_financial_report.report_trial_balance_lines_header" | ||
priority="100" | ||
> | ||
<xpath | ||
expr="//div[hasclass('act_as_row') and hasclass('labels')]/t[@t-if='not show_partner_details']" | ||
position="before" | ||
> | ||
<div class="act_as_cell" style="width: 9%;">Company</div> | ||
</xpath> | ||
</template> | ||
<template | ||
id="report_trial_balance_line_oxigen" | ||
inherit_id="account_financial_report.report_trial_balance_line" | ||
priority="100" | ||
> | ||
<xpath | ||
expr="//div[hasclass('act_as_row') and hasclass('lines')]/t[@t-if='not show_partner_details']" | ||
position="before" | ||
> | ||
<div class="act_as_cell left" t-att-style="style"> | ||
<span | ||
t-att-res-id="balance['id']" | ||
res-model="account.account" | ||
view-type="form" | ||
> | ||
<t t-esc="balance['company']" /> | ||
</span> | ||
</div> | ||
</xpath> | ||
</template> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright NuoBiT - Frank Cespedes <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
from odoo import api, models | ||
|
||
|
||
class TrialBalanceReport(models.AbstractModel): | ||
_inherit = "report.account_financial_report.trial_balance" | ||
|
||
def _get_groups_data(self, accounts_data, total_amount, foreign_currency): | ||
return super(TrialBalanceReport, self.sudo())._get_groups_data( | ||
accounts_data, total_amount, foreign_currency | ||
) | ||
|
||
def _get_hierarchy_groups(self, group_ids, groups_data, foreign_currency): | ||
groups_data = super()._get_hierarchy_groups( | ||
group_ids, groups_data, foreign_currency | ||
) | ||
for group_id in groups_data.keys(): | ||
group = self.env["account.group"].browse(group_id) | ||
groups_data[group_id]["company"] = group.company_id.name | ||
return groups_data | ||
|
||
def _get_report_values(self, docids, data=None): | ||
company_ids = data.get("company_ids", []) | ||
if company_ids: | ||
self = self.with_context(company_ids=company_ids) | ||
return super(TrialBalanceReport, self)._get_report_values(docids, data) | ||
|
||
@api.model | ||
def _get_data( | ||
self, | ||
account_ids, | ||
journal_ids, | ||
partner_ids, | ||
company_id, | ||
date_to, | ||
date_from, | ||
foreign_currency, | ||
only_posted_moves, | ||
show_partner_details, | ||
hide_account_at_0, | ||
unaffected_earnings_account, | ||
fy_start_date, | ||
): | ||
company_ids = self.env.context.get("company_ids", []) | ||
total_amount, accounts_data, partners_data = {}, {}, [] | ||
for company_id in company_ids: | ||
ta, ad, pd = super(TrialBalanceReport, self.sudo())._get_data( | ||
account_ids, | ||
journal_ids, | ||
partner_ids, | ||
company_id, | ||
date_to, | ||
date_from, | ||
foreign_currency, | ||
only_posted_moves, | ||
show_partner_details, | ||
hide_account_at_0, | ||
unaffected_earnings_account, | ||
fy_start_date, | ||
) | ||
total_amount.update(ta) | ||
accounts_data.update(ad) | ||
partners_data.extend(pd) | ||
return total_amount, accounts_data, partners_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright NuoBiT - Frank Cespedes <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
from odoo import _, models | ||
|
||
|
||
class TrialBalanceXslx(models.AbstractModel): | ||
_inherit = "report.a_f_r.report_trial_balance_xlsx" | ||
|
||
def _get_report_columns(self, report): | ||
res = super()._get_report_columns(report) | ||
return { | ||
0: { | ||
"header": _("Company"), | ||
"field": "company", | ||
"width": 20, | ||
}, | ||
**{key + 1: value for key, value in res.items()}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import change_date_draft_invoices | ||
from . import trial_balance_wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright NuoBiT - Frank Cespedes <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class TrialBalanceReportWizard(models.TransientModel): | ||
_inherit = "trial.balance.report.wizard" | ||
|
||
@api.model | ||
def _get_company_domain(self): | ||
return [("id", "in", self.env.user.company_ids.ids)] | ||
|
||
company_ids = fields.Many2many( | ||
comodel_name="res.company", | ||
default=lambda self: self.env.company.ids, | ||
required=False, | ||
domain=lambda self: self._get_company_domain(), | ||
string="Companies", | ||
) | ||
|
||
def _prepare_report_trial_balance(self): | ||
data = super()._prepare_report_trial_balance() | ||
data["company_ids"] = self.company_ids.ids | ||
return data |
Oops, something went wrong.