Browse Source

[REF] make menu more consistent

In normal tree view duplicate and archive can be done throught the
action menu. So we only need to show this button when this tree view
are included in a form using a o2m or m2m.
So this visibility can be activated by passing value in the context

Also make the copy consitent whatever way you do it
12.0-mig-module_prototyper_last
Sébastien BEAU 4 years ago
parent
commit
033e82510d
  1. 15
      attachment_synchronize/models/attachment_synchronize_task.py
  2. 4
      attachment_synchronize/views/attachment_synchronize_task_views.xml

15
attachment_synchronize/models/attachment_synchronize_task.py

@ -111,7 +111,6 @@ class AttachmentSynchronizeTask(models.Model):
record["count_attachment_{}".format(state)] = \ record["count_attachment_{}".format(state)] = \
len(record.attachment_ids.filtered(lambda r: r.state == state)) len(record.attachment_ids.filtered(lambda r: r.state == state))
def _prepare_attachment_vals(self, data, filename): def _prepare_attachment_vals(self, data, filename):
self.ensure_one() self.ensure_one()
vals = { vals = {
@ -219,5 +218,15 @@ class AttachmentSynchronizeTask(models.Model):
task.attachment_ids.filtered(lambda a: a.state == "pending").run() task.attachment_ids.filtered(lambda a: a.state == "pending").run()
def button_duplicate_record(self): def button_duplicate_record(self):
self.ensure_one()
self.copy({"active": False})
# due to orm limitation method call from ui should not have params
# so we need to define this method to be able to copy
# if we do not do this the context will be injected in default params
# in V14 maybe we can call copy directly
self.copy()
def copy(self, default=None):
if default is None:
default = {}
if "active" not in default:
default["active"] = False
return super().copy(default=default)

4
attachment_synchronize/views/attachment_synchronize_task_views.xml

@ -90,8 +90,8 @@
<button name="%(action_attachment_queue_related)d" type="action" icon="fa-spinner" context="{'search_default_pending': 1}"/> <button name="%(action_attachment_queue_related)d" type="action" icon="fa-spinner" context="{'search_default_pending': 1}"/>
<field name="count_attachment_done" string=" "/> <field name="count_attachment_done" string=" "/>
<button name="%(action_attachment_queue_related)d" type="action" icon="fa-thumbs-o-up" context="{'search_default_done': 1}"/> <button name="%(action_attachment_queue_related)d" type="action" icon="fa-thumbs-o-up" context="{'search_default_done': 1}"/>
<button name="button_duplicate_record" type="object" string="Copy" icon="fa-clone"/>
<button name="toggle_active" type="object" string="Active/Inactive" icon="fa-archive"/>
<button name="button_duplicate_record" type="object" string="Copy" icon="fa-clone" invisible="not context.get('show_duplicate_button')"/>
<button name="toggle_active" type="object" string="Active/Inactive" icon="fa-archive" invisible="not context.get('show_toggle_active_button')"/>
</tree> </tree>
</field> </field>
</record> </record>

Loading…
Cancel
Save