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

[17.0][MIG] ddmrp_cron_actions_as_job #480

Merged
merged 26 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
114f895
Add ddmrp_cron_actions_as_job
guewen Oct 29, 2020
4dd290e
[UPD] Update ddmrp_cron_actions_as_job.pot
oca-travis Feb 3, 2021
89ec6d3
[UPD] README.rst
OCA-git-bot Feb 3, 2021
29aafe4
[ADD] icon.png
OCA-git-bot Feb 3, 2021
6176242
ddmrp_cron_actions_as_job 13.0.1.1.0
OCA-git-bot Feb 3, 2021
c801432
Add queue.job.function for ddmrp_buffer._calc_adu
guewen Feb 10, 2021
5ddf50f
ddmrp_cron_actions_as_job 13.0.1.2.0
OCA-git-bot Feb 17, 2021
1d59a68
[MIG] ddmrp_cron_actions_as_job: Migration to 14.0
DavidBForgeFlow May 27, 2021
8e2ab31
[UPD] Update ddmrp_cron_actions_as_job.pot
oca-travis Jun 17, 2021
b16bc4f
[UPD] README.rst
OCA-git-bot Jun 17, 2021
d714aa9
Added translation using Weblate (Portuguese (Brazil))
marcelsavegnago Dec 26, 2021
fd7bfb6
[MIG] ddmrp_cron_actions_as_job: Migrate to 15.0
JordiBForgeFlow Feb 18, 2022
cb0564b
[FIX] tests
ChrisOForgeFlow Feb 18, 2022
0edb03a
[UPD] Update ddmrp_cron_actions_as_job.pot
Feb 28, 2022
b46a7e5
[UPD] README.rst
OCA-git-bot Feb 28, 2022
01282d2
[UPD] README.rst
OCA-git-bot Sep 3, 2023
feb3072
Update translation files
weblate Oct 9, 2023
92fb859
Added translation using Weblate (Italian)
mymage Oct 26, 2023
9cf43f5
Translated using Weblate (Italian)
mymage Oct 26, 2023
b350ac0
Added translation using Weblate (Spanish)
Ivorra78 Feb 28, 2024
f11543a
Translated using Weblate (Spanish)
Ivorra78 Feb 28, 2024
afcb330
[MIG] ddmrp_cron_actions_as_job: Migration to 16.0
LoisRForgeFlow Mar 11, 2024
29115c9
[UPD] Update ddmrp_cron_actions_as_job.pot
Mar 11, 2024
2074033
Translated using Weblate (Portuguese (Brazil))
May 21, 2024
e70374e
[IMP] ddmrp_cron_actions_as_job: pre-commit stuff
ArnauCForgeFlow Jul 18, 2024
0447580
[MIG] ddmrp_cron_actions_as_job: Migration to 17.0
ArnauCForgeFlow Jul 18, 2024
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
89 changes: 89 additions & 0 deletions ddmrp_cron_actions_as_job/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
===============================
DDMRP Buffer Calculation as job
===============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9e8a8dbcb18721e0b5be9ff3418bc0ddd61cc848b94134281a95f90cd2d690ad
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fddmrp-lightgray.png?logo=github
:target: https://github.com/OCA/ddmrp/tree/17.0/ddmrp_cron_actions_as_job
:alt: OCA/ddmrp
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/ddmrp-17-0/ddmrp-17-0-ddmrp_cron_actions_as_job
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/ddmrp&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

DDMRP Buffer calculations are now run with Queue Jobs.

When auto-update of NFP is active, each time the state of a stock move
changes, a new computation is triggered, but thanks to identity keys on
jobs, only one job at a time is generated for the same buffer.

The ``<stock.buffer>.cron_actions`` method is automatically delayed when
the context contains ``auto_delay_ddmrp_cron_actions=True``.

The scheduled action for buffers ADU computation also generates jobs
instead of recomputing all the buffers at once.

The ``<stock.buffer>._calc_adu`` method is automatically delayed when
the context contains ``auto_delay_ddmrp_calc_adu=True``.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/ddmrp/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/ddmrp/issues/new?body=module:%20ddmrp_cron_actions_as_job%0Aversion:%2017.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
-------

* Camptocamp

Contributors
------------

- Guewen Baconnier <[email protected]>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/ddmrp <https://github.com/OCA/ddmrp/tree/17.0/ddmrp_cron_actions_as_job>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions ddmrp_cron_actions_as_job/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions ddmrp_cron_actions_as_job/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2020 Camptocamp (https://www.camptocamp.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

{
"name": "DDMRP Buffer Calculation as job",
"version": "17.0.1.0.0",
"summary": "Run DDMRP Buffer Calculation as jobs",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/ddmrp",
"category": "Warehouse Management",
"depends": ["ddmrp", "queue_job"],
"data": ["data/queue_job_channel_data.xml", "data/queue_job_function_data.xml"],
"license": "LGPL-3",
"installable": True,
}
6 changes: 6 additions & 0 deletions ddmrp_cron_actions_as_job/data/queue_job_channel_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<odoo noupdate="1">
<record model="queue.job.channel" id="channel_ddmrp">
<field name="name">ddmrp</field>
<field name="parent_id" ref="queue_job.channel_root" />
</record>
</odoo>
12 changes: 12 additions & 0 deletions ddmrp_cron_actions_as_job/data/queue_job_function_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<odoo noupdate="1">
<record id="job_function_stock_buffer_cron_actions" model="queue.job.function">
<field name="model_id" ref="ddmrp.model_stock_buffer" />
<field name="method">cron_actions</field>
<field name="channel_id" ref="channel_ddmrp" />
</record>
<record id="job_function_stock_buffer_calc_adu" model="queue.job.function">
<field name="model_id" ref="ddmrp.model_stock_buffer" />
<field name="method">_calc_adu</field>
<field name="channel_id" ref="channel_ddmrp" />
</record>
</odoo>
24 changes: 24 additions & 0 deletions ddmrp_cron_actions_as_job/i18n/ddmrp_cron_actions_as_job.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * ddmrp_cron_actions_as_job
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \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: ddmrp_cron_actions_as_job
#: model:ir.model,name:ddmrp_cron_actions_as_job.model_stock_buffer
msgid "Stock Buffer"
msgstr ""

