[FIX] mass_mailing: Fix crash when trying to schedule a new compaing from the calendar view
To reproduce the error: 1. Open Email marketing 2. Go to the calendar view 3. Click on a cell Explanation: The function 'default_get' defines an argument named 'field' that conflicts with the 'field' variable imported from the default 'odoo' package. When two identifiers conflict, Python will use the variable defined in the closest enclosing scope. When the 'default_get' function accesses the 'Datetime' attribute of 'field', the function will raise an exception as the identifier 'field' will refer to the argument of the function and the property 'Datetime' will not defined on that variable. To solve the issue, we will rename the argument of the function 'default_get' to 'fields_list' so that it will no longer conflict with the imported variable 'fields'. Links: Task id: 2581357 closes odoo/odoo#72857 X-original-commit: a9f6f708d40d0ecafb4a903eb9ff810a6c959416 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -35,20 +35,20 @@ class MassMailing(models.Model):
|
||||
_rec_name = "subject"
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields):
|
||||
vals = super(MassMailing, self).default_get(fields)
|
||||
def default_get(self, fields_list):
|
||||
vals = super(MassMailing, self).default_get(fields_list)
|
||||
|
||||
# field sent by the calendar view when clicking on a date block
|
||||
# we use it to setup the scheduled date of the created mailing.mailing
|
||||
default_calendar_date = self.env.context.get('default_calendar_date')
|
||||
if default_calendar_date and ('schedule_type' in fields and 'schedule_date' in fields) \
|
||||
if default_calendar_date and ('schedule_type' in fields_list and 'schedule_date' in fields_list) \
|
||||
and fields.Datetime.from_string(default_calendar_date) > fields.Datetime.now():
|
||||
vals.update({
|
||||
'schedule_type': 'scheduled',
|
||||
'schedule_date': default_calendar_date
|
||||
})
|
||||
|
||||
if 'contact_list_ids' in fields and not vals.get('contact_list_ids') and vals.get('mailing_model_id'):
|
||||
if 'contact_list_ids' in fields_list and not vals.get('contact_list_ids') and vals.get('mailing_model_id'):
|
||||
if vals.get('mailing_model_id') == self.env['ir.model']._get('mailing.list').id:
|
||||
mailing_list = self.env['mailing.list'].search([], limit=2)
|
||||
if len(mailing_list) == 1:
|
||||
|
||||
Reference in New Issue
Block a user