[FIX] base: duplicate company => duplicate partner
The name of a company is uniq. The name of a company comes from a partner and is required. Thus duplicating a company didn't work. With this change, if no partner is overriding the copy, the current partner is duplicated and associated to the new duplicated company. opw-746106 closes #17532
This commit is contained in:
parent
c50745f1a1
commit
ed61da6793
|
@ -22,7 +22,7 @@
|
|||
import os
|
||||
import re
|
||||
import openerp
|
||||
from openerp import SUPERUSER_ID, tools
|
||||
from openerp import SUPERUSER_ID, tools, api
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools.translate import _
|
||||
from openerp.tools.safe_eval import safe_eval as eval
|
||||
|
@ -154,6 +154,19 @@ class res_company(osv.osv):
|
|||
('name_uniq', 'unique (name)', 'The company name must be unique !')
|
||||
]
|
||||
|
||||
@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(res_company, self).copy(default)
|
||||
|
||||
def onchange_footer(self, cr, uid, ids, custom_footer, phone, fax, email, website, vat, company_registry, bank_ids, context=None):
|
||||
if custom_footer:
|
||||
return {}
|
||||
|
|
Loading…
Reference in New Issue