mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-26 02:18:40 -06:00
Cron working, refactoring relation task/attachment wip
This commit is contained in:
parent
0fbb3be2cd
commit
b39b495d8e
@ -38,6 +38,7 @@
|
|||||||
'menu.xml',
|
'menu.xml',
|
||||||
'location_view.xml',
|
'location_view.xml',
|
||||||
'task_view.xml',
|
'task_view.xml',
|
||||||
|
'cron.xml',
|
||||||
],
|
],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'application': True,
|
'application': True,
|
||||||
|
@ -33,3 +33,7 @@ class IrAttachment(models.Model):
|
|||||||
('done', 'Done'),
|
('done', 'Done'),
|
||||||
], readonly=True, required=True, default='pending')
|
], readonly=True, required=True, default='pending')
|
||||||
state_message = fields.Text()
|
state_message = fields.Text()
|
||||||
|
task_id = fields.Many2one('external.file.task', string='Task')
|
||||||
|
location_id = fields.Many2one('external.file.location', string='Location',
|
||||||
|
related='task_id.location_id', store=True
|
||||||
|
)
|
||||||
|
@ -10,8 +10,9 @@
|
|||||||
<field name="sync_date"/>
|
<field name="sync_date"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<field name="state_message"/>
|
<field name="state_message"/>
|
||||||
|
<field name="task_id"/>
|
||||||
|
<field name="location_id"/>
|
||||||
</field>
|
</field>
|
||||||
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@ -21,8 +22,8 @@
|
|||||||
<tree string="Attachments" >
|
<tree string="Attachments" >
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="datas_fname"/>
|
<field name="datas_fname"/>
|
||||||
<field name="res_model"/>
|
<field name="task_id"/>
|
||||||
<field name="res_id"/>
|
<field name="location_id"/>
|
||||||
<field name="type"/>
|
<field name="type"/>
|
||||||
<field name="company_id" groups="base.group_multi_company"/>
|
<field name="company_id" groups="base.group_multi_company"/>
|
||||||
<field name="create_uid"/>
|
<field name="create_uid"/>
|
||||||
@ -32,6 +33,40 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="view_external_attachment_search" model="ir.ui.view">
|
||||||
|
<field name="model">ir.attachment</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<search string="Attachments">
|
||||||
|
<field name="name" filter_domain="['|', ('name','ilike',self), ('datas_fname','ilike',self)]" string="Attachment"/>
|
||||||
|
<field name="create_date"/>
|
||||||
|
<filter icon="terp-stage"
|
||||||
|
string="URL"
|
||||||
|
domain="[('type','=','url')]"/>
|
||||||
|
<filter icon="terp-stock_align_left_24"
|
||||||
|
string="Binary"
|
||||||
|
domain="[('type','=','binary')]"/>
|
||||||
|
<separator/>
|
||||||
|
<filter name="my_documents_filter"
|
||||||
|
string="My Document(s)"
|
||||||
|
icon="terp-personal"
|
||||||
|
domain="[('create_uid','=',uid)]"
|
||||||
|
help="Filter on my documents"/>
|
||||||
|
<field name="create_uid"/>
|
||||||
|
<field name="type"/>
|
||||||
|
<filter string="Pending" domain="[('state', '=', 'pending')]"/>
|
||||||
|
<filter string="Failed" domain="[('state', '=', 'failed')]"/>
|
||||||
|
<filter string="Done" domain="[('state', '=', 'done')]"/>
|
||||||
|
<group expand="0" string="Group By">
|
||||||
|
<filter string="Owner" icon="terp-personal" domain="[]" context="{'group_by':'create_uid'}"/>
|
||||||
|
<filter string="Type" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'type'}" groups="base.group_no_one"/>
|
||||||
|
<filter string="Company" icon="terp-gtk-home" domain="[]" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
|
||||||
|
<filter string="Creation Month" icon="terp-go-month" domain="[]" context="{'group_by':'create_date'}"/>
|
||||||
|
<filter string="State" domain="[]" context="{'group_by': 'state'}"/>
|
||||||
|
</group>
|
||||||
|
</search>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record id="action_attachment" model="ir.actions.act_window">
|
<record id="action_attachment" model="ir.actions.act_window">
|
||||||
<field name="name">Attachments</field>
|
<field name="name">Attachments</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
@ -39,10 +74,12 @@
|
|||||||
<field name="view_type">form</field>
|
<field name="view_type">form</field>
|
||||||
<field name="view_mode">kanban,tree,form</field>
|
<field name="view_mode">kanban,tree,form</field>
|
||||||
<field name="view_id" eval="False"/>
|
<field name="view_id" eval="False"/>
|
||||||
|
<field name="domain">[('task_id', '!=', False)]</field>
|
||||||
|
<field name="search_view_id" ref="view_external_attachment_search"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="ir_attachment_view1" model="ir.actions.act_window.view">
|
<record id="ir_attachment_view1" model="ir.actions.act_window.view">
|
||||||
<field eval="1" name="sequence"/>
|
<field eval="20" name="sequence"/>
|
||||||
<field name="view_mode">kanban</field>
|
<field name="view_mode">kanban</field>
|
||||||
<field name="view_id" ref="mail.view_document_file_kanban"/>
|
<field name="view_id" ref="mail.view_document_file_kanban"/>
|
||||||
<field name="act_window_id" ref="action_attachment"/>
|
<field name="act_window_id" ref="action_attachment"/>
|
||||||
|
18
external_file_location/cron.xml
Normal file
18
external_file_location/cron.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<record model="ir.cron" id="cronjob_run_exchange_tasks">
|
||||||
|
<field name='name'>Run file exchange tasks</field>
|
||||||
|
<field name='interval_number'>30</field>
|
||||||
|
<field name='interval_type'>minutes</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="active">True</field>
|
||||||
|
<field name="doall" eval="False" />
|
||||||
|
<field name="model">external.file.task</field>
|
||||||
|
<field name="function">_run</field>
|
||||||
|
<field name="args">([])</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
@ -34,7 +34,8 @@ class Task(models.Model):
|
|||||||
filename = fields.Char()
|
filename = fields.Char()
|
||||||
filepath = fields.Char()
|
filepath = fields.Char()
|
||||||
location_id = fields.Many2one('external.file.location', string='Location')
|
location_id = fields.Many2one('external.file.location', string='Location')
|
||||||
attachment_id = fields.Many2one('ir.attachment', string='Attachment')
|
attachment_ids = fields.One2many('ir.attachment', 'task_id',
|
||||||
|
string='Attachment')
|
||||||
|
|
||||||
def _get_method(self):
|
def _get_method(self):
|
||||||
res = []
|
res = []
|
||||||
@ -45,7 +46,14 @@ class Task(models.Model):
|
|||||||
res.append(cls_info)
|
res.append(cls_info)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.multi
|
@api.model
|
||||||
|
def _run(self, domain=None):
|
||||||
|
if not domain:
|
||||||
|
domain = []
|
||||||
|
tasks = self.env['external.file.task'].search(domain)
|
||||||
|
tasks.run()
|
||||||
|
|
||||||
|
@api.one
|
||||||
def run(self):
|
def run(self):
|
||||||
for cls in itersubclasses(AbstractTask):
|
for cls in itersubclasses(AbstractTask):
|
||||||
if cls._synchronize_type and \
|
if cls._synchronize_type and \
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<field name="location_id" colspan="4"/>
|
<field name="location_id" colspan="4"/>
|
||||||
<field name="filename" colspan="4"/>
|
<field name="filename" colspan="4"/>
|
||||||
<field name="filepath" colspan="4"/>
|
<field name="filepath" colspan="4"/>
|
||||||
<field name="attachment_id" colspan="4"/>
|
<field name="attachment_ids" colspan="4"/>
|
||||||
<button name="run" type="object" string="Run"/>
|
<button name="run" type="object" string="Run"/>
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
|
Binary file not shown.
@ -42,7 +42,7 @@ class FtpTask(AbstractTask):
|
|||||||
self.port = config.get('port', '')
|
self.port = config.get('port', '')
|
||||||
self.allow_dir_creation = config.get('allow_dir_creation', '')
|
self.allow_dir_creation = config.get('allow_dir_creation', '')
|
||||||
self.file_name = config.get('file_name', '')
|
self.file_name = config.get('file_name', '')
|
||||||
self.path = config.get('path', '')
|
self.path = config.get('path', './')
|
||||||
self.move_path = config.get('move_path', '')
|
self.move_path = config.get('move_path', '')
|
||||||
self.delete_file = config.get('delete_file', False)
|
self.delete_file = config.get('delete_file', False)
|
||||||
self.attachment_id = config.get('attachment_id', False)
|
self.attachment_id = config.get('attachment_id', False)
|
||||||
@ -138,6 +138,7 @@ class FtpExportTask(FtpTask):
|
|||||||
fileobj.write(filedata)
|
fileobj.write(filedata)
|
||||||
_logger.info('wrote %s, size %d', target_name, len(filedata))
|
_logger.info('wrote %s, size %d', target_name, len(filedata))
|
||||||
self.attachment_id.state = 'done'
|
self.attachment_id.state = 'done'
|
||||||
|
self.attachment_id.state_message = ''
|
||||||
except FTPIOError:
|
except FTPIOError:
|
||||||
self.attachment_id.state = 'failed'
|
self.attachment_id.state = 'failed'
|
||||||
self.attachment_id.state_message = (
|
self.attachment_id.state_message = (
|
||||||
|
Loading…
Reference in New Issue
Block a user