From ffe1d4047da181f97fafe2a69f64e6f283fbeb0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Voet?= Date: Fri, 13 Dec 2019 11:48:36 +0000 Subject: [REF] mass_mailing: move from onchange / default to stored editable computed fields PURPOSE Try to move from onchange / default_get to stored editable computed fields. Normally behavior should be the same (computed or set by user), with support in create / write + onchange without additional code. SPECIFICATIONS Update classic fields with onchange to stored editable computed fields. It means their value will come either from manual user input, either computed based on triggers. Purpose is to remove all onchange and default_get when possible. Clean fields definition inconsistencies, like default / required on computed fields. Indeed computed fields should always have a value, maybe coming from user input. They should not have default / required that are attributes for classic fields. LINKS Task ID 2088577 PR #41877 Enterprise PR odoo/enterprise#7278 --- addons/mass_mailing_event/models/mailing_mailing.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'addons/mass_mailing_event') diff --git a/addons/mass_mailing_event/models/mailing_mailing.py b/addons/mass_mailing_event/models/mailing_mailing.py index cf70517af1c..ac454e5877d 100644 --- a/addons/mass_mailing_event/models/mailing_mailing.py +++ b/addons/mass_mailing_event/models/mailing_mailing.py @@ -4,10 +4,11 @@ from odoo import models, api class MassMailingCampaign(models.Model): _inherit = "mailing.mailing" - @api.onchange('mailing_model_real', 'contact_list_ids') - def _onchange_model_and_list(self): + @api.depends('mailing_model_real', 'contact_list_ids') + def _compute_mailing_domain(self): # TDE FIXME: whuuut ? - result = super(MassMailingCampaign, self)._onchange_model_and_list() - if self.mailing_model_name == 'event.registration' and self.mailing_domain == '[]': - self.mailing_domain = self.env.context.get('default_mailing_domain', '[]') + result = super(MassMailingCampaign, self)._compute_mailing_domain() + for mailing in self: + if mailing.mailing_model_name == 'event.registration' and mailing.mailing_domain == '[]': + mailing.mailing_domain = self.env.context.get('default_mailing_domain', '[]') return result -- cgit v1.2.3