From 776d28b539c3db6154c9d49c55e583e5be5de02f Mon Sep 17 00:00:00 2001 From: hupo-odoo Date: Wed, 28 Dec 2022 16:33:24 +0000 Subject: [PATCH] [IMP] account: show company name when accounting firm Accounting firms are often connected to customer's company, so often single company database. To know easily in which company they work we think that it should be better to show the name of the company on the top for them. A systray item is therefore generated at the location of the company selector. It is visible only when there is a single company (so no company selector) and only when accounting firms mode is on, i.e. the setting field is set to either one of these values ('customer Invoices', 'Vendor Bills', 'Customer Invoices and Vendor Bills') closes odoo/odoo#108928 Task: 3110453 Pr: 108928 Signed-off-by: Quentin De Paoli --- addons/account/models/__init__.py | 1 + addons/account/models/ir_http.py | 11 ++++++++ .../components/systray_item/systray_item.js | 26 +++++++++++++++++++ .../components/systray_item/systray_item.xml | 8 ++++++ 4 files changed, 46 insertions(+) create mode 100644 addons/account/models/ir_http.py create mode 100644 addons/account/static/src/components/systray_item/systray_item.js create mode 100644 addons/account/static/src/components/systray_item/systray_item.xml diff --git a/addons/account/models/__init__.py b/addons/account/models/__init__.py index 80c0ce03e17..a809415fe8b 100644 --- a/addons/account/models/__init__.py +++ b/addons/account/models/__init__.py @@ -2,6 +2,7 @@ from . import sequence_mixin from . import partner +from . import ir_http from . import res_partner_bank from . import account_account_tag from . import account_account diff --git a/addons/account/models/ir_http.py b/addons/account/models/ir_http.py new file mode 100644 index 00000000000..6157cdfe74b --- /dev/null +++ b/addons/account/models/ir_http.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +from odoo import models + + +class IrHttp(models.AbstractModel): + _inherit = 'ir.http' + + def session_info(self): + result = super(IrHttp, self).session_info() + result['is_quick_edit_mode_enabled'] = self.env.user._is_internal() and self.env.company.quick_edit_mode + return result diff --git a/addons/account/static/src/components/systray_item/systray_item.js b/addons/account/static/src/components/systray_item/systray_item.js new file mode 100644 index 00000000000..9fa25a9009e --- /dev/null +++ b/addons/account/static/src/components/systray_item/systray_item.js @@ -0,0 +1,26 @@ +/** @odoo-module **/ + +import { registry } from "@web/core/registry"; +import { useService } from "@web/core/utils/hooks"; +import { Component } from "@odoo/owl"; +import { session } from '@web/session'; + +export class AccountSystrayItem extends Component { + static template = "account.SystrayItem"; + static props = {}; + + setup() { + this.currentCompany = useService("company").currentCompany; + this.isQuickEditModeEnabled = session.is_quick_edit_mode_enabled; + } +} + +export const systrayItem = { + Component: AccountSystrayItem, + isDisplayed : function(env) { + const { availableCompanies } = env.services.company; + return Object.keys(availableCompanies).length === 1; + }, +}; + +registry.category("systray").add("AccountSystrayItem", systrayItem, { sequence: 1 }); diff --git a/addons/account/static/src/components/systray_item/systray_item.xml b/addons/account/static/src/components/systray_item/systray_item.xml new file mode 100644 index 00000000000..f2cc401285c --- /dev/null +++ b/addons/account/static/src/components/systray_item/systray_item.xml @@ -0,0 +1,8 @@ + + + +
+ +
+
+