Browse Source

- fix check_duplicated_files in view

- log info on run completed
12.0-mig-module_prototyper_last
Giovanni 5 years ago
committed by David Beal
parent
commit
1ee9ba7f6a
  1. 3
      attachment_synchronize/models/task.py
  2. 1
      attachment_synchronize/views/task_view.xml

3
attachment_synchronize/models/task.py

@ -131,6 +131,7 @@ class StorageTask(models.Model):
relative_path=self.filepath, pattern=self.pattern)
if self.check_duplicated_files:
filenames = self._file_to_import(filenames)
total_import = 0
for file_name in filenames:
with api.Environment.manage():
with odoo.registry(
@ -165,11 +166,13 @@ class StorageTask(models.Model):
'delete', 'rename', 'move', 'move_rename'
):
backend._delete(full_absolute_path)
total_import += 1
except Exception as e:
new_env.cr.rollback()
raise e
else:
new_env.cr.commit()
_logger.info('Run import complete! Imported {0} files'.format(total_import))
def _file_to_import(self, filenames):
imported = self.attachment_ids.filtered(lambda r: r.name in filenames).mapped('name')

1
attachment_synchronize/views/task_view.xml

@ -20,6 +20,7 @@
<field name="method_type"/>
<field name="pattern" attrs="{'invisible':[('method_type','!=','import')]}"/>
<field name="filepath"/>
<field name="check_duplicated_files" />
</group>
<group name="action" string="Action">
<field name="after_import" attrs="{'invisible':[('method_type','!=','import')]}"/>

Loading…
Cancel
Save