Browse Source

[IMP] task_id readonly if method_type import

12.0-mig-module_prototyper_last
clementmbr 5 years ago
committed by David Beal
parent
commit
a3f4e52a37
  1. 7
      attachment_synchronize/demo/attachment_synchronize_task_demo.xml
  2. 1
      attachment_synchronize/models/attachment_queue.py
  3. 12
      attachment_synchronize/views/attachment_queue_views.xml

7
attachment_synchronize/demo/attachment_synchronize_task_demo.xml

@ -17,4 +17,11 @@
<field name="emails">foo@example.org,bar@example.org</field>
</record>
<record id="attachment_queue_imported_demo" model="attachment.queue">
<field name="datas">bWlncmF0aW9uIHRlc3Q=</field>
<field name="datas_fname">attachment_queue_imported_demo.doc</field>
<field name="name">attachment_queue_imported_demo.doc</field>
<field name="task_id" ref="import_from_filestore" />
</record>
</odoo>

1
attachment_synchronize/models/attachment_queue.py

@ -9,6 +9,7 @@ class AttachmentQueue(models.Model):
_inherit = "attachment.queue"
task_id = fields.Many2one("attachment.synchronize.task", string="Task")
method_type = fields.Selection(related="task_id.method_type")
storage_backend_id = fields.Many2one(
"storage.backend",
string="Storage Backend",

12
attachment_synchronize/views/attachment_queue_views.xml

@ -5,10 +5,16 @@
<field name="model">attachment.queue</field>
<field name="inherit_id" ref="attachment_queue.view_attachment_queue_form" />
<field name="arch" type="xml">
<field name="url" position="after">
<field name="task_id" attrs="{'required': [('file_type', '=', 'export')]}"/>
<!-- Add Related Task and Backend -->
<xpath expr="//field[@name='url']" position="after">
<field name="method_type" invisible="1"/>
<field
name="task_id"
domain="[('method_type', '!=', 'import')]"
attrs="{'required': [('file_type', '=', 'export')], 'readonly': [('method_type', '=', 'import')]}"
/>
<field name="storage_backend_id"/>
</field>
</xpath>
</field>
</record>

Loading…
Cancel
Save