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

[18.0][MIG] sale_automatic_workflow_periodicity: Migration to 18.0 #3444

Open
wants to merge 7 commits into
base: 18.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
100 changes: 100 additions & 0 deletions sale_automatic_workflow_periodicity/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
===================================
Sale Automatic Workflow Periodicity
===================================

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

.. |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-OCA%2Fsale--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/sale-workflow/tree/18.0/sale_automatic_workflow_periodicity
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-sale_automatic_workflow_periodicity
: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/sale-workflow&target_branch=18.0
:alt: Try me on Runboat

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

This module allows to set a period at which a workflow is going to be
executed.

The period of execution can be set in seconds in the workflow
configuration. The next execution time is displayed below it.

Another option Enforce on creation time can be used so only sales
created before the last execution will be processed.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/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/sale-workflow/issues/new?body=module:%20sale_automatic_workflow_periodicity%0Aversion:%2018.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
------------

- Thierry Ducrest <[email protected]>
- Simone Orsi <[email protected]>
- Henry Backman <[email protected]>
- Chau Le <[email protected]>

Other credits
-------------

The migration of this module from 17.0 to 18.0 was financially supported
by Camptocamp.

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.

.. |maintainer-TDu| image:: https://github.com/TDu.png?size=40px
:target: https://github.com/TDu
:alt: TDu

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-TDu|

