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

Update Celery module to version 17.0 and improve visibility condition… #46

Open
wants to merge 2 commits into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion celery/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'name': 'Celery',
'summary': 'Celery (Distributed Task Queue)',
'category': 'Extra Tools',
'version': '0.27',
'version': '17.0',
'description': """Execute Odoo methods by Celery worker tasks.""",
'author': 'Nova Code',
'website': 'https://www.novacode.nl',
Expand Down
8 changes: 5 additions & 3 deletions celery/models/celery_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def apply_call_task():
# Closure uses several variables from enslosing scope.
db_registry = model_registry.Registry.new(dbname)
call_task = False
with api.Environment.manage(), db_registry.cursor() as cr:
with db_registry.cursor() as cr:
env = api.Environment(cr, user_id, {})
Task = env['celery.task']
try:
Expand All @@ -299,7 +299,8 @@ def apply_call_task():
call_task = False

if call_task:
with api.Environment.manage(), db_registry.cursor() as cr:

with db_registry.cursor() as cr:
env = api.Environment(cr, user_id, {})
Task = env['celery.task']
if not scheduled_date: # if the task is not scheduled for a later time
Expand All @@ -308,7 +309,8 @@ def apply_call_task():
if transaction_strategy == 'immediate':
apply_call_task()
else:
self._cr.after('commit', apply_call_task)
self._cr.commit()
apply_call_task()

