[FIX] base: prevent selecting unsupported "action types" in scheduled actions

Currently, scheduled Actions only work if you choose "Python Code" as
the action type ("Action To Do"). Other action types are not really
supported as they work "record-wise" (using active_ids) which makes no
sense for scheduled actions.

We should help users avoid surprises by hiding the "Action To Do" field
on scheduled actions, and default to "Python Code" implicitly.

Example steps to reproduce :

- go to scheduled actions > create a new action
- select "Execute several actions" as action to do
- add several actions to execute
- run this action

=> the sub-actions were not executed

opw-2227082

closes odoo/odoo#51242

X-original-commit: b19c7c54efceb780806d876efc65a8813e3491d1
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
jerome hanke (jhk)
2020-05-14 10:04:17 +00:00
committed by Nicolas Lempereur
parent dbd87ec464
commit ac9fb3b120
3 changed files with 12 additions and 2 deletions
+7
View File
@@ -70,6 +70,13 @@ class ir_cron(models.Model):
values['usage'] = 'ir_cron'
return super(ir_cron, self).create(values)
@api.model
def default_get(self, fields_list):
# only 'code' state is supported for cron job so set it as default
if not self._context.get('default_state'):
self = self.with_context(default_state='code')
return super(ir_cron, self).default_get(fields_list)
def method_direct_trigger(self):
self.check_access_rights('write')
for cron in self:
+1 -1
View File
@@ -256,7 +256,7 @@
help="Remove 'More' top-menu contextual action related to this action"/>
<button name="run" string="Run" type="object"
class="btn-primary"
attrs="{'invisible':[('model_id', '!=', %(base.model_ir_actions_server)s)]}"
attrs="{'invisible':['|', ('model_id', '!=', %(base.model_ir_actions_server)s), ('state', '!=', 'code')]}"
help="Run this action manually."/>
</header>
<sheet>
+4 -1
View File
@@ -8,7 +8,7 @@
<field name="inherit_id" ref="base.view_server_action_form"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='create_action']" position="replace">
<button name="method_direct_trigger" type="object" string="Run Manually" class="oe_highlight"/>
<button name="method_direct_trigger" type="object" string="Run Manually" class="oe_highlight" attrs="{'invisible': [('state', '!=', 'code')]}"/>
</xpath>
<xpath expr="//button[@name='unlink_action']" position="replace">
</xpath>
@@ -27,6 +27,9 @@
<field name="priority"/>
<field name="doall"/>
</xpath>
<field name="state" position="attributes">
<attribute name="invisible">1</attribute>
</field>
</field>
</record>