Skip to content

Commit a21ba45

Browse files
santostelmosimahawk
authored andcommitted
[ADD] purchase_product_packaging_container_deposit
sale_product_packaging_container_deposit: update contributors purchase_product_packaging_container_deposit: fix qty delivered update [IMP] purchase_product_packaging_container_deposit: Unit test delete container deposit lines
1 parent 36aa0fd commit a21ba45

File tree

14 files changed

+1006
-0
lines changed

14 files changed

+1006
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
============================================
2+
Purchase Product Packaging Container Deposit
3+
============================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:ee29479e09230a63eda66b3d5d8272d946822939cb2b002d7693902b290610a1
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github
20+
:target: https://github.com/OCA/purchase-workflow/tree/16.0/purchase_product_packaging_container_deposit
21+
:alt: OCA/purchase-workflow
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/purchase-workflow-16-0/purchase-workflow-16-0-purchase_product_packaging_container_deposit
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module allows you to add product packaging to an order automatically.
32+
Based on the order line quantity with associated packaging, the quantity of product packaging is calculated and added to the order.
33+
34+
Hypothesis:
35+
36+
* package type "Pack of 12" has the container deposit "pack of 12"
37+
* package type "Pack of 24" has the container deposit "pack of 24"
38+
* package type "EUROPAL" has the container deposit "EU pallet"
39+
40+
41+
.. list-table:: Product A has those packaging:
42+
:widths: 50 50 25
43+
:header-rows: 1
44+
45+
* - package type
46+
- package level
47+
- qty
48+
* - Pack of 12
49+
- PACK
50+
- 12
51+
* - Pack of 24
52+
- Pack
53+
- 24
54+
* - EUROPAL
55+
- PALLET
56+
- 240
57+
58+
Order Line:
59+
60+
* Case 1: Product A | qty = 280. Result:
61+
62+
* 280 // 240 = 1 => add order line for 1 EU pallet
63+
* 280 // 24 (biggest PACK) => add SO line for 11 pack of 24
64+
* Case 2: Product A | qty = 280 and packaging=Pack of 12. Result:
65+
66+
* 280 // 240 =1 => add order line for 1 EU pallet
67+
* 280 // 12 (forced packaging for PACK) => add order line for 23 pack of 12
68+
* Case 3: Product A & Product B. Both have a deposit of 1 pack of 24
69+
70+
* only one line for 2 pack of 24
71+
72+
**Table of contents**
73+
74+
.. contents::
75+
:local:
76+
77+
Bug Tracker
78+
===========
79+
80+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
81+
In case of trouble, please check there if your issue has already been reported.
82+
If you spotted it first, help us to smash it by providing a detailed and welcomed
83+
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_product_packaging_container_deposit%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
84+
85+
Do not contact contributors directly about support or help with technical issues.
86+
87+
Credits
88+
=======
89+
90+
Authors
91+
~~~~~~~
92+
93+
* Camptocamp
94+
* BCIM
95+
96+
Contributors
97+
~~~~~~~~~~~~
98+
99+
* Telmo Santos <telmo.santos@camptocamp.com>
100+
* Jacques-Etienne Baudoux <je@bcim.be>
101+
102+
Maintainers
103+
~~~~~~~~~~~
104+
105+
This module is maintained by the OCA.
106+
107+
.. image:: https://odoo-community.org/logo.png
108+
:alt: Odoo Community Association
109+
:target: https://odoo-community.org
110+
111+
OCA, or the Odoo Community Association, is a nonprofit organization whose
112+
mission is to support the collaborative development of Odoo features and
113+
promote its widespread use.
114+
115+
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/16.0/purchase_product_packaging_container_deposit>`_ project on GitHub.
116+
117+
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,17 @@
1+
# Copyright 2023 Camptocamp (<https://www.camptocamp.com>).
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
{
5+
"name": "Purchase Product Packaging Container Deposit",
6+
"version": "16.0.1.0.0",
7+
"development_status": "Beta",
8+
"category": "Product",
9+
"summary": "Purchase Product Packaging Container Deposit",
10+
"author": "Camptocamp, BCIM, Odoo Community Association (OCA)",
11+
"website": "https://github.com/OCA/purchase-workflow",
12+
"license": "AGPL-3",
13+
"depends": ["purchase_stock", "product_packaging_container_deposit"],
14+
"data": [],
15+
"installable": True,
16+
"auto_install": False,
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import purchase_order
2+
from . import purchase_order_line
3+
from . import stock_move
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2023 Camptocamp (<https://www.camptocamp.com>).
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import models
5+
6+
7+
class PurchaseOrder(models.Model):
8+
_name = "purchase.order"
9+
_inherit = ["purchase.order", "container.deposit.order.mixin"]
10+
11+
def _get_order_line_field(self):
12+
return "order_line"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2023 Camptocamp (<https://www.camptocamp.com>).
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import models
5+
6+
7+
class PurchaseOrderLine(models.Model):
8+
_name = "purchase.order.line"
9+
_inherit = ["purchase.order.line", "container.deposit.order.line.mixin"]
10+
11+
def _get_product_qty_field(self):
12+
return "product_qty"
13+
14+
def _get_product_qty_delivered_received_field(self):
15+
return "qty_received"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2023 Camptocamp (<https://www.camptocamp.com>).
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import models
5+
6+
7+
class StockMove(models.Model):
8+
_inherit = "stock.move"
9+
10+
def _action_done(self, cancel_backorder=False):
11+
todo_moves = super()._action_done(cancel_backorder=cancel_backorder)
12+
# ensure container deposit qty are updated on related POs
13+
if todo_moves:
14+
todo_moves.purchase_line_id.order_id.update_order_container_deposit_quantity()
15+
return todo_moves
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* Telmo Santos <telmo.santos@camptocamp.com>
2+
* Jacques-Etienne Baudoux <je@bcim.be>
3+
* Simone Orsi <simone.orsi@camptocamp.com>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
This module allows you to add product packaging to an order automatically.
2+
Based on the order line quantity with associated packaging, the quantity of product packaging is calculated and added to the order.
3+
4+
Hypothesis:
5+
6+
* package type "Pack of 12" has the container deposit "pack of 12"
7+
* package type "Pack of 24" has the container deposit "pack of 24"
8+
* package type "EUROPAL" has the container deposit "EU pallet"
9+
10+
11+
.. list-table:: Product A has those packaging:
12+
:widths: 50 50 25
13+
:header-rows: 1
14+
15+
* - package type
16+
- package level
17+
- qty
18+
* - Pack of 12
19+
- PACK
20+
- 12
21+
* - Pack of 24
22+
- Pack
23+
- 24
24+
* - EUROPAL
25+
- PALLET
26+
- 240
27+
28+
Order Line:
29+
30+
* Case 1: Product A | qty = 280. Result:
31+
32+
* 280 // 240 = 1 => add order line for 1 EU pallet
33+
* 280 // 24 (biggest PACK) => add SO line for 11 pack of 24
34+
* Case 2: Product A | qty = 280 and packaging=Pack of 12. Result:
35+
36+
* 280 // 240 =1 => add order line for 1 EU pallet
37+
* 280 // 12 (forced packaging for PACK) => add order line for 23 pack of 12
38+
* Case 3: Product A & Product B. Both have a deposit of 1 pack of 24
39+
40+
* only one line for 2 pack of 24

0 commit comments

Comments
 (0)