Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a button to generate the ir.values for a model #90

Closed

Conversation

JosDeGraeve
Copy link
Contributor

On the "ZPL II Labels" form, there are buttons added "Add in the 'More' menu" and
"Remove from the 'More' menu".

This way a user can easily set a print function for his label.

To add the buttons, i had to add a tag on the form, indenting all form contents, hence the strange diff you see here on github.

On the "ZPL II Lables" form, there are buttons added "Add in the 'More' menu" and
"Remove from the 'More' menu".

This way a user can easily set a print function for his label.
Copy link

@Garamotte Garamotte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !
Don't worry about the diff being badly displayed by Github, we all know how to use git for that :)

I tested on runbot, it works, but the menu's name is always "Print Label", without the label name, which seems weird with several labels on the same model: we may want to add a menu item for each label, instead of duplicated items.
I think the best is to duplicate the action instead of simply linking it (and delete it when removing the menu item).This way, you can customize the new action's name (to include the label's name in the displayed menu item) and context (to select this label by default).

Also, a small unit test would be nice.

label.menu_ir_values_id.sudo().unlink()
except Exception:
raise exceptions.UserError(
_('Deletion of the action record failed.')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the name of the label when it fails ?
It will help in case we try to remove the menu from several labels at once.

""" Remove the contextual actions created for this label. """
self.check_access_rights('write', raise_exception=True)
for label in self:
if label.menu_ir_values_id:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe merge the for and if statements using:
for label in self.filtered('menu_ir_values_id'):

@JosDeGraeve
Copy link
Contributor Author

Hello @sylvain-garancher,

As i did it now, there is an inconsistency indeed.

I propose these modifications:

  • don't link the ir_values record to the label, because it is not specific for that label
  • on the label form, move the 'add button', from the top of the sheet, next to the 'model' field.
  • If the model already has a linked ir_values record, the button is replaced with a 'remove button'.

That would fix my use case to be more consistent.

What do you think ?

@Garamotte
Copy link

This is also an option.

I proposed to add label-specific action, you propose to add a label-generic action.
Both are valid, and I have no preference about that, so do it the way you prefer :)
Or maybe someone else has an opinion ?

@github-actions
Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Oct 24, 2021
@github-actions github-actions bot closed this Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants