Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0058aaa

Browse files
committedMar 24, 2023·
[ADD] stock_picking_delivery_package
1 parent 86bcac0 commit 0058aaa

17 files changed

+728
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../stock_picking_delivery_package
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)
+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
==============================
2+
Stock Picking Delivery Package
3+
==============================
4+
5+
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6+
!! This file is generated by oca-gen-addon-readme !!
7+
!! changes will be overwritten. !!
8+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9+
10+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
11+
:target: https://odoo-community.org/page/development-status
12+
:alt: Beta
13+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
14+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
15+
:alt: License: AGPL-3
16+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdelivery--carrier-lightgray.png?logo=github
17+
:target: https://github.com/OCA/delivery-carrier/tree/16.0/stock_picking_delivery_package
18+
:alt: OCA/delivery-carrier
19+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20+
:target: https://translation.odoo-community.org/projects/delivery-carrier-16-0/delivery-carrier-16-0-stock_picking_delivery_package
21+
:alt: Translate me on Weblate
22+
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23+
:target: https://runbot.odoo-community.org/runbot/99/16.0
24+
:alt: Try me on Runbot
25+
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
27+
28+
This module allows to launch the wizard to choose a delivery package
29+
in another flow than the output transfer.
30+
31+
**Table of contents**
32+
33+
.. contents::
34+
:local:
35+
36+
Configuration
37+
=============
38+
39+
#. Go to Inventory > Configuration > Warehouse Management > Operation Types
40+
#. On the operation type you want to use the feature, check the box
41+
'Launch Delivery Package Wizard' (you should have activated the Packages management before).
42+
43+
Usage
44+
=====
45+
46+
After having activated the feature on Operation Type level,
47+
fill in the quantities you want to transfer and click on
48+
'Put in Pack' button.
49+
50+
Then, as for deliveries, fill in the desired package type.
51+
52+
Bug Tracker
53+
===========
54+
55+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/delivery-carrier/issues>`_.
56+
In case of trouble, please check there if your issue has already been reported.
57+
If you spotted it first, help us smashing it by providing a detailed and welcomed
58+
`feedback <https://github.com/OCA/delivery-carrier/issues/new?body=module:%20stock_picking_delivery_package%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
59+
60+
Do not contact contributors directly about support or help with technical issues.
61+
62+
Credits
63+
=======
64+
65+
Authors
66+
~~~~~~~
67+
68+
* ACSONE SA/NV
69+
70+
Contributors
71+
~~~~~~~~~~~~
72+
73+
* Denis Roussel <denis.roussel@acsone.eu>
74+
75+
Maintainers
76+
~~~~~~~~~~~
77+
78+
This module is maintained by the OCA.
79+
80+
.. image:: https://odoo-community.org/logo.png
81+
:alt: Odoo Community Association
82+
:target: https://odoo-community.org
83+
84+
OCA, or the Odoo Community Association, is a nonprofit organization whose
85+
mission is to support the collaborative development of Odoo features and
86+
promote its widespread use.
87+
88+
This module is part of the `OCA/delivery-carrier <https://github.com/OCA/delivery-carrier/tree/16.0/stock_picking_delivery_package>`_ project on GitHub.
89+
90+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2023 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Stock Picking Delivery Package",
6+
"summary": """
7+
This module allows to define a delivery package elsewhere than on the
8+
delivery picking""",
9+
"version": "16.0.1.0.0",
10+
"license": "AGPL-3",
11+
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
12+
"website": "https://github.com/OCA/delivery-carrier",
13+
"depends": [
14+
"stock_picking_delivery_link",
15+
],
16+
"data": [
17+
"views/stock_picking_type.xml",
18+
],
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import stock_picking
2+
from . import stock_picking_type
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2023 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import models
5+
6+
7+
class StockPicking(models.Model):
8+
9+
_inherit = "stock.picking"
10+
11+
def _pre_put_in_pack_hook(self, move_line_ids):
12+
"""
13+
If the feature is enabled on picking type level, launch the
14+
Choose Delivery Package wizard. As the default behaviour in delivery module
15+
is to rely on carrier_id value (that we don't have in other operations than OUT).
16+
"""
17+
if self.ship_carrier_id and self.picking_type_id.launch_delivery_package_wizard:
18+
result = self._set_delivery_package_type()
19+
context = result.get("context", {})
20+
if context.get("current_package_carrier_type") != "none":
21+
context.update(
22+
{
23+
"current_package_carrier_type": self.ship_carrier_id.delivery_type,
24+
}
25+
)
26+
result["context"] = context
27+
return result
28+
return super()._pre_put_in_pack_hook(move_line_ids)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2023 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
7+
class StockPickingType(models.Model):
8+
9+
_inherit = "stock.picking.type"
10+
11+
launch_delivery_package_wizard = fields.Boolean(
12+
help="When doing Put In Pack, launch the wizard to allow choosing the "
13+
"Delivery Package Type"
14+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#. Go to Inventory > Configuration > Warehouse Management > Operation Types
2+
#. On the operation type you want to use the feature, check the box
3+
'Launch Delivery Package Wizard' (you should have activated the Packages management before).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Denis Roussel <denis.roussel@acsone.eu>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This module allows to launch the wizard to choose a delivery package
2+
in another flow than the output transfer.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
After having activated the feature on Operation Type level,
2+
fill in the quantities you want to transfer and click on
3+
'Put in Pack' button.
4+
5+
Then, as for deliveries, fill in the desired package type.
Loading

‎stock_picking_delivery_package/static/description/index.html

+437
Large diffs are not rendered by default.

‎stock_picking_delivery_package/tests/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Copyright 2023 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
from odoo import Command
4+
from odoo.tests.common import TransactionCase
5+
6+
7+
class TestStockPickingDeliveryPackage(TransactionCase):
8+
@classmethod
9+
def setUpClass(cls):
10+
super().setUpClass()
11+
cls.warehouse = cls.env.ref("stock.warehouse0")
12+
cls.stock_move_obj = cls.env["stock.move"]
13+
cls.warehouse.delivery_steps = "pick_ship"
14+
cls.pick_type = cls.warehouse.pick_type_id
15+
16+
cls.location_out = cls.env.ref("stock.stock_location_output")
17+
cls.location_customers = cls.env.ref("stock.stock_location_customers")
18+
19+
cls.delivery_product = cls.env["product.product"].create(
20+
{
21+
"name": "Delivery Test",
22+
"type": "service",
23+
}
24+
)
25+
cls.carrier = cls.env["delivery.carrier"].create(
26+
{
27+
"name": "Delivery Test",
28+
"product_id": cls.delivery_product.id,
29+
}
30+
)
31+
32+
cls.route = cls.env["stock.route"].search(
33+
[
34+
("rule_ids.location_dest_id", "=", cls.location_customers.id),
35+
("rule_ids.location_src_id", "=", cls.location_out.id),
36+
],
37+
limit=1,
38+
)
39+
cls.rule_out = cls.route.rule_ids.filtered(
40+
lambda r: r.location_dest_id == cls.location_customers
41+
)
42+
43+
cls.pick_type.launch_delivery_package_wizard = True
44+
cls.package_type = cls.env["stock.package.type"].create(
45+
{"name": "Package Type A"}
46+
)
47+
48+
cls.product = cls.env["product.product"].create(
49+
{
50+
"name": "Product Test",
51+
"type": "product",
52+
"route_ids": [Command.link(cls.route.id)],
53+
}
54+
)
55+
cls._create_qty()
56+
cls.group = cls.env["procurement.group"].create({"name": "Test"})
57+
cls.env["procurement.group"].run(
58+
[
59+
cls.group.Procurement(
60+
cls.product,
61+
2.0,
62+
cls.product.uom_id,
63+
cls.location_customers,
64+
cls.product.name,
65+
"test",
66+
cls.warehouse.company_id,
67+
{},
68+
)
69+
]
70+
)
71+
cls.move_pick = cls.stock_move_obj.search(
72+
[
73+
("product_id", "=", cls.product.id),
74+
("location_dest_id", "=", cls.location_out.id),
75+
]
76+
)
77+
cls.move_out = cls.stock_move_obj.search(
78+
[
79+
("product_id", "=", cls.product.id),
80+
("location_dest_id", "=", cls.location_customers.id),
81+
]
82+
)
83+
cls.move_out.picking_id.carrier_id = cls.carrier
84+
85+
@classmethod
86+
def _create_qty(cls):
87+
cls.env["stock.quant"].with_context(inventory_mode=True).create(
88+
{
89+
"product_id": cls.product.id,
90+
"inventory_quantity": 10.0,
91+
"location_id": cls.env.ref("stock.stock_location_stock").id,
92+
}
93+
)._apply_inventory()
94+
95+
def test_picking_delivery(self):
96+
result = self.move_pick.picking_id.action_put_in_pack()
97+
self.assertEqual(result.get("res_model"), "choose.delivery.package")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!-- Copyright 2023 ACSONE SA/NV
3+
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
4+
<odoo>
5+
6+
<record model="ir.ui.view" id="stock_picking_type_form_view">
7+
<field
8+
name="name"
9+
>stock.picking.type.form (in stock_picking_delivery_package)</field>
10+
<field name="model">stock.picking.type</field>
11+
<field name="inherit_id" ref="stock.view_picking_type_form" />
12+
<field name="arch" type="xml">
13+
<field name="show_entire_packs" position="after">
14+
<field
15+
name="launch_delivery_package_wizard"
16+
groups="stock.group_tracking_lot"
17+
/>
18+
</field>
19+
</field>
20+
</record>
21+
22+
</odoo>

0 commit comments

Comments
 (0)
Please sign in to comment.