Skip to content

Commit

Permalink
[MIG] stock_release_channel: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lmignon committed Nov 14, 2022
1 parent b436c23 commit 4b05fb5
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 52 deletions.
6 changes: 6 additions & 0 deletions setup/stock_release_channel/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
10 changes: 5 additions & 5 deletions stock_release_channel/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Stock Release Channels
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fwms-lightgray.png?logo=github
:target: https://github.com/OCA/wms/tree/14.0/stock_release_channel
:target: https://github.com/OCA/wms/tree/16.0/stock_release_channel
:alt: OCA/wms
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/wms-14-0/wms-14-0-stock_release_channel
:target: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-stock_release_channel
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/285/14.0
:target: https://runbot.odoo-community.org/runbot/285/16.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -70,7 +70,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/wms/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/wms/issues/new?body=module:%20stock_release_channel%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/wms/issues/new?body=module:%20stock_release_channel%0Aversion:%2016.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.

Expand Down Expand Up @@ -124,6 +124,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-sebalix|

This module is part of the `OCA/wms <https://github.com/OCA/wms/tree/14.0/stock_release_channel>`_ project on GitHub.
This module is part of the `OCA/wms <https://github.com/OCA/wms/tree/16.0/stock_release_channel>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
9 changes: 8 additions & 1 deletion stock_release_channel/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,25 @@
"maintainers": ["sebalix"],
"website": "https://github.com/OCA/wms",
"depends": [
"web",
"sale_stock",
"stock_available_to_promise_release", # OCA/wms
"queue_job", # OCA/queue
],
"data": [
"views/assets.xml",
# "views/assets.xml",
"views/stock_release_channel_views.xml",
"views/stock_picking_views.xml",
"data/stock_release_channel_data.xml",
"data/queue_job_data.xml",
"data/ir_cron_data.xml",
"security/stock_release_channel.xml",
],
"assets": {
"web.assets_backend": [
"stock_release_channel/static/src/scss/stock_release_channel.scss",
"stock_release_channel/static/src/js/progressbar_fractional_widget.js",
],
},
"installable": True,
}
3 changes: 2 additions & 1 deletion stock_release_channel/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ def release_available_to_promise(self):
# after releasing, we re-assign a release channel,
# as we may release only partially, the channel may
# change
super().release_available_to_promise()
res = super().release_available_to_promise()
self.picking_id.assign_release_channel()
return res
17 changes: 11 additions & 6 deletions stock_release_channel/models/stock_release_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,10 @@ def _query_get_chain(self, pickings):
return (query, (tuple(pickings.ids),))

def _compute_picking_chain(self):
self.env["stock.move"].flush(["move_dest_ids", "move_orig_ids", "picking_id"])
self.env["stock.picking"].flush(["state"])
self.env["stock.move"].flush_model(
["move_dest_ids", "move_orig_ids", "picking_id"]
)
self.env["stock.picking"].flush_model(["state"])
for channel in self:
domain = self._field_picking_domains()["count_picking_released"]
domain += [("release_channel_id", "=", channel.id)]
Expand Down Expand Up @@ -421,9 +423,12 @@ def _eval_code(self, pickings):
safe_eval(expr, eval_context, mode="exec", nocopy=True)
except Exception as err:
raise exceptions.UserError(
_("Error when evaluating the channel's code:\n %s \n(%s)")
% (self.name, err)
)
_(
"Error when evaluating the channel's code:\n %(name)s \n(%(error)s)",
name=self.name,
error=err,
)
) from err
# normally "pickings" is always set as we set it in the eval context,
# but let assume the worst case with someone using "del pickings"
return eval_context.get("pickings", self.env["stock.picking"].browse())
Expand Down Expand Up @@ -537,7 +542,7 @@ def get_action_picking_form(self):
action["context"] = {}
if not self.last_done_picking_id:
raise exceptions.UserError(
_("Channel %s has no validated transfer yet.") % (self.name,)
_("Channel %(name)s has no validated transfer yet.", name=self.name)
)
action["res_id"] = self.last_done_picking_id.id
return action
Expand Down
8 changes: 4 additions & 4 deletions stock_release_channel/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Stock Release Channels</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Stock Release Channels</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/wms/tree/14.0/stock_release_channel"><img alt="OCA/wms" src="https://img.shields.io/badge/github-OCA%2Fwms-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/wms-14-0/wms-14-0-stock_release_channel"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/285/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/wms/tree/16.0/stock_release_channel"><img alt="OCA/wms" src="https://img.shields.io/badge/github-OCA%2Fwms-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-stock_release_channel"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/285/16.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Release channels are:</p>
<ul class="simple">
<li>Release channels are created by stock managers (only pallets, only parcels, …)</li>
Expand Down Expand Up @@ -419,7 +419,7 @@ <h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/wms/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/wms/issues/new?body=module:%20stock_release_channel%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/wms/issues/new?body=module:%20stock_release_channel%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -462,7 +462,7 @@ <h2><a class="toc-backref" href="#id9">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/sebalix"><img alt="sebalix" src="https://github.com/sebalix.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/wms/tree/14.0/stock_release_channel">OCA/wms</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/wms/tree/16.0/stock_release_channel">OCA/wms</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ odoo.define("stock_release_channel.progressbar_fractional_widget", function (req
"use strict";

var utils = require("web.utils");
var field_registry = require("web.field_registry");
var FieldProgressBar = field_registry.get("progressbar");
var basic_fields = require("web.basic_fields");
var FieldProgressBar = basic_fields.FieldProgressBar;

/**
* New node option:
Expand Down
4 changes: 2 additions & 2 deletions stock_release_channel/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)


class ReleaseChannelCase(common.SavepointCase):
class ReleaseChannelCase(common.TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down Expand Up @@ -152,5 +152,5 @@ def _out_picking(cls, pickings):

def _action_done_picking(self, picking):
for line in picking.move_line_ids:
line.qty_done = line.product_uom_qty
line.qty_done = line.reserved_qty
picking._action_done()
8 changes: 4 additions & 4 deletions stock_release_channel/tests/test_channel_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_action_released_assigned_waiting(self):
self.channel.action_move_released(), self.picking + self.picking2
)

pick_picking = self.picking.move_lines.move_orig_ids.picking_id
pick_picking = self.picking.move_ids.move_orig_ids.picking_id
self._action_done_picking(pick_picking)

self._assert_picking_action(
Expand All @@ -87,7 +87,7 @@ def _release_all(self):
def test_action_all_related(self):
self._release_all()
pickings = self.picking + self.picking2 + self.picking3
related = pickings.move_lines.move_orig_ids.picking_id
related = pickings.move_ids.move_orig_ids.picking_id

action = self.channel.action_picking_all_related()
self._assert_picking_action(
Expand Down Expand Up @@ -120,7 +120,7 @@ def test_action_priority(self):

def test_action_done(self):
self._release_all()
self._action_done_picking(self.picking.move_lines.move_orig_ids.picking_id)
self._action_done_picking(self.picking.move_ids.move_orig_ids.picking_id)
self._action_done_picking(self.picking)

self._assert_picking_action(self.channel.action_picking_done(), self.picking)
Expand All @@ -132,7 +132,7 @@ def test_action_no_last_picking_done(self):

def test_action_last_picking_done(self):
self._release_all()
self._action_done_picking(self.picking.move_lines.move_orig_ids.picking_id)
self._action_done_picking(self.picking.move_ids.move_orig_ids.picking_id)
self._action_done_picking(self.picking)
action = self.channel.get_action_picking_form()
self.assertEqual(action["res_id"], self.picking.id)
12 changes: 6 additions & 6 deletions stock_release_channel/tests/test_channel_computed_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ def test_computed_fields_counts(self):
self._update_qty_in_location(self.loc_bin1, self.product1, 20.0)
self._update_qty_in_location(self.loc_bin1, self.product2, 20.0)

channel.invalidate_cache()
channel.env.invalidate_all()
self.assertEqual(channel.count_picking_release_ready, 3)

picking.release_available_to_promise()
pick_picking = picking.move_lines.move_orig_ids.picking_id
pick_picking = picking.move_ids.move_orig_ids.picking_id

channel.invalidate_cache()
channel.env.invalidate_all()

self.assertEqual(channel.count_picking_all, 3)
self.assertEqual(channel.count_move_all, 6)
Expand All @@ -53,18 +53,18 @@ def test_computed_fields_counts(self):
self.assertEqual(channel.picking_chain_ids, pick_picking)

picking.scheduled_date = fields.Datetime.now() - timedelta(hours=1)
channel.invalidate_cache()
channel.env.invalidate_all()
self.assertEqual(channel.count_picking_late, 1)
self.assertEqual(channel.count_move_late, 2)

self._action_done_picking(pick_picking)

channel.invalidate_cache()
channel.env.invalidate_all()
self.assertEqual(channel.count_picking_assigned, 1)
self.assertEqual(channel.count_move_assigned, 2)
self._action_done_picking(picking)

channel.invalidate_cache()
channel.env.invalidate_all()
self.assertEqual(channel.count_picking_done, 1)
self.assertEqual(channel.count_picking_chain, 0)
self.assertEqual(channel.count_picking_chain_in_progress, 0)
Expand Down
2 changes: 1 addition & 1 deletion stock_release_channel/tests/test_channel_release_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_release_auto_max_next_batch(self):
# nothing new to release
self.channel.release_next_batch()

self._action_done_picking(self.pickings[0].move_lines.move_orig_ids.picking_id)
self._action_done_picking(self.pickings[0].move_ids.move_orig_ids.picking_id)
self._action_done_picking(self.pickings[0])

self.channel.release_next_batch()
Expand Down
20 changes: 0 additions & 20 deletions stock_release_channel/views/assets.xml

This file was deleted.

0 comments on commit 4b05fb5

Please sign in to comment.