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

[13.0] Add compatibility module for stock_picking_type_shipping_policy and... #27

Merged
merged 2 commits into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions setup/stock_picking_type_shipping_policy_group_by/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,
)
14 changes: 10 additions & 4 deletions stock_picking_type_shipping_policy/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ class StockMove(models.Model):

_inherit = "stock.move"

def _get_new_picking_values(self):
res = super()._get_new_picking_values()
def _shipping_policy_from_picking_type(self):
picking_type = self.mapped("picking_type_id")
if picking_type.shipping_policy == "force_as_soon_as_possible":
res["move_type"] = "direct"
return "direct"
elif picking_type.shipping_policy == "force_all_products_ready":
res["move_type"] = "one"
return "one"
return None

def _get_new_picking_values(self):
res = super()._get_new_picking_values()
picking_type_move_type = self._shipping_policy_from_picking_type()
if picking_type_move_type:
res["move_type"] = picking_type_move_type
return res
1 change: 1 addition & 0 deletions stock_picking_type_shipping_policy_group_by/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions stock_picking_type_shipping_policy_group_by/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
{
"name": "Stock Picking Type Shipping Policy -" " Group By Partner and Carrier",
guewen marked this conversation as resolved.
Show resolved Hide resolved
"summary": "Glue module for Picking Type Shipping Policy"
" and Group Transfers by Partner and Carrier",
"version": "13.0.1.0.0",
"category": "Hidden",
"website": "https://github.com/OCA/wms",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"auto_install": True,
"depends": [
"stock_picking_type_shipping_policy",
# in stock-logistics-workflow
"stock_picking_group_by_partner_by_carrier",
],
"data": [],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_move
14 changes: 14 additions & 0 deletions stock_picking_type_shipping_policy_group_by/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import models


class StockMove(models.Model):
_inherit = "stock.move"

def _domain_search_picking_handle_move_type(self):
picking_type_move_type = self._shipping_policy_from_picking_type()
if picking_type_move_type:
return [("move_type", "=", picking_type_move_type)]
else:
return super()._domain_search_picking_handle_move_type()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Guewen Baconnier <[email protected]>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Technical module to make the following addons work properly together:

* ``stock_picking_type_shipping_policy``
* ``stock_picking_group_by_partner_by_carrier``
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions stock_picking_type_shipping_policy_group_by/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo.tests import SavepointCase


class TestPickingTypeShippingPolicyGroupBy(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
cls.warehouse = cls.env.ref("stock.warehouse0")
cls.pick_type = cls.warehouse.pick_type_id
cls.pick_type.group_pickings = True
cls.product = cls.env.ref("product.product_product_9")
cls.group = cls.env["procurement.group"].create(
{"name": "Test 1", "move_type": "direct"}
)

def _create_single_move(self, picking_type, group, product):
move_vals = {
"name": product.name,
"picking_type_id": picking_type.id,
"product_id": product.id,
"product_uom_qty": 1.0,
"product_uom": product.uom_id.id,
"location_id": picking_type.default_location_src_id.id,
"location_dest_id": picking_type.default_location_dest_id.id,
"state": "confirmed",
"procure_method": "make_to_stock",
"group_id": group.id,
}
return self.env["stock.move"].create(move_vals)

def test_shipping_policy_force_picking_type_one(self):
"""When the picking type changes move_type to 'one'
If the picking type creates a stock.picking for move1 with move_type
'one', ensure that the method that assign move2 to a new picking search
using the same move_type.
"""
self.group.move_type = "direct"
self.pick_type.shipping_policy = "force_all_products_ready"
move1 = self._create_single_move(self.pick_type, self.group, self.product)
move1._assign_picking()
move2 = self._create_single_move(self.pick_type, self.group, self.product)
move2._assign_picking()
self.assertEqual(move1.picking_id, move2.picking_id)
self.assertEqual(move1.picking_id.move_type, "one")