Skip to content

Commit

Permalink
Add stock_release_channel
Browse files Browse the repository at this point in the history
  • Loading branch information
guewen authored and sbejaoui committed Mar 7, 2023
1 parent e288854 commit 60fc3c4
Show file tree
Hide file tree
Showing 10 changed files with 1,046 additions and 0 deletions.
1 change: 1 addition & 0 deletions stock_release_channel/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions stock_release_channel/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2020 Camptocamp
# License OPL-1

{
"name": "Stock Release Channels",
"summary": "Manage workload in WMS with release channels",
"version": "13.0.1.0.0",
"license": "OPL-1",
"author": "Camptocamp",
"website": "https://www.camptocamp.com",
"depends": ["sale_stock", "stock_available_to_promise_release", "ddmrp"],
"data": [
"security/stock_release_channel.xml",
"views/stock_release_channel_views.xml",
"views/stock_picking_views.xml",
"data/stock_release_channel_data.xml",
],
}
10 changes: 10 additions & 0 deletions stock_release_channel/data/stock_release_channel_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">

<record model="stock.release.channel" id="stock_release_channel_default">
<field name="name">Default</field>
<field name="sequence">999</field>
<field name="rule_domain">[]</field>
</record>

</odoo>
3 changes: 3 additions & 0 deletions stock_release_channel/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import sale_order_line
from . import stock_picking
from . import stock_release_channel
19 changes: 19 additions & 0 deletions stock_release_channel/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2020 Camptocamp
# License OPL-1

from odoo import models


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

def _action_launch_stock_rule(self, previous_product_uom_qty=False):
result = super()._action_launch_stock_rule(
previous_product_uom_qty=previous_product_uom_qty
)
pickings = self.move_ids.picking_id
# ensure we assign a channel on any picking OUT generated for the sale,
# if moves are assigned to an existing transfer, we recompute the
# channel
pickings.assign_release_channel()
return result
21 changes: 21 additions & 0 deletions stock_release_channel/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2020 Camptocamp
# License OPL-1

from odoo import fields, models


class StockPicking(models.Model):
_inherit = "stock.picking"

release_channel_id = fields.Many2one(
comodel_name="stock.release.channel", index=True, ondelete="restrict"
)

# TODO queue.job (with identity key)
def assign_release_channel(self):
self.env["stock.release.channel"].assign_release_channel(self)

def _create_backorder(self):
backorders = super()._create_backorder()
self.env["stock.release.channel"].assign_release_channel(backorders)
return backorders
Loading

0 comments on commit 60fc3c4

Please sign in to comment.