def _transaction_strategies(self):
transaction_strategies = self.env['celery.task.setting']._fields['transaction_strategy'].selection
Expand Down
20 changes: 15 additions & 5 deletions celery/views/celery_task_setting_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) -->
<tree string="Queues" editable="bottom">
<field name="sequence" widget="handle"/>
<field name="queue_id" options="{'no_create': True}"/>
<field name="queue_max_pending_tasks" attrs="{'invisible': [('parent.use_first_empty_queue', '!=', True)]}"/>
<field name="queue_max_pending_tasks"
invisible="not parent.use_first_empty_queue"
/>
</tree>
</field>
</group>
Expand All @@ -63,10 +65,14 @@ License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) -->
<group colspan="2">
<p>A task seems Stuck when it's still in state <strong>Started</strong> or <strong>Retry</strong>, after certain elapsed seconds.</p>
</group>
<group attrs="{'invisible': [('handle_stuck', '=', False)]}">
<group
invisible="not parent.handle_stuck"
>
<field name="stuck_after_seconds"/>
</group>
<group attrs="{'invisible': [('handle_stuck', '=', False)]}">
<group
invisible="not parent.handle_stuck"
>
<field name="handle_stuck_by_cron"/>
</group>
</group>
Expand All @@ -77,7 +83,9 @@ License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) -->
<field name="schedule"/>
</group>
<group colspan="4" cols="4">
<group attrs="{'invisible': [('schedule', '=', False)]}" colspan="2" cols="2" string="Days:">
<group
invisible="not parent.schedule"
colspan="2" cols="2" string="Days:">
<field name="schedule_mondays" string="Monday"/>
<field name="schedule_tuesdays" string="Tuesday"/>
<field name="schedule_wednesdays" string="Wednesday"/>
Expand All @@ -86,7 +94,9 @@ License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) -->
<field name="schedule_saturdays" string="Saturday"/>
<field name="schedule_sundays" string="Sunday"/>
</group>
<group attrs="{'invisible': [('schedule', '=', False)]}" colspan="2" cols="2" string="Hours:">
<group
invisible="not parent.schedule"
colspan="2" cols="2" string="Hours:">
<field name="schedule_hours_from" string="From" widget="float_time"/>
<field name="schedule_hours_to" string="To" widget="float_time"/>
</group>
Expand Down
27 changes: 18 additions & 9 deletions celery/views/celery_task_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) -->
<header>
<button
name="action_open_related_record" type="object" string="Related"
attrs="{'invisible': [('res_model', '=', False)]}"/>
invisible="not res_model"
/>
<field name="state" widget="statusbar" statusbar_visible="PENDING,STARTED,SCHEDULED,RETRY,RETRYING,FAILURE,SUCCESS"/>
</header>
<sheet>
Expand All @@ -44,7 +45,7 @@ License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) -->
<field name="res_model" invisible="1"/>
<group>
<field name="uuid"/>
<field name="ref" attrs="{'invisible': [('ref', '=', False)]}"/>
<field name="ref" invisible="not ref"/>
</group>
<group>
<group>
Expand All @@ -61,18 +62,23 @@ License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) -->
</group>
</group>
<notebook>
<page name="result" string="Result" attrs="{'invisible': [('result', '=', False)]}">
<page name="result" string="Result" invisible="not result">
<group>
<field nolabel="1" name="result"/>
</group>
</page>
<page name="exc_info" string="Retry/Failure Information"
attrs="{'invisible': ['|', ('state', 'not in', ['RETRY', 'RETRYING', 'FAILURE']), ('result', '!=', False)]}">
<div attrs="{'invisible': [('exc_info', '!=', False)]}">
invisible="state not in ['RETRY', 'RETRYING', 'FAILURE'] or not result"
>
<div
invisible="not exc_info"
>
<p>No Retry/Failure has occurred on this moment.</p>
<p>Update the information by refreshing this view (button above).</p>
</div>
<group attrs="{'invisible': [('exc_info', '=', False)]}">
<group
invisible="not exc_info"
>
<code>
<field nolabel="1" name="exc_info"/>
</code>
Expand All @@ -87,16 +93,19 @@ License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) -->
</group>
<group name="retry_countdown_settings"
string="Retry Countdown settings"
attrs="{'invisible': [('retry', '=', False), ('countdown', '=', False)]}">
invisible="not retry and not countdown"
>
<field name="retry_countdown_setting" string="Retry Countdown"/>
<field
name="retry_countdown_add_seconds"
string="Seconnds (+ countdown)"
attrs="{'invisible': ['|', ('retry', '=', False), ('retry_countdown_setting', '!=', 'ADD_SECS')]}"/>
invisible="not retry_countdown_setting != 'ADD_SECS' or not retry"
/>
<field
name="retry_countdown_multiply_retries_seconds"
string="Seconds (* retries)"
attrs="{'invisible': ['|', ('retry', '=', False), ('retry_countdown_setting', '!=', 'MUL_RETRIES_SECS')]}"/>
invisible="not retry_countdown_setting != 'MUL_RETRIES_SECS' or not retry"
/>
</group>
<group name="retry_broker_connection" string="Retry Broker Connection">
<field name="interval_start"/>
Expand Down
37 changes: 19 additions & 18 deletions celery/views/res_config_settings_views.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright Nova Code (http://www.novacode.nl)
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) -->

<!-- Copyright Nova Code (http://www.novacode.nl) License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) -->
<odoo>
<record id="res_config_settings_celery_form" model="ir.ui.view">
<field name="name">res.config.settings.celery.view.form</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[hasclass('settings')]" position="inside">
<div class="app_settings_block" data-string="Celery" data-key="celery">
<h2>Celery</h2>
<div class="row mt16 o_settings_container">
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_left_pane"/>
<div class="o_setting_right_pane">
<div class="row">
<label for="celery_base_url" class="col-md-4"/>
<field name="celery_base_url"/>
</div>
</div>
</div>
</div>
</div>
<xpath expr="//form" position="inside">
<app data-string="Celery" name="hsn_hpp_settings" string="Celery">
<block title="Settings for Celery" id="celery_settings_block">
<setting id="celery_settings_base_url">
<group>
<field name="celery_base_url"/>
</group>
</setting>
</block>
</app>
</xpath>
</field>
</record>

<record id="action_config_settings_celery" model="ir.actions.act_window">
<field name="name">Settings</field>
<field name="res_model">res.config.settings</field>
<field name="view_mode">form</field>
<field name="target">inline</field>
<field name="context">{'module': 'celery', 'bin_size': False}</field>
</record>
</odoo>