summaryrefslogtreecommitdiff
path: root/addons/project/models
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/models
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/models')
-rw-r--r--addons/project/models/project.py6
1 files changed, 2 insertions, 4 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",