[FIX] {test_,}mail: don't copy alias_id for models using optional alias
Summary ------- Currently, duplicating a journal results in the new journal's mail alias name overwriting the original's. Steps to reproduce ------------------ * install `account_accountant` * duplicate the "Vendor Bills" journal => you should see that the alias name of the new journal overwrites the alias of the original journal. Cause ----- When duplicating a journal, the new journal inherits the alias of the original. Because of this, a specific code segment intended to generate missing aliases for new sale/purchase journals, inadvertently modifies the name of the alias. opw-3597349 closes odoo/odoo#143771 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -18,7 +18,7 @@ class AliasMixinOptional(models.AbstractModel):
|
||||
_description = 'Email Aliases Mixin (light)'
|
||||
ALIAS_WRITEABLE_FIELDS = ['alias_domain_id', 'alias_name', 'alias_contact', 'alias_defaults', 'alias_bounced_content']
|
||||
|
||||
alias_id = fields.Many2one('mail.alias', string='Alias', ondelete="restrict", required=False)
|
||||
alias_id = fields.Many2one('mail.alias', string='Alias', ondelete="restrict", required=False, copy=False)
|
||||
alias_name = fields.Char(related='alias_id.alias_name', readonly=False)
|
||||
alias_domain_id = fields.Many2one(
|
||||
'mail.alias.domain', string='Alias Domain',
|
||||
|
||||
@@ -807,6 +807,18 @@ class TestMailAliasMixin(TestMailAliasCommon):
|
||||
record_copy2 = record_copy.copy()
|
||||
self.assertEqual(record_copy2.alias_bounced_content, new_content)
|
||||
|
||||
@users('employee')
|
||||
def test_copy_optional_alias_model(self):
|
||||
""" Do not propagate alias_id to duplicate record as it could lead to
|
||||
overwriting alias_name of old record. """
|
||||
record = self.env['mail.test.alias.optional'].create({
|
||||
'name': 'Test Optional Alias Record',
|
||||
'alias_name': 'test.optional.alias.record',
|
||||
})
|
||||
self.assertTrue(record.alias_id)
|
||||
record_copy = record.copy()
|
||||
self.assertFalse(record_copy.alias_id)
|
||||
|
||||
@users('erp_manager')
|
||||
def test_multi_company_setup(self):
|
||||
""" Test company impact on alias domains when creating or updating
|
||||
|
||||
Reference in New Issue
Block a user