mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-24 17:38:42 -06:00
[MERGE] merge various improvement, look in the log of the branch merge for more information
This commit is contained in:
commit
469971843b
@ -32,10 +32,11 @@
|
|||||||
""",
|
""",
|
||||||
'author': 'Akretion',
|
'author': 'Akretion',
|
||||||
'website': 'http://www.akretion.com/',
|
'website': 'http://www.akretion.com/',
|
||||||
'depends': ['file_document','fetchmail_server'],
|
'depends': ['file_document', 'fetchmail'],
|
||||||
'init_xml': [],
|
'init_xml': [],
|
||||||
'update_xml': [
|
'update_xml': [
|
||||||
"fetchmail_view.xml",
|
"fetchmail_view.xml",
|
||||||
|
"file_document_view.xml",
|
||||||
],
|
],
|
||||||
'demo_xml': [],
|
'demo_xml': [],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
|
@ -35,14 +35,23 @@ class fetchmail_server(orm.Model):
|
|||||||
_columns = {
|
_columns = {
|
||||||
'file_type': fields.selection(_get_file_type, 'File Type',
|
'file_type': fields.selection(_get_file_type, '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', 'Company', required=True),#Why this field do not exist by default?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_defaults = {
|
||||||
|
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'fetchmail.server', context=c),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_context_for_server(self, cr, uid, server_id, context=None):
|
def get_context_for_server(self, cr, uid, server_id, context=None):
|
||||||
if context is None:
|
if context is None:
|
||||||
ctx = {}
|
ctx = {}
|
||||||
else:
|
else:
|
||||||
ctx = context.copy()
|
ctx = context.copy()
|
||||||
ctx['default_file_document_vals'] = {}
|
ctx['default_file_document_vals'] = {}
|
||||||
|
server = self.browse(cr, uid, server_id, context=context)
|
||||||
|
ctx['default_company_id'] = server.company_id.id
|
||||||
|
ctx['default_fetchmail_server_id'] = server_id
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
def fetch_mail(self, cr, uid, ids, context=None):
|
def fetch_mail(self, cr, uid, ids, context=None):
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
<data>
|
<data>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="view_email_server_form">
|
<record model="ir.ui.view" id="view_email_server_form">
|
||||||
<field name="name">fetchmail.server.form</field>
|
|
||||||
<field name="model">fetchmail.server</field>
|
<field name="model">fetchmail.server</field>
|
||||||
<field name="inherit_id" ref="fetchmail.view_email_server_form"/>
|
<field name="inherit_id" ref="fetchmail.view_email_server_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
|
<field name="date" position="after">
|
||||||
|
<field name="company_id" widget="selection" groups="base.group_multi_company"/>
|
||||||
|
</field>
|
||||||
<field name="object_id" position="after">
|
<field name="object_id" position="after">
|
||||||
<field name="file_type"/> <!-- TODO attrs="{'invisible': [('object_id','!=', 'file.document')]}"/>-->
|
<field name="file_type"/> <!-- TODO attrs="{'invisible': [('object_id','!=', 'file.document')]}"/>-->
|
||||||
</field>
|
</field>
|
||||||
|
@ -26,6 +26,48 @@ from openerp.osv import fields, orm
|
|||||||
class file_document(orm.Model):
|
class file_document(orm.Model):
|
||||||
_inherit = "file.document"
|
_inherit = "file.document"
|
||||||
|
|
||||||
|
_columns = {
|
||||||
|
'fetchmail_server_id': fields.many2one('fetchmail.server', 'Email Server'),
|
||||||
|
}
|
||||||
|
|
||||||
|
_sql_constraints = [
|
||||||
|
('fecthmail_server_ext_id_uniq', 'unique(fetchmail_server_id, ext_id)',
|
||||||
|
'The combination of Email Server and External id must be unique !'),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def message_process(self, cr, uid, model, message, custom_values=None,
|
||||||
|
save_original=False, strip_attachments=False,
|
||||||
|
thread_id=None, context=None):
|
||||||
|
if context is None:
|
||||||
|
context = {}
|
||||||
|
context['no_post'] = True
|
||||||
|
return super(file_document, 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',
|
||||||
|
subtype=None, parent_id=False, attachments=None, context=None,
|
||||||
|
content_subtype='html', **kwargs):
|
||||||
|
if context.get('no_post'):
|
||||||
|
return None
|
||||||
|
return super(file_document, self).message_post(cr, uid, thread_id,
|
||||||
|
body=body,
|
||||||
|
subject=subject,
|
||||||
|
type='notification',
|
||||||
|
subtype=subtype,
|
||||||
|
parent_id=parent_id,
|
||||||
|
attachments=attachments,
|
||||||
|
context=context,
|
||||||
|
content_subtype=content_subtype,
|
||||||
|
**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _prepare_data_for_file_document(self, cr, uid, msg, context=None):
|
def _prepare_data_for_file_document(self, cr, uid, msg, context=None):
|
||||||
"""Method to prepare the data for creating a file document.
|
"""Method to prepare the data for creating a file document.
|
||||||
:param msg: a dictionnary with the email data
|
:param msg: a dictionnary with the email data
|
||||||
@ -41,9 +83,14 @@ class file_document(orm.Model):
|
|||||||
res = self._prepare_data_for_file_document(cr, uid, msg, context=context)
|
res = self._prepare_data_for_file_document(cr, uid, msg, context=context)
|
||||||
if res:
|
if res:
|
||||||
for vals in res:
|
for vals in res:
|
||||||
if context.get('default_file_document_vals'):
|
default = context.get('default_file_document_vals')
|
||||||
vals.update(context['default_file_document_vals'])
|
if default:
|
||||||
|
for key in default:
|
||||||
|
if not key in vals:
|
||||||
|
vals[key] = default[key]
|
||||||
created_ids.append(self.create(cr, uid, vals, context=context))
|
created_ids.append(self.create(cr, uid, vals, context=context))
|
||||||
print "create message", vals['date']
|
cr.commit()
|
||||||
return created_ids
|
context['created_ids'] = created_ids
|
||||||
|
return created_ids[0]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
21
file_document_view.xml
Normal file
21
file_document_view.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<!-- SEARCH -->
|
||||||
|
<record id="file_document_view_search" model="ir.ui.view">
|
||||||
|
<field name="name">file.document.search</field>
|
||||||
|
<field name="model">file.document</field>
|
||||||
|
<field name="type">search</field>
|
||||||
|
<field name="inherit_id" ref="file_document.file_document_view_search"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="ext_id" position="after">
|
||||||
|
<field name="fetchmail_server_id"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user