-
-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5cf9205
commit b80b15d
Showing
22 changed files
with
545 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
=========== | ||
Mass Action | ||
=========== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-grap%2Fgrap--odoo--incubator-lightgray.png?logo=github | ||
:target: https://github.com/grap/grap-odoo-incubator/tree/8.0/mass_action | ||
:alt: grap/grap-odoo-incubator | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
This module provides a generic tools to have the possibility to execute | ||
custom python code for any model to a list of a given selected items. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
* Go to 'Setting / Technical / Mass Operations / Mass Actions' | ||
|
||
* Create a new item | ||
|
||
.. figure:: https://raw.githubusercontent.com/grap/grap-odoo-incubator/8.0/mass_action/static/description/mass_action_form.png | ||
|
||
* Set a name for your mass action, and another for the button that will appear | ||
on the target model for the end users | ||
|
||
* choose a model | ||
|
||
* In the Python code part, write the python code that will be executed for | ||
the selected items. The selected items are available in the ``self`` var. | ||
|
||
* Once done, click on the 'Add Sidebar button' to generate a new 'More options' | ||
button. | ||
|
||
|
||
**Extra options** | ||
|
||
* you can define a domain, to limit the action to items that match | ||
with that domain | ||
* you can define groups whose members will have access to that option | ||
|
||
Usage | ||
===== | ||
|
||
* go to the model for which you have configured a mass action | ||
|
||
* select items and click on 'More' and on the new created button | ||
|
||
.. figure:: https://raw.githubusercontent.com/grap/grap-odoo-incubator/8.0/mass_action/static/description/res_users_tree.png | ||
|
||
|
||
* the opened pop up display the number of selected items | ||
|
||
.. figure:: https://raw.githubusercontent.com/grap/grap-odoo-incubator/8.0/mass_action/static/description/wizard_form_ok.png | ||
|
||
**Result** | ||
|
||
The selected items will be processed. In that exemple, the selected users | ||
will be duplicated. | ||
|
||
|
||
.. figure:: https://raw.githubusercontent.com/grap/grap-odoo-incubator/8.0/mass_action/static/description/res_users_tree_result.png | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/grap/grap-odoo-incubator/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/grap/grap-odoo-incubator/issues/new?body=module:%20mass_action%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* GRAP | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Sylvain LE GAL (https://www.twitter.com/legalsylvain) | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
|
||
|
||
This module is part of the `grap/grap-odoo-incubator <https://github.com/grap/grap-odoo-incubator/tree/8.0/mass_action>`_ project on GitHub. | ||
|
||
|
||
You are welcome to contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
|
||
{ | ||
"name": "Mass Action", | ||
"version": "13.0.1.0.0", | ||
"author": "GRAP, " "Odoo Community Association (OCA)", | ||
"summary": "Provide the possibility to execute python code on many items" | ||
" from any models", | ||
"category": "Tools", | ||
"website": "https://github.com/OCA/server-ux", | ||
"license": "AGPL-3", | ||
"depends": ["mass_operation_abstract"], | ||
"maintainers": ["legalsylvain"], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/view_mass_action.xml", | ||
"views/view_mass_action_wizard.xml", | ||
], | ||
"demo": ["demo/mass_action.xml"], | ||
"images": [ | ||
"static/description/mass_action_form.png", | ||
"static/description/res_users_tree.png", | ||
"static/description/res_users_tree_result.png", | ||
"static/description/wizard_form_ok.png", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2019 - Today: GRAP (http://www.grap.coop) | ||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
--> | ||
<odoo> | ||
|
||
<record id="mass_action_duplicate_users" model="mass.action"> | ||
<field name="name">res.users - Mass Duplicate</field> | ||
<field name="action_name">Mass Duplicate</field> | ||
<field name="message">This operation will duplicate each selected item</field> | ||
<field name="model_id" ref="base.model_res_users"/> | ||
<field name="python_code"><![CDATA[ | ||
for user in self.sudo(): | ||
user.copy() | ||
]]></field> | ||
</record> | ||
|
||
<function model="mass.action" name="enable_mass_operation"> | ||
<value eval="[ref('mass_action_duplicate_users')]"/> | ||
</function> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * mass_action | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 13.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2019-10-03 16:30+0000\n" | ||
"PO-Revision-Date: 2019-10-03 16:30+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action__action_name | ||
msgid "Action Name" | ||
msgstr "Nom de l'action" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action__groups_id | ||
msgid "Allowed Groups" | ||
msgstr "Groupes autorisés" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action__create_uid | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action_wizard__create_uid | ||
msgid "Created by" | ||
msgstr "Créé par" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action__create_date | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action_wizard__create_date | ||
msgid "Created on" | ||
msgstr "Créé le" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action__display_name | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action_wizard__display_name | ||
msgid "Display Name" | ||
msgstr "Afficher Nom" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action__domain | ||
msgid "Domain" | ||
msgstr "Domaine" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action__id | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action_wizard__id | ||
msgid "ID" | ||
msgstr "ID" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,help:mass_action.field_mass_action__message | ||
msgid "If set, this message will be displayed in the wizard." | ||
msgstr "Si ce champ est défini, le message sera affiché dans l'assistant" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action____last_update | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action_wizard____last_update | ||
msgid "Last Modified on" | ||
msgstr "Dernière modification le" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action__write_uid | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action_wizard__write_uid | ||
msgid "Last Updated by" | ||
msgstr "Dernière mise à jour par" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action__write_date | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action_wizard__write_date | ||
msgid "Last Updated on" | ||
msgstr "Dernière mise à jour le" | ||
|
||
#. module: mass_action | ||
#: code:addons/mass_action/models/mass_action.py:0 | ||
#, python-format | ||
msgid "Mass Action (%s)" | ||
msgstr "Action de lot (%s)" | ||
|
||
#. module: mass_action | ||
#: model:ir.actions.act_window,name:mass_action.action_mass_action | ||
#: model:ir.model,name:mass_action.model_mass_action | ||
#: model:ir.ui.menu,name:mass_action.menu_mass_action | ||
msgid "Mass Actions" | ||
msgstr "Actions en lot" | ||
|
||
#. module: mass_action | ||
#: model:ir.model,name:mass_action.model_mass_action_wizard | ||
msgid "Mass Actions Wizard" | ||
msgstr "Assistant d'action en lot" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action_wizard__message | ||
msgid "Message" | ||
msgstr "Message" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action__model_id | ||
msgid "Model" | ||
msgstr "Modèle" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action__name | ||
msgid "Name" | ||
msgstr "Nom" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action_wizard__operation_description_danger | ||
msgid "Operation Description Danger" | ||
msgstr "" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action_wizard__operation_description_info | ||
msgid "Operation Description Info" | ||
msgstr "" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action_wizard__operation_description_warning | ||
msgid "Operation Description Warning" | ||
msgstr "" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action__python_code | ||
#: model_terms:ir.ui.view,arch_db:mass_action.view_mass_action_form | ||
msgid "Python Code" | ||
msgstr "Code Python" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,help:mass_action.field_mass_action__python_code | ||
msgid "" | ||
"Python code that will be evaluated\n" | ||
"\n" | ||
" * self: contains the current items that can be processed\n" | ||
" * other python function are available like 'abs', 'min', 'any'. See safe_eval() definition in odoo core to have an exhaustive list of the available functions" | ||
msgstr "Code python qui sera exécuté\n" | ||
"\n" | ||
" * self: contient les éléments courant qui seront traités\n" | ||
" * D'autres fonctions python sont disponibles comme 'abs', 'min', 'any'. Voir la définition" | ||
" de la fonction safe_eval() dans le noyaut de odoo pour avoir une liste exhaustive" | ||
" des fonctions disponibles." | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action_wizard__remaining_item_qty | ||
msgid "Remaining Item Qty" | ||
msgstr "Nombre d'éléments restants" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action_wizard__selected_item_qty | ||
msgid "Selected Item Qty" | ||
msgstr "Nombre d'éléments sélectionnés" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action__ref_ir_act_window_id | ||
msgid "Sidebar Action" | ||
msgstr "Action de la barre latérale" | ||
|
||
#. module: mass_action | ||
#: model:ir.model.fields,field_description:mass_action.field_mass_action__message | ||
msgid "message" | ||
msgstr "message" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import mass_action | ||
from . import mass_action_wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
|
||
from odoo import _, fields, models | ||
|
||
|
||
class MassAction(models.Model): | ||
_name = "mass.action" | ||
_description = "Mass Actions" | ||
_inherit = "mass.operation.mixin" | ||
|
||
# Overwrite Section | ||
_wizard_model_name = "mass.action.wizard" | ||
|
||
def _prepare_action_name(self): | ||
return _("Mass Action (%s)" % (self.name)) | ||
|
||
# Column Section | ||
python_code = fields.Text( | ||
string="Python Code", | ||
required=True, | ||
help="Python code that will be evaluated\n\n" | ||
" * self: contains the current items that can be processed\n" | ||
" * other python function are available like 'abs', 'min', 'any'." | ||
" See safe_eval() definition in odoo core to have an exhaustive list" | ||
" of the available functions", | ||
default="for item in self:\n" " pass", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
|
||
from odoo import models | ||
from odoo.tools.safe_eval import safe_eval | ||
|
||
|
||
class MassActionWizard(models.TransientModel): | ||
_name = "mass.action.wizard" | ||
_description = "Mass Actions Wizard" | ||
_inherit = "mass.operation.wizard.mixin" | ||
|
||
def _apply_operation(self, items): | ||
self.ensure_one() | ||
mass_action = self._get_mass_operation() | ||
localdict = {"self": items} | ||
safe_eval(mass_action.python_code, localdict, mode="exec", nocopy=True) | ||
return True |
Oops, something went wrong.