- better view layout
- match pattern filename to download - empty list as default domainpull/2632/head
parent
f022064a47
commit
945e3f5279
|
@ -1,12 +1,12 @@
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# 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 datetime
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
from fnmatch import fnmatch
|
||||||
|
|
||||||
|
import odoo
|
||||||
|
from odoo import api, fields, models, tools
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -112,10 +112,10 @@ class StorageTask(models.Model):
|
||||||
return render_result
|
return render_result
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def run_task_scheduler(self, domain=None):
|
def run_task_scheduler(self, domain=list()):
|
||||||
if domain is None:
|
if ('method_type', '=', 'import') not in domain:
|
||||||
domain = []
|
|
||||||
domain.append([('method_type', '=', 'import')])
|
domain.append([('method_type', '=', 'import')])
|
||||||
|
|
||||||
tasks = self.env['storage.backend'].search(domain)
|
tasks = self.env['storage.backend'].search(domain)
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
task.run_import()
|
task.run_import()
|
||||||
|
@ -127,7 +127,7 @@ class StorageTask(models.Model):
|
||||||
backend = self.backend_id
|
backend = self.backend_id
|
||||||
all_filenames = backend._list(relative_path=self.filepath)
|
all_filenames = backend._list(relative_path=self.filepath)
|
||||||
if self.filename:
|
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:
|
for file_name in filenames:
|
||||||
with api.Environment.manage():
|
with api.Environment.manage():
|
||||||
with odoo.registry(
|
with odoo.registry(
|
||||||
|
|
|
@ -6,12 +6,13 @@
|
||||||
<field name="inherit_id" ref="storage_backend.storage_backend_view_form" />
|
<field name="inherit_id" ref="storage_backend.storage_backend_view_form" />
|
||||||
<field name="priority" eval="250"/>
|
<field name="priority" eval="250"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form>
|
<xpath expr="//group[@name='config']" position="after">
|
||||||
<xpath expr="/form/sheet" position="inside">
|
<notebook>
|
||||||
<separator string="Tasks"/>
|
<page string="Tasks">
|
||||||
<field name="task_ids" nolabel="1"/>
|
<field name="task_ids"/>
|
||||||
|
</page>
|
||||||
|
</notebook>
|
||||||
</xpath>
|
</xpath>
|
||||||
</form>
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
|
@ -1,40 +1,30 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record id="view_task_form" model="ir.ui.view">
|
<record id="view_task_form" model="ir.ui.view">
|
||||||
<field name="model">storage.backend.task</field>
|
<field name="model">storage.backend.task</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form>
|
<form>
|
||||||
<header>
|
<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>
|
</header>
|
||||||
<sheet>
|
<sheet>
|
||||||
<field name="method_type" invisible="1"/>
|
<field name="method_type" invisible="1"/>
|
||||||
<group col="4">
|
|
||||||
<div class="oe_title" style="width: 390px;" colspan="4">
|
<div class="oe_title" style="width: 390px;" colspan="4">
|
||||||
<label class="oe_edit_only" for="name" string="Name"/>
|
<label class="oe_edit_only" for="name" string="Name"/>
|
||||||
<h1><field name="name" class="oe_inline"/></h1>
|
<h2>
|
||||||
|
<field name="name" class="oe_inline"/>
|
||||||
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
<field name="method_type" colspan="2"/>
|
<group>
|
||||||
<span colspan="2"/>
|
<field name="enabled"/>
|
||||||
<field name="filename" colspan="4" attrs="{'invisible':[('method_type','!=','import')]}"/>
|
<field name="method_type"/>
|
||||||
<field name="filepath" colspan="4" />
|
<field name="filename" attrs="{'invisible':[('method_type','!=','import')]}"/>
|
||||||
|
<field name="filepath"/>
|
||||||
</group>
|
</group>
|
||||||
<group col="6">
|
<group name="action" string="Action">
|
||||||
<field name="after_import" attrs="{'invisible':[('method_type','!=','import')]}"/>
|
<field name="after_import" attrs="{'invisible':[('method_type','!=','import')]}"/>
|
||||||
<group col="4" colspan="4" >
|
<field name="move_path" colspan="4" attrs="{'invisible':['|', '&', ('after_import','!=','move'), ('after_import','!=','move_rename'), ('method_type','!=','import')]}"/>
|
||||||
<field name="move_path" colspan="4"
|
<field name="new_name" colspan="4" attrs="{'invisible': ['|', '&', ('after_import','!=','rename'), ('after_import','!=','move_rename'), ('method_type','!=','import')]}"/>
|
||||||
attrs="{'invisible':['|', '&',
|
|
||||||
('after_import','!=','move'),
|
|
||||||
('after_import','!=','move_rename'),
|
|
||||||
('method_type','!=','import')]}"/>
|
|
||||||
<field name="new_name" colspan="4"
|
|
||||||
attrs="{'invisible': ['|', '&',
|
|
||||||
('after_import','!=','rename'),
|
|
||||||
('after_import','!=','move_rename'),
|
|
||||||
('method_type','!=','import')]}"/>
|
|
||||||
</group>
|
|
||||||
<field name="active" colspan="2"/>
|
|
||||||
</group>
|
</group>
|
||||||
<group string="Data importation setting">
|
<group string="Data importation setting">
|
||||||
<field name="file_type" attrs="{'invisible':[('method_type','!=','import')]}"/>
|
<field name="file_type" attrs="{'invisible':[('method_type','!=','import')]}"/>
|
||||||
|
|
Loading…
Reference in New Issue