Odoo Help


3 Semua Jawaban

René Schuster Jerman

--René Schuster--
| 7 7 10
Weinheim, Jerman
--René Schuster--

Challenge Everything!

René Schuster Jerman
25/11/14 04.41

I wonder why a browse object has a copy method.

You need to call the copy mehtod of the company object.

What you might want to try is something like this:

new_company_id = self.pool.get('res_company').copy(cr, uid, YourCompany_id, default={'name': 'New name'}, context=context)

where YourCompany_id could be template_user.company_id.id



1 Komentar
Anders Wallenquist Sweden
02/12/14 05.32

Thank you, I have tested self.env['res.company'].copy (I dont have cr/uid) it looks like I got a copy but not any company-object nor company_id returned. def add_activity(self): template_user = self.env['res.users'].browse(literal_eval(self.env['ir.config_parameter'].get_param('auth_signup.template_user_id', 'False')),) assert template_user and template_user.exists(), 'Signup: invalid template user' for user in self: if user.company_id.id == template_user.company_id.id: company_id = self.env['res.company'].copy(template_user.company_id.id,default={ 'name': _('%s Activity') % user.name, 'currency_id': template_user.company_id.currency_id.id, 'country_id': template_user.company_id.country_id.id, 'parent_id': template_user.company_id.parent_id.id,}) _logger.warning("res.user company %s" % (company_id)) user.write({'company_ids': (6,_,[company_id,template_user.parent_id.id]),'company_id': company_id})

Hernaldo Henriquez Chili
20/10/17 08.58

I think that might be because in the definition of the Partner model from Odoo name is an index of the database and is defined like this:

name = fields.Char(index=True)

So you should inherit that model to redefine name to have a copy=False attribute (because default is True).

class Partner(models.Model):
_inherit = 'res.partner'

name = fields.Char(index=True, copy=False)

Mengajukan pertanyaan
Keep Informed
1 Follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now