#. module: ddmrp_cron_actions_as_job
#: model:ir.model,name:ddmrp_cron_actions_as_job.model_stock_move
msgid "Stock Move"
msgstr ""
27 changes: 27 additions & 0 deletions ddmrp_cron_actions_as_job/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * ddmrp_cron_actions_as_job
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-02-28 21:33+0000\n"
"Last-Translator: Ivorra78 <[email protected]>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: ddmrp_cron_actions_as_job
#: model:ir.model,name:ddmrp_cron_actions_as_job.model_stock_buffer
msgid "Stock Buffer"
msgstr "Amortiguador de Inventario"

#. module: ddmrp_cron_actions_as_job
#: model:ir.model,name:ddmrp_cron_actions_as_job.model_stock_move
msgid "Stock Move"
msgstr "Movimiento de Existencias"
27 changes: 27 additions & 0 deletions ddmrp_cron_actions_as_job/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * ddmrp_cron_actions_as_job
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-10-28 20:10+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: ddmrp_cron_actions_as_job
#: model:ir.model,name:ddmrp_cron_actions_as_job.model_stock_buffer
msgid "Stock Buffer"
msgstr "Buffer di materiale"

#. module: ddmrp_cron_actions_as_job
#: model:ir.model,name:ddmrp_cron_actions_as_job.model_stock_move
msgid "Stock Move"
msgstr "Movimento di magazzino"
28 changes: 28 additions & 0 deletions ddmrp_cron_actions_as_job/i18n/pt_BR.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * ddmrp_cron_actions_as_job
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-05-21 03:17+0000\n"
"Last-Translator: Rodrigo Macedo <[email protected]."
"translation.odoo-community.org>\n"
"Language-Team: none\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: ddmrp_cron_actions_as_job
#: model:ir.model,name:ddmrp_cron_actions_as_job.model_stock_buffer
msgid "Stock Buffer"
msgstr "Buffer de estoque"

#. module: ddmrp_cron_actions_as_job
#: model:ir.model,name:ddmrp_cron_actions_as_job.model_stock_move
msgid "Stock Move"
msgstr "Movimento de estoque"
2 changes: 2 additions & 0 deletions ddmrp_cron_actions_as_job/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import stock_buffer
from . import stock_move
49 changes: 49 additions & 0 deletions ddmrp_cron_actions_as_job/models/stock_buffer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2020 Camptocamp (https://www.camptocamp.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from odoo import models

from odoo.addons.queue_job.job import identity_exact


class Buffer(models.Model):
_inherit = "stock.buffer"

def cron_actions_job_options(self, only_nfp=False):
return {
"identity_key": identity_exact,
"priority": 15,
"description": f"DDMRP Buffer calculation ({self.display_name})",
}

def _calc_adu_job_options(self):
return {
"identity_key": identity_exact,
"priority": 15,
"description": f"DDMRP Buffer ADU calculation ({self.display_name})",
}

def _register_hook(self):
self._patch_method(
"cron_actions",
self._patch_job_auto_delay(
"cron_actions", context_key="auto_delay_ddmrp_cron_actions"
),
)
self._patch_method(
"_calc_adu",
self._patch_job_auto_delay(
"_calc_adu", context_key="auto_delay_ddmrp_calc_adu"
),
)
return super()._register_hook()

def cron_ddmrp(self, automatic=False):
return super(
Buffer, self.with_context(auto_delay_ddmrp_cron_actions=True)
).cron_ddmrp(automatic=automatic)

def cron_ddmrp_adu(self, automatic=False):
return super(
Buffer, self.with_context(auto_delay_ddmrp_calc_adu=True)
).cron_ddmrp_adu(automatic=automatic)
13 changes: 13 additions & 0 deletions ddmrp_cron_actions_as_job/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2020 Camptocamp
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from odoo import models


class StockMove(models.Model):
_inherit = "stock.move"

def _update_ddmrp_nfp(self):
return super(

Check warning on line 11 in ddmrp_cron_actions_as_job/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

ddmrp_cron_actions_as_job/models/stock_move.py#L11

Added line #L11 was not covered by tests
StockMove, self.with_context(auto_delay_ddmrp_cron_actions=True)
)._update_ddmrp_nfp()
3 changes: 3 additions & 0 deletions ddmrp_cron_actions_as_job/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions ddmrp_cron_actions_as_job/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Guewen Baconnier \<<[email protected]>\>
14 changes: 14 additions & 0 deletions ddmrp_cron_actions_as_job/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
DDMRP Buffer calculations are now run with Queue Jobs.

When auto-update of NFP is active, each time the state of a stock move
changes, a new computation is triggered, but thanks to identity keys on
jobs, only one job at a time is generated for the same buffer.

The `<stock.buffer>.cron_actions` method is automatically delayed when
the context contains `auto_delay_ddmrp_cron_actions=True`.

The scheduled action for buffers ADU computation also generates jobs
instead of recomputing all the buffers at once.

The `<stock.buffer>._calc_adu` method is automatically delayed when the
context contains `auto_delay_ddmrp_calc_adu=True`.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading