Browse Source

- better view layout

- match pattern filename to download
- empty list as default domain
12.0-mig-module_prototyper_last
Giovanni 5 years ago
committed by David Beal
parent
commit
8c8a866216
  1. 18
      attachment_synchronize/models/task.py
  2. 11
      attachment_synchronize/views/storage_backend_view.xml
  3. 34
      attachment_synchronize/views/task_view.xml

18
attachment_synchronize/models/task.py

@ -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):
if domain is None:
domain = []
def run_task_scheduler(self, domain=list()):
if ('method_type', '=', 'import') not in 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(

11
attachment_synchronize/views/storage_backend_view.xml

@ -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="/form/sheet" position="inside">
<separator string="Tasks"/>
<field name="task_ids" nolabel="1"/>
<xpath expr="//group[@name='config']" position="after">
<notebook>
<page string="Tasks">
<field name="task_ids"/>
</page>
</notebook>
</xpath> </xpath>
</form>
</field> </field>
</record> </record>

34
attachment_synchronize/views/task_view.xml

@ -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"/>
<span colspan="2"/>
<field name="filename" colspan="4" attrs="{'invisible':[('method_type','!=','import')]}"/>
<field name="filepath" colspan="4" />
<group>
<field name="enabled"/>
<field name="method_type"/>
<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':['|', '&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>
<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…
Cancel
Save