Skip to content

Commit

Permalink
Fix stock_release_channel_auto_release backward port to 14
Browse files Browse the repository at this point in the history
  • Loading branch information
TDu authored and grindtildeath committed Oct 30, 2023
1 parent 7aa0249 commit 316a304
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions stock_available_to_promise_release/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"wizards/stock_release_views.xml",
"wizards/stock_unrelease_views.xml",
],
"demo": [],
"installable": True,
"license": "LGPL-3",
"application": False,
Expand Down
9 changes: 9 additions & 0 deletions stock_available_to_promise_release/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ class StockPicking(models.Model):
city = fields.Char(related="partner_id.city", store=True)
last_release_date = fields.Datetime()

set_printed_at_release = fields.Boolean(compute="_compute_set_printed_at_release")

@api.depends("move_lines")
def _compute_set_printed_at_release(self):
for picking in self:
picking.set_printed_at_release = not (
any(picking.move_lines.mapped("rule_id.no_backorder_at_release"))
)

@api.depends("move_lines.need_release")
def _compute_need_release(self):
data = self.env["stock.move"].read_group(
Expand Down
3 changes: 2 additions & 1 deletion stock_available_to_promise_release/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from odoo import fields
from odoo.tests import common
from odoo.tests import common, tagged


@tagged("post_install", "-at_install")
class PromiseReleaseCommonCase(common.SavepointCase):
@classmethod
def setUpClass(cls):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
create="0"
>
<field name="release_mode" invisible="1" />
<field name="is_release_allowed" />
<field name="color" />
<field name="name" readonly="1" />
<field name="count_picking_release_ready" />
Expand Down
2 changes: 1 addition & 1 deletion stock_release_channel_auto_release/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Stock Release Channel Auto Release",
"summary": """
Add an automatic release mode to the release channel""",
"version": "16.0.1.0.0",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/wms",
Expand Down
8 changes: 4 additions & 4 deletions stock_release_channel_auto_release/data/queue_job_data.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<record model="queue.job.channel" id="stock_release_channel">
<field name="name">stock_release_channel</field>
<record model="queue.job.channel" id="stock_release_channel_auto_release">
<field name="name">stock_release_channel_auto_release</field>
<field name="parent_id" ref="queue_job.channel_root" />
</record>

<record id="job_function_stock_picking_auto_release" model="queue.job.function">
<field name="model_id" ref="stock.model_stock_picking" />
<field name="method">auto_release</field>
<field name="channel_id" ref="stock_release_channel" />
<field name="method">auto_release_available_to_promise</field>
<field name="channel_id" ref="stock_release_channel_auto_release" />
</record>

</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def write(self, vals):
res = super().write(vals)
release_mode = vals.get("release_mode")
if release_mode == "auto":
self.invalidate_recordset(["is_auto_release_allowed"])
self.invalidate_cache(["is_auto_release_allowed"])
self.auto_release_all()
return res

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setUpClass(cls):
cls._update_qty_in_location(cls.loc_bin1, cls.product2, 1000.0)

# invalidate cache for computed fields bases on qty in stock
cls.env.invalidate_all()
cls.env["product.product"].invalidate_cache()

@contextmanager
def assert_release_job_enqueued(self, channel):
Expand Down

0 comments on commit 316a304

Please sign in to comment.