diff options
| author | Thibault Delavallée <tde@odoo.com> | 2020-02-28 13:42:30 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-04-03 12:59:28 +0000 |
| commit | bea9bc3d6c51bfc1c4eaad2378caba83b7a5142a (patch) | |
| tree | f96cc8c9b1cdce0823e95078b0b46cbea534ecc7 /addons/phone_validation | |
| parent | 9b76c6b7f1eec4057289de90d62b8a7a266b0aac (diff) | |
[IMP] mail, mass_mailing, phone, survey: call toggle_active / action_(un)archive when possible
Purpose of this commit is to call toggle_active or archive / unarchive methods
instead of manually writing on active field. Indeed this allows to trigger
business code related to archive / unarchive which is normally located
in toggle_archive (called by action_archive and action_unarchive).
Task ID 2170708
Community PR odoo/odoo#46563
Diffstat (limited to 'addons/phone_validation')
| -rw-r--r-- | addons/phone_validation/models/phone_blacklist.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/phone_validation/models/phone_blacklist.py b/addons/phone_validation/models/phone_blacklist.py index 3fd1c4b4bcc..17f59b7fc38 100644 --- a/addons/phone_validation/models/phone_blacklist.py +++ b/addons/phone_validation/models/phone_blacklist.py @@ -89,7 +89,7 @@ class PhoneBlackList(models.Model): records = self.env["phone.blacklist"].with_context(active_test=False).search([('number', 'in', numbers)]) todo = [n for n in numbers if n not in records.mapped('number')] if records: - records.write({'active': True}) + records.action_unarchive() if todo: records += self.create([{'number': n} for n in todo]) return records @@ -112,7 +112,7 @@ class PhoneBlackList(models.Model): records = self.env["phone.blacklist"].with_context(active_test=False).search([('number', 'in', numbers)]) todo = [n for n in numbers if n not in records.mapped('number')] if records: - records.write({'active': False}) + records.action_archive() if todo: records += self.create([{'number': n, 'active': False} for n in todo]) return records |
