mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-25 18:08:42 -06:00
Cron working, refactoring relation task/attachment wip
This commit is contained in:
parent
0fbb3be2cd
commit
b39b495d8e
@ -38,6 +38,7 @@
|
||||
'menu.xml',
|
||||
'location_view.xml',
|
||||
'task_view.xml',
|
||||
'cron.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'application': True,
|
||||
|
@ -33,3 +33,7 @@ class IrAttachment(models.Model):
|
||||
('done', 'Done'),
|
||||
], readonly=True, required=True, default='pending')
|
||||
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="state"/>
|
||||
<field name="state_message"/>
|
||||
<field name="task_id"/>
|
||||
<field name="location_id"/>
|
||||
</field>
|
||||
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@ -21,8 +22,8 @@
|
||||
<tree string="Attachments" >
|
||||
<field name="name"/>
|
||||
<field name="datas_fname"/>
|
||||
<field name="res_model"/>
|
||||
<field name="res_id"/>
|
||||
<field name="task_id"/>
|
||||
<field name="location_id"/>
|
||||
<field name="type"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="create_uid"/>
|
||||
@ -32,6 +33,40 @@
|
||||
</field>
|
||||
</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">
|
||||
<field name="name">Attachments</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
@ -39,10 +74,12 @@
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">kanban,tree,form</field>
|
||||
<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 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_id" ref="mail.view_document_file_kanban"/>
|
||||
<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()
|
||||
filepath = fields.Char()
|
||||
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):
|
||||
res = []
|
||||
@ -45,7 +46,14 @@ class Task(models.Model):
|
||||
res.append(cls_info)
|
||||
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):
|
||||
for cls in itersubclasses(AbstractTask):
|
||||
if cls._synchronize_type and \
|
||||
|
@ -13,7 +13,7 @@
|
||||
<field name="location_id" colspan="4"/>
|
||||
<field name="filename" 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"/>
|
||||
</group>
|
||||
</sheet>
|
||||
|
Binary file not shown.
@ -42,7 +42,7 @@ class FtpTask(AbstractTask):
|
||||
self.port = config.get('port', '')
|
||||
self.allow_dir_creation = config.get('allow_dir_creation', '')
|
||||
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.delete_file = config.get('delete_file', False)
|
||||
self.attachment_id = config.get('attachment_id', False)
|
||||
@ -138,6 +138,7 @@ class FtpExportTask(FtpTask):
|
||||
fileobj.write(filedata)
|
||||
_logger.info('wrote %s, size %d', target_name, len(filedata))
|
||||
self.attachment_id.state = 'done'
|
||||
self.attachment_id.state_message = ''
|
||||
except FTPIOError:
|
||||
self.attachment_id.state = 'failed'
|
||||
self.attachment_id.state_message = (
|
||||
|
Loading…
Reference in New Issue
Block a user