From 2bbff57691a33a02ca6a85a600f0b32035daa2a4 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 7 Aug 2014 12:50:13 +0200 Subject: [PATCH] [IMP] hr,mail,product,project,base: use @auto_join=True on _inherits FK field This can give a performance boost on large databases and should not be a concern in terms of access control as the inheritance already grants access to the parent records. --- addons/hr/hr.py | 2 +- addons/mail/mail_mail.py | 2 +- addons/mail/res_users.py | 2 +- addons/product/product.py | 2 +- addons/project/project.py | 6 +++++- openerp/addons/base/res/res_users.py | 2 +- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/addons/hr/hr.py b/addons/hr/hr.py index 5e081fab3bf..efec3e6e2be 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -207,7 +207,7 @@ class hr_employee(osv.osv): 'parent_id': fields.many2one('hr.employee', 'Manager'), 'category_ids': fields.many2many('hr.employee.category', 'employee_category_rel', 'emp_id', 'category_id', 'Tags'), 'child_ids': fields.one2many('hr.employee', 'parent_id', 'Subordinates'), - 'resource_id': fields.many2one('resource.resource', 'Resource', ondelete='cascade', required=True), + 'resource_id': fields.many2one('resource.resource', 'Resource', ondelete='cascade', required=True, auto_join=True), 'coach_id': fields.many2one('hr.employee', 'Coach'), 'job_id': fields.many2one('hr.job', 'Job Title'), # image: all image fields are base64 encoded and PIL-supported diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py index aeea2c0b1a5..fa4122cbedd 100644 --- a/addons/mail/mail_mail.py +++ b/addons/mail/mail_mail.py @@ -44,7 +44,7 @@ class mail_mail(osv.Model): _rec_name = 'subject' _columns = { - 'mail_message_id': fields.many2one('mail.message', 'Message', required=True, ondelete='cascade'), + 'mail_message_id': fields.many2one('mail.message', 'Message', required=True, ondelete='cascade', auto_join=True), 'state': fields.selection([ ('outgoing', 'Outgoing'), ('sent', 'Sent'), diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index 097893ae601..eedc04603f0 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -40,7 +40,7 @@ class res_users(osv.Model): _columns = { 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True, help="Email address internally associated with this user. Incoming "\ - "emails will appear in the user's notifications.", copy=False), + "emails will appear in the user's notifications.", copy=False, auto_join=True), 'display_groups_suggestions': fields.boolean("Display Groups Suggestions"), } diff --git a/addons/product/product.py b/addons/product/product.py index c55fe448b1c..90a3c3ae6ff 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -904,7 +904,7 @@ class product_product(osv.osv): 'partner_ref' : fields.function(_product_partner_ref, type='char', string='Customer ref'), 'default_code' : fields.char('Internal Reference', select=True), 'active': fields.boolean('Active', help="If unchecked, it will allow you to hide the product without removing it."), - 'product_tmpl_id': fields.many2one('product.template', 'Product Template', required=True, ondelete="cascade", select=True), + 'product_tmpl_id': fields.many2one('product.template', 'Product Template', required=True, ondelete="cascade", select=True, auto_join=True), 'ean13': fields.char('EAN13 Barcode', size=13, help="International Article Number used for product identification."), 'name_template': fields.related('product_tmpl_id', 'name', string="Template Name", type='char', store={ 'product.template': (_get_name_template_ids, ['name'], 10), diff --git a/addons/project/project.py b/addons/project/project.py index 5beb80ffed5..4deb73ff48e 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -227,7 +227,11 @@ class project(osv.osv): _columns = { 'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the project without removing it."), 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of Projects."), - 'analytic_account_id': fields.many2one('account.analytic.account', 'Contract/Analytic', help="Link this project to an analytic account if you need financial management on projects. It enables you to connect projects with budgets, planning, cost and revenue analysis, timesheets on projects, etc.", ondelete="cascade", required=True), + 'analytic_account_id': fields.many2one( + 'account.analytic.account', 'Contract/Analytic', + help="Link this project to an analytic account if you need financial management on projects. " + "It enables you to connect projects with budgets, planning, cost and revenue analysis, timesheets on projects, etc.", + ondelete="cascade", required=True, auto_join=True), 'members': fields.many2many('res.users', 'project_user_rel', 'project_id', 'uid', 'Project Members', help="Project's members are users who can have an access to the tasks related to this project.", states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), 'tasks': fields.one2many('project.task', 'project_id', "Task Activities"), diff --git a/openerp/addons/base/res/res_users.py b/openerp/addons/base/res/res_users.py index 7102c009264..023bccb2efa 100644 --- a/openerp/addons/base/res/res_users.py +++ b/openerp/addons/base/res/res_users.py @@ -166,7 +166,7 @@ class res_users(osv.osv): 'login_date': fields.date('Latest connection', select=1), 'partner_id': fields.many2one('res.partner', required=True, string='Related Partner', ondelete='restrict', - help='Partner-related data of the user'), + help='Partner-related data of the user', auto_join=True), 'login': fields.char('Login', size=64, required=True, help="Used to log into the system"), 'password': fields.char('Password', size=64, invisible=True, copy=False,