|
@ -9,50 +9,51 @@ from odoo.modules import registry |
|
|
from ..hooks import uninstall_hook |
|
|
from ..hooks import uninstall_hook |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestMassEditing(common.TransactionCase): |
|
|
|
|
|
|
|
|
class TestMassEditing(common.SavepointCase): |
|
|
at_install = False |
|
|
at_install = False |
|
|
post_install = True |
|
|
post_install = True |
|
|
|
|
|
|
|
|
def setUp(self): |
|
|
|
|
|
super(TestMassEditing, self).setUp() |
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
def setUpClass(cls): |
|
|
|
|
|
super(TestMassEditing, cls).setUpClass() |
|
|
# Model connections |
|
|
# Model connections |
|
|
model_obj = self.env['ir.model'] |
|
|
|
|
|
self.mass_wiz_obj = self.env['mass.editing.wizard'] |
|
|
|
|
|
self.mass_object_model = self.env['mass.object'] |
|
|
|
|
|
self.res_partner_model = self.env['res.partner'] |
|
|
|
|
|
self.ir_translation_model = self.env['ir.translation'] |
|
|
|
|
|
self.lang_model = self.env['res.lang'] |
|
|
|
|
|
|
|
|
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) |
|
|
|
|
|
model_obj = cls.env['ir.model'] |
|
|
|
|
|
cls.mass_wiz_obj = cls.env['mass.editing.wizard'] |
|
|
|
|
|
cls.mass_object_model = cls.env['mass.object'] |
|
|
|
|
|
cls.res_partner_model = cls.env['res.partner'] |
|
|
|
|
|
cls.ir_translation_model = cls.env['ir.translation'] |
|
|
|
|
|
cls.lang_model = cls.env['res.lang'] |
|
|
# Shared data for test methods |
|
|
# Shared data for test methods |
|
|
self.partner = self._create_partner() |
|
|
|
|
|
self.partner_model = model_obj.\ |
|
|
|
|
|
|
|
|
cls.partner = cls._create_partner() |
|
|
|
|
|
cls.partner_model = model_obj.\ |
|
|
search([('model', '=', 'res.partner')]) |
|
|
search([('model', '=', 'res.partner')]) |
|
|
self.user_model = model_obj.search([('model', '=', 'res.users')]) |
|
|
|
|
|
self.fields_model = self.env['ir.model.fields'].\ |
|
|
|
|
|
search([('model_id', '=', self.partner_model.id), |
|
|
|
|
|
|
|
|
cls.user_model = model_obj.search([('model', '=', 'res.users')]) |
|
|
|
|
|
cls.fields_model = cls.env['ir.model.fields'].\ |
|
|
|
|
|
search([('model_id', '=', cls.partner_model.id), |
|
|
('name', 'in', ['email', 'phone', 'category_id', 'comment', |
|
|
('name', 'in', ['email', 'phone', 'category_id', 'comment', |
|
|
'country_id', 'customer', 'child_ids', |
|
|
'country_id', 'customer', 'child_ids', |
|
|
'title', 'company_type'])]) |
|
|
'title', 'company_type'])]) |
|
|
self.mass = self._create_mass_editing(self.partner_model, |
|
|
|
|
|
self.fields_model, |
|
|
|
|
|
'Partner') |
|
|
|
|
|
self.copy_mass = self.mass.copy() |
|
|
|
|
|
self.user = self._create_user() |
|
|
|
|
|
self.res_partner_title_model = self.env['res.partner.title'] |
|
|
|
|
|
self.partner_title = self._create_partner_title() |
|
|
|
|
|
self.partner_title_model = model_obj.search( |
|
|
|
|
|
|
|
|
cls.mass = cls._create_mass_editing( |
|
|
|
|
|
cls.partner_model, cls.fields_model, 'Partner') |
|
|
|
|
|
cls.copy_mass = cls.mass.copy() |
|
|
|
|
|
cls.user = cls._create_user() |
|
|
|
|
|
cls.res_partner_title_model = cls.env['res.partner.title'] |
|
|
|
|
|
cls.partner_title = cls._create_partner_title() |
|
|
|
|
|
cls.partner_title_model = model_obj.search( |
|
|
[('model', '=', 'res.partner.title')]) |
|
|
[('model', '=', 'res.partner.title')]) |
|
|
self.fields_partner_title_model = self.env['ir.model.fields'].search( |
|
|
|
|
|
[('model_id', '=', self.partner_title_model.id), |
|
|
|
|
|
|
|
|
cls.fields_partner_title_model = cls.env['ir.model.fields'].search( |
|
|
|
|
|
[('model_id', '=', cls.partner_title_model.id), |
|
|
('name', 'in', ['abbreviation'])]) |
|
|
('name', 'in', ['abbreviation'])]) |
|
|
self.mass_partner_title = self._create_mass_editing( |
|
|
|
|
|
self.partner_title_model, |
|
|
|
|
|
self.fields_partner_title_model, |
|
|
|
|
|
|
|
|
cls.mass_partner_title = cls._create_mass_editing( |
|
|
|
|
|
cls.partner_title_model, cls.fields_partner_title_model, |
|
|
'Partner Title') |
|
|
'Partner Title') |
|
|
|
|
|
|
|
|
def _create_partner(self): |
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
def _create_partner(cls): |
|
|
"""Create a Partner.""" |
|
|
"""Create a Partner.""" |
|
|
categ_ids = self.env['res.partner.category'].search([]).ids |
|
|
|
|
|
return self.res_partner_model.create({ |
|
|
|
|
|
|
|
|
categ_ids = cls.env['res.partner.category'].search([]).ids |
|
|
|
|
|
return cls.res_partner_model.create({ |
|
|
'name': 'Test Partner', |
|
|
'name': 'Test Partner', |
|
|
'email': 'example@yourcompany.com', |
|
|
'email': 'example@yourcompany.com', |
|
|
'phone': 123456, |
|
|
'phone': 123456, |
|
@ -60,12 +61,13 @@ class TestMassEditing(common.TransactionCase): |
|
|
'notify_email': 'always' |
|
|
'notify_email': 'always' |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
def _create_partner_title(self): |
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
def _create_partner_title(cls): |
|
|
"""Create a Partner Title.""" |
|
|
"""Create a Partner Title.""" |
|
|
# Loads German to work with translations |
|
|
# Loads German to work with translations |
|
|
self.lang_model.load_lang('de_DE') |
|
|
|
|
|
|
|
|
cls.lang_model.load_lang('de_DE') |
|
|
# Creating the title in English |
|
|
# Creating the title in English |
|
|
partner_title = self.res_partner_title_model.create({ |
|
|
|
|
|
|
|
|
partner_title = cls.res_partner_title_model.create({ |
|
|
'name': 'Ambassador', |
|
|
'name': 'Ambassador', |
|
|
'shortcut': 'Amb.', |
|
|
'shortcut': 'Amb.', |
|
|
}) |
|
|
}) |
|
@ -76,17 +78,19 @@ class TestMassEditing(common.TransactionCase): |
|
|
'shortcut': 'Bots.'}) |
|
|
'shortcut': 'Bots.'}) |
|
|
return partner_title |
|
|
return partner_title |
|
|
|
|
|
|
|
|
def _create_user(self): |
|
|
|
|
|
return self.env['res.users'].create({ |
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
def _create_user(cls): |
|
|
|
|
|
return cls.env['res.users'].create({ |
|
|
'name': 'Test User', |
|
|
'name': 'Test User', |
|
|
'login': 'test_login', |
|
|
'login': 'test_login', |
|
|
'email': 'test@test.com', |
|
|
'email': 'test@test.com', |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
def _create_mass_editing(self, model, fields, model_name): |
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
def _create_mass_editing(cls, model, fields, model_name): |
|
|
"""Create a Mass Editing with Partner as model and |
|
|
"""Create a Mass Editing with Partner as model and |
|
|
email field of partner.""" |
|
|
email field of partner.""" |
|
|
mass = self.mass_object_model.create({ |
|
|
|
|
|
|
|
|
mass = cls.mass_object_model.create({ |
|
|
'name': 'Mass Editing for {0}'.format(model_name), |
|
|
'name': 'Mass Editing for {0}'.format(model_name), |
|
|
'model_id': model.id, |
|
|
'model_id': model.id, |
|
|
'field_ids': [(6, 0, fields.ids)] |
|
|
'field_ids': [(6, 0, fields.ids)] |
|
|