Skip to content

Commit

Permalink
Merge PR #493 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by simahawk
  • Loading branch information
OCA-git-bot committed Mar 10, 2023
2 parents a0cab3d + 160707d commit fe311fd
Show file tree
Hide file tree
Showing 18 changed files with 130 additions and 103 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
exclude: |
(?x)
# NOT INSTALLABLE ADDONS
^stock_release_channel/|
# END NOT INSTALLABLE ADDONS
# Files and folders generated by bots, to avoid loops
^setup/|/static/description/index\.html$|
Expand Down
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,
)
11 changes: 6 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 All @@ -88,6 +88,7 @@ Contributors
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
* Matthieu Méquignon <matthieu.mequignon@camptocamp.com>
* Sébastien Alix <sebastien.alix@camptocamp.com>
* Jacques-Etienne Baudoux <je@bcim.be>

Design
~~~~~~
Expand Down Expand Up @@ -124,6 +125,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.
13 changes: 9 additions & 4 deletions stock_release_channel/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,30 @@
{
"name": "Stock Release Channels",
"summary": "Manage workload in WMS with release channels",
"version": "14.0.1.0.0",
"version": "16.0.1.0.0",
"development_status": "Beta",
"license": "AGPL-3",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["sebalix"],
"website": "https://github.com/OCA/wms",
"depends": [
"sale_stock",
"web",
"stock_available_to_promise_release", # OCA/wms
"queue_job", # OCA/queue
],
"data": [
"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",
],
"installable": False,
"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,
}
1 change: 0 additions & 1 deletion stock_release_channel/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from . import sale_order_line
from . import stock_move
from . import stock_picking
from . import stock_release_channel
22 changes: 0 additions & 22 deletions stock_release_channel/models/sale_order_line.py

This file was deleted.

11 changes: 10 additions & 1 deletion stock_release_channel/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2020 Camptocamp
# Copyright 2022 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import models
Expand All @@ -11,5 +12,13 @@ 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

def _action_confirm(self, merge=True, merge_into=False):
moves = super()._action_confirm(merge=merge, merge_into=merge_into)
pickings = moves.filtered("need_release").picking_id
if pickings:
pickings._delay_assign_release_channel()
return moves
51 changes: 40 additions & 11 deletions stock_release_channel/models/stock_release_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ class StockReleaseChannel(models.Model):
release_forbidden = fields.Boolean(string="Forbid to release this channel")
sequence = fields.Integer(default=lambda self: self._default_sequence())
color = fields.Integer()
warehouse_id = fields.Many2one(
"stock.warehouse",
string="Warehouse",
index=True,
help="Warehouse for which this channel is relevant",
)
picking_type_ids = fields.Many2many(
"stock.picking.type",
"stock_release_channel_warehouse_rel",
"channel_id",
"picking_type_id",
string="Operation Types",
domain="warehouse_id"
" and [('warehouse_id', '=', warehouse_id), ('code', '=', 'outgoing')]"
" or [('code', '=', 'outgoing')]",
)
rule_domain = fields.Char(
string="Domain",
default=[],
Expand Down Expand Up @@ -289,8 +305,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 @@ -363,13 +381,17 @@ def assign_release_channel(self, pickings):
return
# do a single query rather than one for each rule*picking
for channel in self.sudo().search([]):
domain = channel._prepare_domain()

if domain:
current = pickings.filtered_domain(domain)
if channel.picking_type_ids:
current = pickings.filtered(
lambda p: p.picking_type_id in channel.picking_type_ids
)
else:
current = pickings

domain = channel._prepare_domain()
if domain:
current = current.filtered_domain(domain)

if not current:
continue

Expand All @@ -378,7 +400,7 @@ def assign_release_channel(self, pickings):

if not current:
continue

current = channel._assign_release_channel_additional_filter(current)
current.release_channel_id = channel

pickings -= current
Expand All @@ -394,6 +416,10 @@ def assign_release_channel(self, pickings):
)
return True

def _assign_release_channel_additional_filter(self, pickings):
self.ensure_one()
return pickings

def _eval_context(self, pickings):
"""Prepare the context used when for the python rule evaluation
Expand Down Expand Up @@ -421,9 +447,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 +566,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
1 change: 1 addition & 0 deletions stock_release_channel/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
* Matthieu Méquignon <matthieu.mequignon@camptocamp.com>
* Sébastien Alix <sebastien.alix@camptocamp.com>
* Jacques-Etienne Baudoux <je@bcim.be>

Design
~~~~~~
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 Expand Up @@ -60,9 +60,8 @@ odoo.define("stock_release_channel.progressbar_fractional_widget", function (req
// This variable is a change made w.r.t. the original one,
// because the original one set the value to 100 if the
// maximum value was zero.
var original_max_value = this.recordData[
this.nodeOptions.max_value
];
var original_max_value =
this.recordData[this.nodeOptions.max_value];
this.$(".o_progressbar_value").text(
utils.human_number(value) +
" / " +
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)
Loading

0 comments on commit fe311fd

Please sign in to comment.