summaryrefslogtreecommitdiff
path: root/addons/project
diff options
context:
space:
mode:
authorRobot Odoo <xmo+roboto@odoo.com>2019-07-04 18:42:51 +0200
committerGitHub <noreply@github.com>2019-07-04 18:42:51 +0200
commit3fc2a27808ca4e4ce74884580543e70537d5ce3b (patch)
treedcc607ed9bf97adfa0bc12ce1695cc332da7254c /addons/project
parentcaf900e89ea292c56ed773232792a2aab19de8d5 (diff)
parent2511841da1c42622b2d83f2235417bb83d14a76a (diff)
[MERGE] project, sale_timesheet: multi company fixes
Impacted modules: project, sale, sale_timesheet and project_timesheet_holidays. Since a5b6f31cf28e5381e1c85f66730bcdb55998e643, the multi company environment is contextualized, allowing people to see several company documents at the same time. This reveals some problem in such env. To solve this, we need to force the "company_id" field as required on some business model, and to correctly propagate the company when a document generate another one. The guidelines is to stop using company of current user, but the one of the document itself. See subcommits for more details. Task-1999686 closes odoo/odoo#33739 Signed-off-by: Jérome Maes (jem) <jem@openerp.com>
Diffstat (limited to 'addons/project')
-rw-r--r--addons/project/models/project.py6
-rw-r--r--addons/project/security/project_security.xml12
-rw-r--r--addons/project/views/project_views.xml5
3 files changed, 6 insertions, 17 deletions
diff --git a/addons/project/models/project.py b/addons/project/models/project.py
index ad874ebfdab..f9a9f53c406 100644
--- a/addons/project/models/project.py
+++ b/addons/project/models/project.py
@@ -408,7 +408,7 @@ class Project(models.Model):
def _create_analytic_account_from_values(self, values):
analytic_account = self.env['account.analytic.account'].create({
'name': values.get('name', _('Unknown Analytic Account')),
- 'company_id': values.get('company_id', self.env.user.company_id.id),
+ 'company_id': values.get('company_id') or self.env.company.id,
'partner_id': values.get('partner_id'),
'active': True,
})
@@ -519,9 +519,7 @@ class Task(models.Model):
string='Customer',
default=lambda self: self._get_default_partner())
manager_id = fields.Many2one('res.users', string='Project Manager', related='project_id.user_id', readonly=True, related_sudo=False)
- company_id = fields.Many2one('res.company',
- string='Company',
- default=lambda self: self.env.company)
+ company_id = fields.Many2one('res.company', string='Company', required=True, default=lambda self: self.env.company)
color = fields.Integer(string='Color Index')
user_email = fields.Char(related='user_id.email', string='User Email', readonly=True, related_sudo=False)
attachment_ids = fields.One2many('ir.attachment', compute='_compute_attachment_ids', string="Main Attachments",
diff --git a/addons/project/security/project_security.xml b/addons/project/security/project_security.xml
index c50386bb6ec..eecc68d1ccb 100644
--- a/addons/project/security/project_security.xml
+++ b/addons/project/security/project_security.xml
@@ -38,10 +38,7 @@
<field name="name">Project: multi-company</field>
<field name="model_id" ref="model_project_project"/>
<field name="global" eval="True"/>
- <field name="domain_force">['|',
- ('company_id', '=', False),
- ('company_id', 'in', company_ids),
- ]</field>
+ <field name="domain_force">[('company_id', 'in', company_ids)]</field>
</record>
<record model="ir.rule" id="project_project_manager_rule">
@@ -67,10 +64,7 @@
<field name="name">Project/Task: multi-company</field>
<field name="model_id" ref="model_project_task"/>
<field name="global" eval="True"/>
- <field name="domain_force">['|',
- ('company_id', '=', False),
- ('company_id', 'in', company_ids),
- ]</field>
+ <field name="domain_force">[('company_id', 'in', company_ids)]</field>
</record>
<record model="ir.rule" id="task_visibility_rule">
@@ -100,7 +94,7 @@
<field name="name">Task Analysis multi-company</field>
<field name="model_id" ref="model_report_project_task_user"/>
<field name="global" eval="True"/>
- <field name="domain_force">['|',('company_id','=',False),('company_id', 'in', company_ids)]</field>
+ <field name="domain_force">[('company_id', 'in', company_ids)]</field>
</record>
<!-- Portal -->
diff --git a/addons/project/views/project_views.xml b/addons/project/views/project_views.xml
index 035f70f4e5f..cbd14f7caa1 100644
--- a/addons/project/views/project_views.xml
+++ b/addons/project/views/project_views.xml
@@ -151,15 +151,12 @@
<field name="rating_status_period" class="oe_inline" attrs="{'required': [('rating_status','=','periodic')], 'invisible': [('rating_status','!=','periodic')]}" groups="project.group_project_rating"/>
<field name="portal_show_rating" attrs="{'invisible': [('rating_status','==','no')]}" groups="project.group_project_rating"/>
<field name="subtask_project_id" groups="project.group_subtask_project"/>
+ <field name="company_id" groups="base.group_multi_company"/>
</group>
<group name="extra_settings">
</group>
</group>
<group name="misc">
- <group string="Configuration" groups="base.group_no_one" name="configuration">
- <field name="sequence" groups="base.group_no_one"/>
- <field name="company_id" groups="base.group_multi_company"/>
- </group>
<group string="Time Scheduling">
<field name="resource_calendar_id"/>
</group>