This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/18.0/sale_automatic_workflow_periodicity>`_ 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 sale_automatic_workflow_periodicity/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions sale_automatic_workflow_periodicity/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

{
"name": "Sale Automatic Workflow Periodicity",
"summary": "Adds a period for the execution of a workflow.",
"version": "18.0.1.0.0",
"category": "Sales Management",
"license": "AGPL-3",
"author": "Camptocamp, " "Odoo Community Association (OCA)",
"maintainers": ["TDu"],
"website": "https://github.com/OCA/sale-workflow",
"depends": ["sale_automatic_workflow"],
"data": ["views/sale_workflow_process_view.xml"],
}
84 changes: 84 additions & 0 deletions sale_automatic_workflow_periodicity/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_automatic_workflow_periodicity
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-01-26 20:34+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: sale_automatic_workflow_periodicity
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_automatic_workflow_job__display_name
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_sale_workflow_process__display_name
msgid "Display Name"
msgstr "Mostrar Nombre"

#. module: sale_automatic_workflow_periodicity
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_sale_workflow_process__periodicity_check_create_date
msgid "Enforce on creation time"
msgstr "Aplicar en el momento de la creación"

#. module: sale_automatic_workflow_periodicity
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_automatic_workflow_job__id
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_sale_workflow_process__id
msgid "ID"
msgstr "ID"

#. module: sale_automatic_workflow_periodicity
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_automatic_workflow_job____last_update
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_sale_workflow_process____last_update
msgid "Last Modified on"
msgstr "Última Modificación el"

#. module: sale_automatic_workflow_periodicity
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_sale_workflow_process__next_execution
msgid "Next Execution"
msgstr "Próxima Ejecución"

#. module: sale_automatic_workflow_periodicity
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_sale_workflow_process__periodicity
msgid "Run every (in seconds)"
msgstr "Ejecutar cada (en segundos)"

#. module: sale_automatic_workflow_periodicity
#: model:ir.model,name:sale_automatic_workflow_periodicity.model_sale_workflow_process
msgid "Sale Workflow Process"
msgstr "Proceso de Flujo de Venta"

#. module: sale_automatic_workflow_periodicity
#: model:ir.model,name:sale_automatic_workflow_periodicity.model_automatic_workflow_job
msgid ""
"Scheduler that will play automatically the validation of invoices, "
"pickings..."
msgstr ""
"Programador que reproducirá automáticamente la validación de facturas, "
"recogidas..."

#. module: sale_automatic_workflow_periodicity
#: model:ir.model.fields,help:sale_automatic_workflow_periodicity.field_sale_workflow_process__periodicity
msgid "Sets a periodicity for this workflow to be executed (in seconds)"
msgstr ""
"Establece una periodicidad para que se ejecute este flujo de trabajo (en "
"segundos)"

#. module: sale_automatic_workflow_periodicity
#: model:ir.model.fields,help:sale_automatic_workflow_periodicity.field_sale_workflow_process__periodicity_check_create_date
msgid ""
"When checked only sales created before the last execution will be processed."
msgstr ""
"Si se marca, sólo se procesarán las ventas creadas antes de la última "
"ejecución."

#. module: sale_automatic_workflow_periodicity
#: model_terms:ir.ui.view,arch_db:sale_automatic_workflow_periodicity.sale_workflow_process_view_form
msgid "Workflow execution periodicity"
msgstr "Periodicidad de ejecución del flujo de trabajo"
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_automatic_workflow_periodicity
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.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: sale_automatic_workflow_periodicity
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_automatic_workflow_job__display_name
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_sale_workflow_process__display_name
msgid "Display Name"
msgstr ""

#. module: sale_automatic_workflow_periodicity
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_sale_workflow_process__periodicity_check_create_date
msgid "Enforce on creation time"
msgstr ""

#. module: sale_automatic_workflow_periodicity
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_automatic_workflow_job__id
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_sale_workflow_process__id
msgid "ID"
msgstr ""

#. module: sale_automatic_workflow_periodicity
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_automatic_workflow_job____last_update
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_sale_workflow_process____last_update
msgid "Last Modified on"
msgstr ""

#. module: sale_automatic_workflow_periodicity
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_sale_workflow_process__next_execution
msgid "Next Execution"
msgstr ""

#. module: sale_automatic_workflow_periodicity
#: model:ir.model.fields,field_description:sale_automatic_workflow_periodicity.field_sale_workflow_process__periodicity
msgid "Run every (in seconds)"
msgstr ""

#. module: sale_automatic_workflow_periodicity
#: model:ir.model,name:sale_automatic_workflow_periodicity.model_sale_workflow_process
msgid "Sale Workflow Process"
msgstr ""

#. module: sale_automatic_workflow_periodicity
#: model:ir.model,name:sale_automatic_workflow_periodicity.model_automatic_workflow_job
msgid ""
"Scheduler that will play automatically the validation of invoices, "
"pickings..."
msgstr ""

#. module: sale_automatic_workflow_periodicity
#: model:ir.model.fields,help:sale_automatic_workflow_periodicity.field_sale_workflow_process__periodicity
msgid "Sets a periodicity for this workflow to be executed (in seconds)"
msgstr ""

#. module: sale_automatic_workflow_periodicity
#: model:ir.model.fields,help:sale_automatic_workflow_periodicity.field_sale_workflow_process__periodicity_check_create_date
msgid ""
"When checked only sales created before the last execution will be processed."
msgstr ""

#. module: sale_automatic_workflow_periodicity
#: model_terms:ir.ui.view,arch_db:sale_automatic_workflow_periodicity.sale_workflow_process_view_form
msgid "Workflow execution periodicity"
msgstr ""
2 changes: 2 additions & 0 deletions sale_automatic_workflow_periodicity/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import automatic_workflow_job
from . import sale_workflow_process
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import api, fields, models


class AutomaticWorkflowJob(models.Model):
_inherit = "automatic.workflow.job"

def run_with_workflow(self, sale_workflow):
res = super().run_with_workflow(sale_workflow)
if sale_workflow.periodicity:
sale_workflow.next_execution = fields.Datetime.add(
fields.Datetime.now(), seconds=sale_workflow.periodicity
)
return res

@api.model
def _workflow_process_to_run_domain(self):
return [
"|",
("periodicity", "=", 0),
"|",
"&",
("periodicity", ">", 0),
("next_execution", "<=", fields.Datetime.now()),
("next_execution", "=", False),
]

def _sale_workflow_domain(self, workflow):
domain = super()._sale_workflow_domain(workflow)
if workflow.periodicity_check_create_date:
domain.append(
(
"create_date",
"<",
fields.Datetime.subtract(
fields.Datetime.now(), seconds=workflow.periodicity
),
)
)
return domain
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import fields, models


class SaleWorkflowProcess(models.Model):
_inherit = "sale.workflow.process"

periodicity = fields.Integer(
string="Run every (in seconds)",
help="Sets a periodicity for this workflow to be executed (in seconds)",
)
next_execution = fields.Datetime()
periodicity_check_create_date = fields.Boolean(
string="Enforce on creation time",
help="When checked only sales created before the last execution "
"will be processed.",
)

def write(self, vals):
if "periodicity" in vals.keys():
periodicity = vals["periodicity"]
if periodicity == 0:
vals["next_execution"] = False
else:
now = fields.Datetime.now()
vals["next_execution"] = fields.Datetime.add(now, seconds=periodicity)
return super().write(vals)
3 changes: 3 additions & 0 deletions sale_automatic_workflow_periodicity/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
4 changes: 4 additions & 0 deletions sale_automatic_workflow_periodicity/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Thierry Ducrest \<<[email protected]>\>
- Simone Orsi \<<[email protected]>\>
- Henry Backman \<<[email protected]>\>
- Chau Le \<<[email protected]>\>
1 change: 1 addition & 0 deletions sale_automatic_workflow_periodicity/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The migration of this module from 17.0 to 18.0 was financially supported by Camptocamp.
8 changes: 8 additions & 0 deletions sale_automatic_workflow_periodicity/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This module allows to set a period at which a workflow is going to be
executed.

The period of execution can be set in seconds in the workflow
configuration. The next execution time is displayed below it.

Another option Enforce on creation time can be used so only sales
created before the last execution will be processed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading