mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-26 18:38:41 -06:00
Flake8 done
This commit is contained in:
parent
0932cb1e73
commit
f40146b110
@ -27,44 +27,24 @@ import base64
|
|||||||
class IrAttachmentMetadata(models.Model):
|
class IrAttachmentMetadata(models.Model):
|
||||||
_inherit = "ir.attachment.metadata"
|
_inherit = "ir.attachment.metadata"
|
||||||
|
|
||||||
fetchmail_server_id = fields.Many2one('fetchmail.server', string='Email Server')
|
fetchmail_server_id = fields.Many2one('fetchmail.server',
|
||||||
|
string='Email Server')
|
||||||
|
|
||||||
def message_process(self, cr, uid, model, message, custom_values=None,
|
def message_process(self, cr, uid, model, message, custom_values=None,
|
||||||
save_original=False, strip_attachments=False,
|
save_original=False, strip_attachments=False,
|
||||||
thread_id=None, context=None):
|
thread_id=None, context=None):
|
||||||
print "message process"
|
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
context['no_post'] = True
|
context['no_post'] = True
|
||||||
return True
|
return True
|
||||||
# return super(IrAttachmentMetadata, self).message_process(self, cr, uid,
|
|
||||||
# model,
|
|
||||||
# message,
|
|
||||||
# custom_values=custom_values,
|
|
||||||
# save_original=save_original,
|
|
||||||
# strip_attachments=strip_attachments,
|
|
||||||
# thread_id=thread_id,
|
|
||||||
# context=context
|
|
||||||
# )
|
|
||||||
|
|
||||||
def message_post(self, cr, uid, thread_id, body='', subject=None, type='notification',
|
def message_post(self, cr, uid, thread_id, body='', subject=None,
|
||||||
subtype=None, parent_id=False, attachments=None,
|
type='notification', subtype=None, parent_id=False,
|
||||||
content_subtype='html', context=None, **kwargs):
|
attachments=None, content_subtype='html', context=None,
|
||||||
print "message post"
|
**kwargs):
|
||||||
if context.get('no_post'):
|
if context.get('no_post'):
|
||||||
return None
|
return None
|
||||||
return True
|
return True
|
||||||
# return super(IrAttachmentMetadata, self).message_post(cr, uid, thread_id,
|
|
||||||
# body=body,
|
|
||||||
# subject=subject,
|
|
||||||
# type='notification',
|
|
||||||
# subtype=subtype,
|
|
||||||
# parent_id=parent_id,
|
|
||||||
# attachments=attachments,
|
|
||||||
# content_subtype=content_subtype,
|
|
||||||
# context=context,
|
|
||||||
# **kwargs)
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _get_attachment_metadata_data(self, condition, msg, att):
|
def _get_attachment_metadata_data(self, condition, msg, att):
|
||||||
@ -83,21 +63,23 @@ class IrAttachmentMetadata(models.Model):
|
|||||||
@api.model
|
@api.model
|
||||||
def prepare_data_from_basic_condition(self, condition, msg):
|
def prepare_data_from_basic_condition(self, condition, msg):
|
||||||
vals = {}
|
vals = {}
|
||||||
if condition.from_email in msg['from'] and condition.mail_subject in msg['subject']:
|
if (condition.from_email in msg['from']
|
||||||
|
and condition.mail_subject in msg['subject']):
|
||||||
for att in msg['attachments']:
|
for att in msg['attachments']:
|
||||||
if condition.file_extension in att[0]:
|
if condition.file_extension in att[0]:
|
||||||
vals = self._get_attachment_metadata_data(condition, msg, att)
|
vals = self._get_attachment_metadata_data(condition,
|
||||||
|
msg, att)
|
||||||
break
|
break
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _prepare_data_for_attachment_metadata(self, msg):
|
def _prepare_data_for_attachment_metadata(self, msg):
|
||||||
"""Method to prepare the data for creating a attachment metadata.
|
"""Method to prepare the data for creating a attachment metadata.
|
||||||
:param msg: a dictionnary with the email data
|
:param msg: a dictionnary with the email data
|
||||||
:type: dict
|
:type: dict
|
||||||
|
|
||||||
:return: a list of dictionnary that containt the attachment metadata data
|
:return: a list of dictionnary that containt
|
||||||
|
the attachment metadata data
|
||||||
:rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
res = []
|
res = []
|
||||||
@ -124,11 +106,10 @@ class IrAttachmentMetadata(models.Model):
|
|||||||
default = self._context.get('default_attachment_metadata_vals')
|
default = self._context.get('default_attachment_metadata_vals')
|
||||||
if default:
|
if default:
|
||||||
for key in default:
|
for key in default:
|
||||||
if not key in vals:
|
if key not in vals:
|
||||||
vals[key] = default[key]
|
vals[key] = default[key]
|
||||||
created_ids.append(self.create(vals))
|
created_ids.append(self.create(vals))
|
||||||
self._cr.commit()
|
self._cr.commit()
|
||||||
#self._context['created_ids'] = created_ids
|
|
||||||
return created_ids[0].id
|
return created_ids[0].id
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -35,15 +35,19 @@ class fetchmail_server(models.Model):
|
|||||||
return self.get_file_type()
|
return self.get_file_type()
|
||||||
|
|
||||||
def company_default_get(self):
|
def company_default_get(self):
|
||||||
company_id = self.env['res.company']._company_default_get('fetchmail.server')
|
company_id = (self.env['res.company'].
|
||||||
|
_company_default_get('fetchmail.server'))
|
||||||
return self.env['res.company'].browse(company_id)
|
return self.env['res.company'].browse(company_id)
|
||||||
|
|
||||||
file_type = fields.Selection(selection='_get_file_type',
|
file_type = fields.Selection(
|
||||||
|
selection='_get_file_type',
|
||||||
help='The file type will show some special option')
|
help='The file type will show some special option')
|
||||||
company_id = fields.Many2one('res.company', string='Company',
|
company_id = fields.Many2one(
|
||||||
# required=True,
|
'res.company',
|
||||||
|
string='Company',
|
||||||
|
required=True,
|
||||||
default=company_default_get
|
default=company_default_get
|
||||||
) #Why this field do not exist by default?
|
) # Why this field do not exist by default?
|
||||||
attachment_metadata_condition_ids = fields.One2many(
|
attachment_metadata_condition_ids = fields.One2many(
|
||||||
'ir.attachment.metadata.condition', 'server_id', string='Attachment')
|
'ir.attachment.metadata.condition', 'server_id', string='Attachment')
|
||||||
|
|
||||||
@ -61,6 +65,5 @@ class fetchmail_server(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def fetch_mail(self):
|
def fetch_mail(self):
|
||||||
for server in self:
|
for server in self:
|
||||||
ctx = server.get_context_for_server()
|
|
||||||
super(fetchmail_server, server).fetch_mail()
|
super(fetchmail_server, server).fetch_mail()
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user