[FIX] account: branch management fixes

After feedback on the new branch management feature, there were a few
bugs reported. This commit solves several of them:

- Display the company/branch name of a reconciled payment in the info
  popover when viewing customer invoices and vendor bills. This way you
  can see why you don't have access to the payment e.g.
- Make it possible to select the taxes of the parent company when
  creating moves in a branch.
- Allow users with only access to a branch to open the Accounting app.
  The dashboard would fail with a security error before.

task-3461421

closes odoo/odoo#134000

X-original-commit: 92d261d9a3f64fcbb01023e680d362b598061707
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
Signed-off-by: Dylan Kiss (dyki) <dyki@odoo.com>
This commit is contained in:
Dylan Kiss (dyki)
2023-09-04 10:56:06 +00:00
parent f740f590f4
commit 09b8c32e9e
5 changed files with 24 additions and 7 deletions
+7
View File
@@ -2943,6 +2943,13 @@ msgstr ""
msgid "Boolean"
msgstr ""
#. module: account
#. odoo-javascript
#: code:addons/account/static/src/components/account_payment_field/account_payment.xml:0
#, python-format
msgid "Branch:"
msgstr ""
#. module: account
#: model:ir.model.fields,field_description:account.field_account_account__include_initial_balance
msgid "Bring Accounts Balance Forward"
@@ -193,7 +193,8 @@ class account_journal(models.Model):
result = {}
for journal in self:
graph_title, graph_key = journal._graph_title_and_key()
currency = journal.currency_id or journal.company_id.currency_id
# User may have read access on the journal but not on the company
currency = journal.currency_id or self.env['res.currency'].browse(journal.company_id.sudo().currency_id.id)
journal_result = query_result[journal.id]
color = '#875A7B' if 'e' in version else '#7c7bad'
@@ -257,7 +258,8 @@ class account_journal(models.Model):
query_results = {r['journal_id']: r for r in self.env.cr.dictfetchall()}
result = {}
for journal in self:
currency = journal.currency_id or journal.company_id.currency_id
# User may have read access on the journal but not on the company
currency = journal.currency_id or self.env['res.currency'].browse(journal.company_id.sudo().currency_id.id)
graph_title, graph_key = journal._graph_title_and_key()
sign = 1 if journal.type == 'sale' else -1
journal_data = query_results.get(journal.id)
@@ -300,7 +302,7 @@ class account_journal(models.Model):
dashboard_data = {} # container that will be filled by functions below
for journal in self:
dashboard_data[journal.id] = {
'currency_id': journal.currency_id.id or journal.company_id.currency_id.id,
'currency_id': journal.currency_id.id or journal.company_id.sudo().currency_id.id,
'company_count': len(self.env.companies),
}
self._fill_bank_cash_dashboard_data(dashboard_data)
@@ -397,7 +399,8 @@ class account_journal(models.Model):
}
for journal in bank_cash_journals:
currency = journal.currency_id or journal.company_id.currency_id
# User may have read access on the journal but not on the company
currency = journal.currency_id or self.env['res.currency'].browse(journal.company_id.sudo().currency_id.id)
has_outstanding, outstanding_pay_account_balance = outstanding_pay_account_balances[journal.id]
to_check_balance, number_to_check = to_check.get(journal.id, (0, 0))
misc_balance, number_misc = misc_totals.get(journal.default_account_id, (0, 0))
@@ -457,7 +460,8 @@ class account_journal(models.Model):
curr_cache = {}
sale_purchase_journals._fill_dashboard_data_count(dashboard_data, 'account.move', 'entries_count', [])
for journal in sale_purchase_journals:
currency = journal.currency_id or journal.company_id.currency_id
# User may have read access on the journal but not on the company
currency = journal.currency_id or self.env['res.currency'].browse(journal.company_id.sudo().currency_id.id)
(number_waiting, sum_waiting) = self._count_results_and_sum_amounts(query_results_to_pay[journal.id], currency, curr_cache=curr_cache)
(number_draft, sum_draft) = self._count_results_and_sum_amounts(query_results_drafts[journal.id], currency, curr_cache=curr_cache)
(number_late, sum_late) = self._count_results_and_sum_amounts(late_query_results[journal.id], currency, curr_cache=curr_cache)
@@ -613,7 +617,8 @@ class account_journal(models.Model):
result = {}
curr_cache = {}
for journal in self:
currency = journal.currency_id or journal.company_id.currency_id
# User may have read access on the journal but not on the company
currency = journal.currency_id or self.env['res.currency'].browse(journal.company_id.sudo().currency_id.id)
result[journal.id] = self._count_results_and_sum_amounts(query_result[journal.id], currency, curr_cache)
return result
+1
View File
@@ -1202,6 +1202,7 @@ class AccountMove(models.Model):
reconciled_vals.append({
'name': counterpart_line.name,
'journal_name': counterpart_line.journal_id.name,
'company_name': counterpart_line.journal_id.company_id.name if counterpart_line.journal_id.company_id != move.company_id else None,
'amount': reconciled_partial['amount'],
'currency_id': move.company_id.currency_id.id if reconciled_partial['is_exchange'] else reconciled_partial['currency'].id,
'date': counterpart_line.date,
@@ -92,6 +92,10 @@
<td><strong>Journal: </strong></td>
<td><t t-out="props.journal_name"/><span t-if="props.payment_method_name"> (<t t-out="props.payment_method_name"/>)</span></td>
</tr>
<tr t-if="props.company_name">
<td><strong>Branch: </strong></td>
<td><t t-out="props.company_name"/></td>
</tr>
</table>
</div>
<button class="btn btn-sm btn-primary js_unreconcile_payment float-start" t-if="!props.is_exchange" style="margin-top:5px; margin-bottom:5px;" groups="account.group_account_invoice" t-on-click="() => props._onRemoveMoveReconcile(props.move_id, props.partial_id)">Unreconcile</button>
+1 -1
View File
@@ -946,7 +946,7 @@
<field name="price_unit" string="Price"/>
<field name="discount" string="Disc.%" optional="hide"/>
<field name="tax_ids" widget="many2many_tags"
domain="[('type_tax_use', '=?', parent.invoice_filter_type_domain), ('company_id', '=', parent.company_id), ('country_id', '=', parent.tax_country_id)]"
domain="[('type_tax_use', '=?', parent.invoice_filter_type_domain), ('company_id', 'parent_of', parent.company_id), ('country_id', '=', parent.tax_country_id)]"
context="{'append_type_to_tax_name': not parent.invoice_filter_type_domain, 'active_test': True}"
options="{'no_create': True}"
optional="show"/>