[FIX] base: disable the copying of the res.company

When copying a company, the default accounts/journals are copyied too.
The chart_template_id and the opening move are also copyied.
To conclude: copying a company is a very bad idea that leads to a lot of access rights issues.

-githug issue: 21213
This commit is contained in:
Laurent Smet
2018-02-28 15:19:48 +01:00
parent d5d2a33424
commit bff30f58c5
+2 -11
View File
@@ -5,7 +5,7 @@ import os
import re
from odoo import api, fields, models, tools, _
from odoo.exceptions import ValidationError
from odoo.exceptions import ValidationError, UserError
class Company(models.Model):
@@ -15,16 +15,7 @@ class Company(models.Model):
@api.multi
def copy(self, default=None):
"""
Duplicating a company without specifying a partner duplicate the partner
"""
self.ensure_one()
default = dict(default or {})
if not default.get('name') and not default.get('partner_id'):
copy_partner = self.partner_id.copy()
default['partner_id'] = copy_partner.id
default['name'] = copy_partner.name
return super(Company, self).copy(default)
raise UserError(_('Duplicate a company is not allowed. Please create a new one instead.'))
def _get_logo(self):
return base64.b64encode(open(os.path.join(tools.config['root_path'], 'addons', 'base', 'res', 'res_company_logo.png'), 'rb') .read())