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_stock_delivery_state: Migration to 18.0 #3448

Open
wants to merge 15 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
4 changes: 4 additions & 0 deletions checklog-odoo.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[checklog-odoo]
ignore=
WARNING.*0 failed, 0 error\(s\).*
WARNING.*sale.order.delivery_status: selection=.*overrides existing selection.*
87 changes: 87 additions & 0 deletions sale_stock_delivery_state/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
=========================
Sale Stock Delivery State
=========================

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

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |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_stock_delivery_state
: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_stock_delivery_state
: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 is a glue module for sale_delivery_state and sale_stock

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**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_stock_delivery_state%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
-------

* Akretion

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

- Sébastien BEAU <[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.

This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/18.0/sale_stock_delivery_state>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions sale_stock_delivery_state/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from .hooks import post_init_hook
26 changes: 26 additions & 0 deletions sale_stock_delivery_state/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2023 Akretion (https://www.akretion.com).
# @author Sébastien BEAU <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Sale Stock Delivery State",
"summary": "Change the way to compute the delivery state",
"version": "18.0.1.0.0",
"development_status": "Alpha",
"category": "Uncategorized",
"website": "https://github.com/OCA/sale-workflow",
"author": " Akretion,Odoo Community Association (OCA)",
"license": "AGPL-3",
"external_dependencies": {
"python": [],
"bin": [],
},
"depends": [
"sale_stock",
"sale_delivery_state",
],
"auto_install": True,
"data": ["views/sale_order_views.xml"],
"demo": [],
"post_init_hook": "post_init_hook",
}
26 changes: 26 additions & 0 deletions sale_stock_delivery_state/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2023 Akretion (https://www.akretion.com).
# @author Sébastien BEAU <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import logging
import math

from odoo.tools.misc import split_every

_logger = logging.getLogger(__name__)


def post_init_hook(env):
# Recompute '<sale.order>.delivery_status' by chunk to keep a constant
# memory consumption
order_model = env["sale.order"].with_context(prefetch_fields=False)
rec_ids = order_model.search([]).ids
_logger.info("Recompute 'delivery_status' on %s sale orders...", len(rec_ids))
chunk_size = 2000
nb_chunks = math.ceil(len(rec_ids) / chunk_size)

Check warning on line 20 in sale_stock_delivery_state/hooks.py

View check run for this annotation

Codecov / codecov/patch

sale_stock_delivery_state/hooks.py#L16-L20

Added lines #L16 - L20 were not covered by tests
for i, chunk_ids in enumerate(split_every(chunk_size, rec_ids), 1):
_logger.info("... %s / %s", i, nb_chunks)
records = order_model.browse(chunk_ids)
records._compute_oca_delivery_status()
env.cr.commit()
env.invalidate_all()

Check warning on line 26 in sale_stock_delivery_state/hooks.py

View check run for this annotation

Codecov / codecov/patch

sale_stock_delivery_state/hooks.py#L22-L26

Added lines #L22 - L26 were not covered by tests
27 changes: 27 additions & 0 deletions sale_stock_delivery_state/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:
# * sale_stock_delivery_state
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-07 18:33+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: sale_stock_delivery_state
#: model:ir.model.fields,field_description:sale_stock_delivery_state.field_sale_order__delivery_status
msgid "Delivery Status"
msgstr "Stato di consegna"

#. module: sale_stock_delivery_state
#: model:ir.model,name:sale_stock_delivery_state.model_sale_order
msgid "Sales Order"
msgstr "Ordine di vendita"
24 changes: 24 additions & 0 deletions sale_stock_delivery_state/i18n/sale_stock_delivery_state.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:
# * sale_stock_delivery_state
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.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_stock_delivery_state
#: model:ir.model.fields,field_description:sale_stock_delivery_state.field_sale_order__delivery_status
msgid "Delivery Status"
msgstr ""

#. module: sale_stock_delivery_state
#: model:ir.model,name:sale_stock_delivery_state.model_sale_order
msgid "Sales Order"
msgstr ""
1 change: 1 addition & 0 deletions sale_stock_delivery_state/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_order
11 changes: 11 additions & 0 deletions sale_stock_delivery_state/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2023 Akretion (https://www.akretion.com).
# @author Sébastien BEAU <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class SaleOrder(models.Model):
_inherit = "sale.order"

delivery_status = fields.Selection(compute="_compute_oca_delivery_status")
3 changes: 3 additions & 0 deletions sale_stock_delivery_state/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 sale_stock_delivery_state/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Sébastien BEAU \<<[email protected]>\>
1 change: 1 addition & 0 deletions sale_stock_delivery_state/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.
1 change: 1 addition & 0 deletions sale_stock_delivery_state/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a glue module for sale_delivery_state and sale_stock
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading