- better view layout

- match pattern filename to download
- empty list as default domain
pull/2632/head
Giovanni 2020-01-14 10:44:09 +01:00 committed by Florian da Costa
parent f022064a47
commit 945e3f5279
4 changed files with 55 additions and 64 deletions

View File

@ -1,12 +1,12 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api
import odoo
from odoo import tools
from base64 import b64encode
import os
import datetime
import logging
import os
from fnmatch import fnmatch
import odoo
from odoo import api, fields, models, tools
_logger = logging.getLogger(__name__)
@ -112,10 +112,10 @@ class StorageTask(models.Model):
return render_result
@api.model
def run_task_scheduler(self, domain=None):
if domain is None:
domain = []
domain.append([('method_type', '=', 'import')])
def run_task_scheduler(self, domain=list()):
if ('method_type', '=', 'import') not in domain:
domain.append([('method_type', '=', 'import')])
tasks = self.env['storage.backend'].search(domain)
for task in tasks:
task.run_import()
@ -127,7 +127,7 @@ class StorageTask(models.Model):
backend = self.backend_id
all_filenames = backend._list(relative_path=self.filepath)
if self.filename:
filenames = [x for x in all_filenames if self.filename in x]
filenames = [x for x in all_filenames if fnmatch(x, self.filename)]
for file_name in filenames:
with api.Environment.manage():
with odoo.registry(
@ -160,7 +160,7 @@ class StorageTask(models.Model):
backend._add_b64_data(new_full_path, datas)
if self.after_import in (
'delete', 'rename', 'move', 'move_rename'
):
):
backend._delete(full_absolute_path)
except Exception as e:
new_env.cr.rollback()

View File

@ -1,26 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_attachment_improved_form" model="ir.ui.view">
<field name="model">ir.attachment.metadata</field>
<field name="inherit_id" ref="base_attachment_queue.view_attachment_improved_form" />
<field name="arch" type="xml">
<field name="url" position="after">
<field name="task_id" attrs="{'required': [('file_type', '=', 'export')]}"/>
<field name="storage_backend_id"/>
</field>
<record id="view_attachment_improved_form" model="ir.ui.view">
<field name="model">ir.attachment.metadata</field>
<field name="inherit_id" ref="base_attachment_queue.view_attachment_improved_form" />
<field name="arch" type="xml">
<field name="url" position="after">
<field name="task_id" attrs="{'required': [('file_type', '=', 'export')]}"/>
<field name="storage_backend_id"/>
</field>
</record>
</field>
</record>
<record id="view_external_attachment_tree" model="ir.ui.view">
<field name="model">ir.attachment.metadata</field>
<field name="inherit_id" ref="base_attachment_queue.view_external_attachment_tree" />
<field name="arch" type="xml">
<field name="file_type" position="after">
<field name="task_id"/>
<field name="storage_backend_id"/>
</field>
<record id="view_external_attachment_tree" model="ir.ui.view">
<field name="model">ir.attachment.metadata</field>
<field name="inherit_id" ref="base_attachment_queue.view_external_attachment_tree" />
<field name="arch" type="xml">
<field name="file_type" position="after">
<field name="task_id"/>
<field name="storage_backend_id"/>
</field>
</record>
</field>
</record>
</odoo>

View File

@ -3,15 +3,16 @@
<record id="view_storage_backend_form" model="ir.ui.view">
<field name="model">storage.backend</field>
<field name="inherit_id" ref="storage_backend.storage_backend_view_form" />
<field name="priority" eval="250"/>
<field name="inherit_id" ref="storage_backend.storage_backend_view_form" />
<field name="priority" eval="250"/>
<field name="arch" type="xml">
<form>
<xpath expr="/form/sheet" position="inside">
<separator string="Tasks"/>
<field name="task_ids" nolabel="1"/>
</xpath>
</form>
<xpath expr="//group[@name='config']" position="after">
<notebook>
<page string="Tasks">
<field name="task_ids"/>
</page>
</notebook>
</xpath>
</field>
</record>

View File

@ -1,40 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_task_form" model="ir.ui.view">
<field name="model">storage.backend.task</field>
<field name="arch" type="xml">
<form>
<header>
<button name="run_import" type="object" string="Run" icon="gtk-execute" attrs="{'invisible': [('method_type', '!=', 'import')]}"/>
<button name="run_import" type="object" string="Run" class="oe_read_only" icon="fa-play-circle" attrs="{'invisible': ['|', ('method_type', '!=', 'import'), ('enabled','=', False)]}"/>
</header>
<sheet>
<field name="method_type" invisible="1"/>
<group col="4">
<div class="oe_title" style="width: 390px;" colspan="4">
<label class="oe_edit_only" for="name" string="Name"/>
<h1><field name="name" class="oe_inline"/></h1>
</div>
<field name="method_type" colspan="2"/>
<span colspan="2"/>
<field name="filename" colspan="4" attrs="{'invisible':[('method_type','!=','import')]}"/>
<field name="filepath" colspan="4" />
<div class="oe_title" style="width: 390px;" colspan="4">
<label class="oe_edit_only" for="name" string="Name"/>
<h2>
<field name="name" class="oe_inline"/>
</h2>
</div>
<group>
<field name="enabled"/>
<field name="method_type"/>
<field name="filename" attrs="{'invisible':[('method_type','!=','import')]}"/>
<field name="filepath"/>
</group>
<group col="6">
<group name="action" string="Action">
<field name="after_import" attrs="{'invisible':[('method_type','!=','import')]}"/>
<group col="4" colspan="4" >
<field name="move_path" colspan="4"
attrs="{'invisible':['|', '&amp;',
('after_import','!=','move'),
('after_import','!=','move_rename'),
('method_type','!=','import')]}"/>
<field name="new_name" colspan="4"
attrs="{'invisible': ['|', '&amp;',
('after_import','!=','rename'),
('after_import','!=','move_rename'),
('method_type','!=','import')]}"/>
</group>
<field name="active" colspan="2"/>
<field name="move_path" colspan="4" attrs="{'invisible':['|', '&amp;', ('after_import','!=','move'), ('after_import','!=','move_rename'), ('method_type','!=','import')]}"/>
<field name="new_name" colspan="4" attrs="{'invisible': ['|', '&amp;', ('after_import','!=','rename'), ('after_import','!=','move_rename'), ('method_type','!=','import')]}"/>
</group>
<group string="Data importation setting">
<field name="file_type" attrs="{'invisible':[('method_type','!=','import')]}"/>
@ -47,10 +37,10 @@
<record id="view_task_tree" model="ir.ui.view">
<field name="model">storage.backend.task</field>
<field name="arch" type="xml">
<tree string="Tasks" >
<tree string="Tasks">
<field name="name" select="1"/>
<field name="method_type"/>
<field name="filename"/>
<field name="filename"/>
<field name="filepath"/>
</tree>
</field>