Browse Source

[IMP] task run_export + onchange link method_type and file_type if export

12.0-mig-module_prototyper_last
clementmbr 4 years ago
committed by David Beal
parent
commit
61276cff04
  1. 8
      attachment_synchronize/models/attachment_queue.py
  2. 19
      attachment_synchronize/models/attachment_synchronize_task.py
  3. 13
      attachment_synchronize/views/attachment_synchronize_task_views.xml

8
attachment_synchronize/models/attachment_queue.py

@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import os
from odoo import models, fields
from odoo import api, models, fields
class AttachmentQueue(models.Model):
@ -30,3 +30,9 @@ class AttachmentQueue(models.Model):
if self.task_id.emails:
res = self.task_id.emails
return res
@api.onchange("task_id")
def onchange_task_id(self):
for attachment in self:
if attachment.task_id.method_type == "export":
attachment.file_type = "export"

19
attachment_synchronize/models/attachment_synchronize_task.py

@ -100,9 +100,11 @@ class AttachmentSynchronizeTask(models.Model):
"when excuting the files linked to this task",
)
def toogle_enabled(self):
@api.onchange("method_type")
def onchange_method_type(self):
for task in self:
task.enabled = not task.enabled
if task.method_type == "export":
task.file_type = "export"
def _prepare_attachment_vals(self, data, filename):
self.ensure_one()
@ -196,17 +198,14 @@ class AttachmentSynchronizeTask(models.Model):
)
return list(set(filenames) - set(imported))
def run_export(self):
for task in self:
task.attachment_ids.filtered(lambda a: a.state == "pending").run()
def button_toogle_enabled(self):
for rec in self:
rec.enabled = not rec.enabled
def button_duplicate_record(self):
self.ensure_one()
record = self.copy({"enabled": False})
return {
"type": "ir.actions.act_window",
"res_model": record.backend_id._name,
"target": "current",
"view_mode": "form",
"res_id": record.backend_id.id,
}
self.copy({"enabled": False})

13
attachment_synchronize/views/attachment_synchronize_task_views.xml

@ -7,9 +7,12 @@
<header>
<button name="run_import" type="object" string="Run Import" class="oe_read_only oe_highlight" icon="fa-play-circle" attrs="{'invisible': ['|', ('method_type', '!=', 'import'), ('enabled','=', False)]}"/>
</header>
<header>
<button name="run_export" type="object" string="Run Export" class="oe_read_only oe_highlight" icon="fa-play-circle" attrs="{'invisible': ['|', ('method_type', '!=', 'export'), ('enabled','=', False)]}"/>
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button name="toogle_enabled" type="object" class="oe_stat_button" icon="fa-check-square">
<button name="button_toogle_enabled" type="object" class="oe_stat_button" icon="fa-check-square">
<field
name="enabled"
widget="boolean_button"
@ -31,11 +34,10 @@
</div>
<div class="col-12 col-lg-6">
<group>
<!-- <field name="enabled"/> -->
<field name="method_type"/>
<field name="pattern" attrs="{'invisible':[('method_type','!=','import')]}"/>
<field name="backend_id"/>
<field name="filepath"/>
<field name="pattern" attrs="{'invisible':[('method_type','!=','import')]}"/>
</group>
<group name="action" string="Action">
<field name="emails"/>
@ -43,11 +45,14 @@
<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="file_type" />
<group string="Data importation settings" attrs="{'invisible':[('method_type','!=','import')]}" >
<field name="file_type" />
<field name="check_duplicated_files" />
</group>
</div>
<group string="Attachments" attrs="{'invisible':[('method_type','!=','export')]}">
<field name="attachment_ids" domain="[('task_id', '=', id)]" nolabel="1" />
</group>
</sheet>
</form>
</field>

Loading…
Cancel
Save