[FIX] *: use lazy translation for _get_stat_buttons in project update
Before this commit, the translation is not done in lazy, so for each stat button shown in the right side panel of the project update, a query is done to find the correct translation based on the language of the user. It means, the translation is costly and need to be done in lazy to reduce the time for the translation of those stat buttons. This commit uses the `_lt` to translate in lazy mode those stat buttons. By doing that, the execution time is reduced from 750 ms to 250 ms. X-original-commit: 95fe018 Part-of: odoo/odoo#85660 Co-authored-by: Yannick Tivisse <yti@odoo.com> Co-authored-by: Laurent Stukkens (LTU) <ltu@odoo.com>
This commit is contained in:
co-authored by
Yannick Tivisse
Laurent Stukkens
parent
15f285a9ec
commit
41bcee0cda
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models, _
|
||||
from odoo import fields, models, _lt
|
||||
|
||||
class Project(models.Model):
|
||||
_inherit = 'project.project'
|
||||
@@ -17,7 +17,7 @@ class Project(models.Model):
|
||||
if self.user_has_groups('account.group_account_readonly'):
|
||||
buttons.append({
|
||||
'icon': 'pencil-square-o',
|
||||
'text': _('Invoices'),
|
||||
'text': _lt('Invoices'),
|
||||
'number': self.invoice_count,
|
||||
'action_type': 'object',
|
||||
'action': 'action_open_project_invoices',
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo import models, fields, api, _, _lt
|
||||
from odoo.exceptions import UserError, ValidationError, RedirectWarning
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ class Project(models.Model):
|
||||
if self.user_has_groups('hr_timesheet.group_hr_timesheet_user'):
|
||||
buttons.append({
|
||||
'icon': 'clock-o',
|
||||
'text': _('Recorded'),
|
||||
'text': _lt('Recorded'),
|
||||
'number': '%s %s' % (self.total_timesheet_time, self.env.company.timesheet_encode_uom_id.name),
|
||||
'action_type': 'object',
|
||||
'action': 'action_show_timesheets_by_employee_invoice_type',
|
||||
|
||||
@@ -8,7 +8,7 @@ from collections import defaultdict
|
||||
from datetime import timedelta, datetime, time
|
||||
from random import randint
|
||||
|
||||
from odoo import api, Command, fields, models, tools, SUPERUSER_ID, _
|
||||
from odoo import api, Command, fields, models, tools, SUPERUSER_ID, _, _lt
|
||||
from odoo.exceptions import UserError, ValidationError, AccessError
|
||||
from odoo.tools import format_amount
|
||||
from odoo.osv.expression import OR, AND
|
||||
@@ -746,7 +746,7 @@ class Project(models.Model):
|
||||
self.ensure_one()
|
||||
buttons = [{
|
||||
'icon': 'tasks',
|
||||
'text': _('Tasks'),
|
||||
'text': _lt('Tasks'),
|
||||
'number': self.task_count,
|
||||
'action_type': 'action',
|
||||
'action': 'project.act_project_project_2_project_task_all',
|
||||
@@ -759,7 +759,7 @@ class Project(models.Model):
|
||||
if self.user_has_groups('project.group_project_rating'):
|
||||
buttons.append({
|
||||
'icon': 'smile-o',
|
||||
'text': _('Satisfaction'),
|
||||
'text': _lt('Satisfaction'),
|
||||
'number': f'{round(100 * self.rating_avg_percentage, 2)} %',
|
||||
'action_type': 'object',
|
||||
'action': 'action_view_all_rating',
|
||||
@@ -769,7 +769,7 @@ class Project(models.Model):
|
||||
if self.user_has_groups('project.group_project_manager'):
|
||||
buttons.append({
|
||||
'icon': 'area-chart',
|
||||
'text': _('Burndown Chart'),
|
||||
'text': _lt('Burndown Chart'),
|
||||
'action_type': 'action',
|
||||
'action': 'project.action_project_task_burndown_chart_report',
|
||||
'additional_context': json.dumps({
|
||||
@@ -780,7 +780,7 @@ class Project(models.Model):
|
||||
})
|
||||
buttons.append({
|
||||
'icon': 'users',
|
||||
'text': _('Collaborators'),
|
||||
'text': _lt('Collaborators'),
|
||||
'number': self.collaborator_count,
|
||||
'action_type': 'action',
|
||||
'action': 'project.project_collaborator_action',
|
||||
@@ -793,7 +793,7 @@ class Project(models.Model):
|
||||
if self.user_has_groups('analytic.group_analytic_accounting'):
|
||||
buttons.append({
|
||||
'icon': 'usd',
|
||||
'text': _('Gross Margin'),
|
||||
'text': _lt('Gross Margin'),
|
||||
'number': format_amount(self.env, self.analytic_account_balance, self.company_id.currency_id),
|
||||
'action_type': 'object',
|
||||
'action': 'action_view_analytic_account_entries',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo import api, fields, models, _, _lt
|
||||
|
||||
class Project(models.Model):
|
||||
_inherit = 'project.project'
|
||||
@@ -49,7 +49,7 @@ class Project(models.Model):
|
||||
if self.user_has_groups('hr_expense.group_hr_expense_team_approver'):
|
||||
buttons.append({
|
||||
'icon': 'money',
|
||||
'text': _('Expenses'),
|
||||
'text': _lt('Expenses'),
|
||||
'number': self.expenses_count,
|
||||
'action_type': 'object',
|
||||
'action': 'action_open_project_expenses',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models, _
|
||||
from odoo import fields, models, _lt
|
||||
|
||||
|
||||
class Project(models.Model):
|
||||
@@ -41,7 +41,7 @@ class Project(models.Model):
|
||||
if self.user_has_groups('mrp.group_mrp_user'):
|
||||
buttons.extend([{
|
||||
'icon': 'wrench',
|
||||
'text': _('Manufacturing Orders'),
|
||||
'text': _lt('Manufacturing Orders'),
|
||||
'number': self.production_count,
|
||||
'action_type': 'object',
|
||||
'action': 'action_view_mrp_production',
|
||||
@@ -50,7 +50,7 @@ class Project(models.Model):
|
||||
},
|
||||
{
|
||||
'icon': 'cog',
|
||||
'text': _('Work Orders'),
|
||||
'text': _lt('Work Orders'),
|
||||
'number': self.workorder_count,
|
||||
'action_type': 'object',
|
||||
'action': 'action_view_workorder',
|
||||
@@ -59,7 +59,7 @@ class Project(models.Model):
|
||||
},
|
||||
{
|
||||
'icon': 'flask',
|
||||
'text': _('Bills of Materials'),
|
||||
'text': _lt('Bills of Materials'),
|
||||
'number': self.bom_count,
|
||||
'action_type': 'object',
|
||||
'action': 'action_view_mrp_bom',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo import api, fields, models, _, _lt
|
||||
|
||||
|
||||
class Project(models.Model):
|
||||
@@ -52,7 +52,7 @@ class Project(models.Model):
|
||||
if self.user_has_groups('purchase.group_purchase_user'):
|
||||
buttons.append({
|
||||
'icon': 'credit-card',
|
||||
'text': _('Purchase Orders'),
|
||||
'text': _lt('Purchase Orders'),
|
||||
'number': self.purchase_orders_count,
|
||||
'action_type': 'object',
|
||||
'action': 'action_open_project_purchase_orders',
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from ast import literal_eval
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo import api, fields, models, _, _lt
|
||||
from odoo.exceptions import ValidationError, AccessError
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ class Project(models.Model):
|
||||
if self.user_has_groups('sales_team.group_sale_salesman_all_leads'):
|
||||
buttons.append({
|
||||
'icon': 'dollar',
|
||||
'text': _('Sales Orders'),
|
||||
'text': _lt('Sales Orders'),
|
||||
'number': self.sale_order_count,
|
||||
'action_type': 'object',
|
||||
'action': 'action_view_sos',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models, _
|
||||
from odoo import fields, models, _, _lt
|
||||
|
||||
class Project(models.Model):
|
||||
_inherit = 'project.project'
|
||||
@@ -38,7 +38,7 @@ class Project(models.Model):
|
||||
if self.user_has_groups('account.group_account_readonly'):
|
||||
buttons.append({
|
||||
'icon': 'pencil-square-o',
|
||||
'text': _('Vendor Bills'),
|
||||
'text': _lt('Vendor Bills'),
|
||||
'number': self.vendor_bill_count,
|
||||
'action_type': 'object',
|
||||
'action': 'action_open_project_vendor_bills',
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import json
|
||||
from collections import defaultdict
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo import api, fields, models, _, _lt
|
||||
from odoo.osv import expression
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
from odoo.tools import format_amount, float_is_zero, formatLang
|
||||
@@ -404,7 +404,7 @@ class Project(models.Model):
|
||||
if self.user_has_groups('hr_timesheet.group_hr_timesheet_approver'):
|
||||
buttons.append({
|
||||
'icon': 'clock-o',
|
||||
'text': _('Billable Time'),
|
||||
'text': _lt('Billable Time'),
|
||||
'number': '%s %%' % (self.billable_percentage),
|
||||
'action_type': 'object',
|
||||
'action': 'action_billable_time_button',
|
||||
|
||||
Reference in New Issue
Block a user