Browse Source

[FIX] UserError: ('Record cannot be modified right now: This cron task is currently being executed and may not be modified Please try again in a few minutes', None)

pull/37/head
Ivan Yelizariev 9 years ago
parent
commit
e6e728c57e
  1. 2
      mailgun/data/cron.xml
  2. 6
      mailgun/models.py

2
mailgun/data/cron.xml

@ -5,7 +5,7 @@
<field name="name">Mailgun - domain verification</field>
<field name='interval_number'>10</field>
<field name='interval_type'>minutes</field>
<field name="numbercall">-1</field>
<field name="numbercall">288</field>
<field name="active">True</field>
<field name="model">ir.config_parameter</field>
<field name="function">mailgun_verify</field>

6
mailgun/models.py

@ -27,11 +27,13 @@ class IrConfigParameter(models.Model):
@api.model
def mailgun_verify(self):
verified = self.get_param('mailgun.verified')
if verified:
return
api_key = self.get_param('mailgun.apikey')
mail_domain = self.get_param('mail.catchall.domain')
cron_record = self.env.ref('mailgun.mailgun_domain_verification')
if api_key and mail_domain:
url = "https://api.mailgun.net/v3/domains/%s/verify" % mail_domain
res = requests.put(url, auth=("api", api_key))
if res.status_code == 200 and simplejson.loads(res.text)["domain"]["state"] == "active":
cron_record.write({'active': False})
self.set_param('mailgun.verified', '1')
Loading…
Cancel
Save