Skip to content

Commit af0239f

Browse files
committed
[ADD] server_action_wizard
1 parent 5c975d7 commit af0239f

File tree

13 files changed

+739
-0
lines changed

13 files changed

+739
-0
lines changed

server_action_wizard/README.rst

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
====================
2+
Server Action Wizard
3+
====================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:39e5179921affeec3b5f675d82829cc3b2c20aa260f586ecb3b82f086c17039a
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
18+
:alt: License: LGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--ux-lightgray.png?logo=github
20+
:target: https://github.com/OCA/server-ux/tree/18.0/server_action_wizard
21+
:alt: OCA/server-ux
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/server-ux-18-0/server-ux-18-0-server_action_wizard
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-ux&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module provides a wizard interface to execute Odoo server actions
32+
with user-defined input parameters.
33+
34+
Key features:
35+
36+
- Select a target model and a corresponding tavailable server action.
37+
- Enter parameters to be passed to the server action via \`context\`:
38+
39+
- Start Date
40+
- End Date
41+
- Text 1
42+
- Text 2
43+
44+
Server action Python code can then access these via:
45+
46+
.. code:: python
47+
48+
date_start = env.context.get('param_date_start')
49+
date_end = env.context.get('param_date_end')
50+
text_1 = env.context.get('param_1')
51+
text_2 = env.context.get('param_2')
52+
53+
**Table of contents**
54+
55+
.. contents::
56+
:local:
57+
58+
Usage
59+
=====
60+
61+
1. Go to *Technical > Actions > Server Action Wizard*.
62+
2. Choose the model you want to run a server action on.
63+
3. Select the appropriate server action (filtered by model).
64+
4. Fill in any optional parameters.
65+
5. Click **Run** to execute the server action with the provided context.
66+
67+
Bug Tracker
68+
===========
69+
70+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-ux/issues>`_.
71+
In case of trouble, please check there if your issue has already been reported.
72+
If you spotted it first, help us to smash it by providing a detailed and welcomed
73+
`feedback <https://github.com/OCA/server-ux/issues/new?body=module:%20server_action_wizard%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
74+
75+
Do not contact contributors directly about support or help with technical issues.
76+
77+
Credits
78+
=======
79+
80+
Authors
81+
-------
82+
83+
* Open Source Integrators
84+
85+
Maintainers
86+
-----------
87+
88+
This module is maintained by the OCA.
89+
90+
.. image:: https://odoo-community.org/logo.png
91+
:alt: Odoo Community Association
92+
:target: https://odoo-community.org
93+
94+
OCA, or the Odoo Community Association, is a nonprofit organization whose
95+
mission is to support the collaborative development of Odoo features and
96+
promote its widespread use.
97+
98+
.. |maintainer-dreispt| image:: https://github.com/dreispt.png?size=40px
99+
:target: https://github.com/dreispt
100+
:alt: dreispt
101+
102+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
103+
104+
|maintainer-dreispt|
105+
106+
This module is part of the `OCA/server-ux <https://github.com/OCA/server-ux/tree/18.0/server_action_wizard>`_ project on GitHub.
107+
108+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

server_action_wizard/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "Server Action Wizard",
3+
"summary": "Run server actions with parameters via a wizard",
4+
"version": "18.0.1.0.0",
5+
"author": "Open Source Integrators, Odoo Community Association (OCA)",
6+
"license": "LGPL-3",
7+
"maintainers": ["dreispt"],
8+
"website": "https://github.com/OCA/server-ux",
9+
"category": "Tools",
10+
"depends": ["base"],
11+
"data": [
12+
"security/ir.model.access.csv",
13+
"views/ir_actions_server_views.xml",
14+
"views/server_action_wizard_views.xml",
15+
],
16+
"installable": True,
17+
"application": False,
18+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import ir_actions_server
2+
from . import server_action_wizard
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from odoo import fields, models
2+
3+
4+
class IrActionsServer(models.Model):
5+
_inherit = "ir.actions.server"
6+
7+
can_run_from_wizard = fields.Boolean("Can run from wizard")
8+
param_label_date_start = fields.Char()
9+
param_label_date_end = fields.Char()
10+
param_label_1 = fields.Char()
11+
param_label_2 = fields.Char()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from odoo import fields, models
2+
3+
4+
class ServerActionWizard(models.TransientModel):
5+
_name = "server.action.wizard"
6+
_description = "Wizard to run server actions with parameters"
7+
8+
model_id = fields.Many2one("ir.model", string="Model", required=True)
9+
server_action_id = fields.Many2one(
10+
"ir.actions.server",
11+
string="Server Action",
12+
required=True,
13+
domain="[('model_id', '=', model_id), ('can_run_from_wizard', '=', True)]",
14+
)
15+
16+
param_date_start = fields.Char("Date Start")
17+
param_date_end = fields.Char("Date End")
18+
param_1 = fields.Char("Parameter 1")
19+
param_2 = fields.Char("Parameter 2")
20+
21+
def run_server_action(self):
22+
ctx_add = {
23+
"param_1": self.param_1,
24+
"param_2": self.param_2,
25+
"param_3": self.param_3,
26+
"param_4": self.param_4,
27+
}
28+
self.server_action_id.with_context(**ctx_add).run()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
A wizard interface to execute Odoo server actions allowing for user input parameters.
2+
3+
Server Actions can be by end users to manually run automation scripts,
4+
but the only parameter available is the records select to run the action.
5+
6+
This feature allows to present a dialog to the users,
7+
where they can enter parameters to be passed to the server action.
8+
9+
These parameters are made available to be used
10+
in the server action Python code through the environment context.
11+
12+
A usage example could be to copy a Customer Invoice for a period of months.
13+
14+
Key features:
15+
16+
- Select a target model and a corresponding available server action.
17+
- Enter parameters to be passed to the server action via \`context\`:
18+
- Start Date
19+
- End Date
20+
- Text 1
21+
- Text 2
22+
23+
Server action Python code can then access these via:
24+
25+
``` python
26+
date_start = env.context.get('param_date_start')
27+
date_end = env.context.get('param_date_end')
28+
text_1 = env.context.get('param_1')
29+
text_2 = env.context.get('param_2')
30+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
1. Go to *Technical \> Actions \> Server Action Wizard*.
2+
2. Choose the model you want to run a server action on.
3+
3. Select the appropriate server action (filtered by model).
4+
4. Fill in any optional parameters.
5+
5. Click **Run** to execute the server action with the provided
6+
context.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2+
access_server_action_wizard,access_server_action_wizard,model_server_action_wizard,base.group_system,1,1,1,1

0 commit comments

Comments
 (0)