Skip to content

Commit cdcb4ae

Browse files
AdriaGForgeFlowPauBForgeFlow
authored andcommitted
[12.0][ADD] purchase_manual_delivery
[ADD] ability to change destination location in wizard
1 parent fbc0766 commit cdcb4ae

18 files changed

+1319
-0
lines changed

purchase_manual_delivery/README.rst

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
========================
2+
Purchase Manual Delivery
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%2Fpurchase--workflow-lightgray.png?logo=github
17+
:target: https://github.com/OCA/purchase-workflow/tree/12.0/purchase_manual_delivery
18+
:alt: OCA/purchase-workflow
19+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20+
:target: https://translation.odoo-community.org/projects/purchase-workflow-12-0/purchase-workflow-12-0-purchase_manual_delivery
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/142/12.0
24+
:alt: Try me on Runbot
25+
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
27+
28+
The goal of this module is to allow the manual creation of incoming shipments. When installed,
29+
a purchase order won't impact directly the stock. It will not create the pickings upon order confirmation.
30+
It allows the reception and the impact on stock to be done manually when needed.
31+
The goal is to be used when a supplier does not confirm the full order at once. As the supplier
32+
confirms the different purchase order lines, the user can manually create the incoming
33+
shipments for those specific lines.
34+
35+
**Table of contents**
36+
37+
.. contents::
38+
:local:
39+
40+
Usage
41+
=====
42+
43+
There are two main ways to use this module:
44+
45+
* From Purchase Order
46+
47+
When creating a purchase order and confirming it, no picking will be automatically created.
48+
Lines with pending quantities to receive will appear in blue color, to create
49+
the manual picking press the button "Create Incoming Shipment":
50+
51+
.. figure:: https://raw.githubusercontent.com/OCA/purchase-workflow/12.0/purchase_manual_delivery/static/description/create_incoming_shipment_button.png
52+
:width: 800px
53+
54+
This will trigger the wizard that lets the user choose which lines should be taken for the
55+
creation of the picking and also the quantities. Clicking on the "Create and View Picking"
56+
will create the reception and redirect the user to the picking form.
57+
58+
.. figure:: https://raw.githubusercontent.com/OCA/purchase-workflow/12.0/purchase_manual_delivery/static/description/create_incoming_shipment_wizard.png
59+
:width: 800px
60+
61+
62+
* From Purchase Order Line
63+
64+
The module adds a new list view for Purchase Order Lines (in Purchase Menu). From there you can select multiple
65+
PO lines (in this base module only PO lines from same PO can be selected) and create the
66+
manual delivery. Follow the same steps as above to manually generate the incoming shipment.
67+
68+
Bug Tracker
69+
===========
70+
71+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
72+
In case of trouble, please check there if your issue has already been reported.
73+
If you spotted it first, help us smashing it by providing a detailed and welcomed
74+
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_manual_delivery%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
75+
76+
Do not contact contributors directly about support or help with technical issues.
77+
78+
Credits
79+
=======
80+
81+
Authors
82+
~~~~~~~
83+
84+
* ForgeFlow S.L.
85+
86+
Contributors
87+
~~~~~~~~~~~~
88+
89+
* Adria Gil Sorribes <adria.gil@forgeflow.com>
90+
91+
Maintainers
92+
~~~~~~~~~~~
93+
94+
This module is maintained by the OCA.
95+
96+
.. image:: https://odoo-community.org/logo.png
97+
:alt: Odoo Community Association
98+
:target: https://odoo-community.org
99+
100+
OCA, or the Odoo Community Association, is a nonprofit organization whose
101+
mission is to support the collaborative development of Odoo features and
102+
promote its widespread use.
103+
104+
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/12.0/purchase_manual_delivery>`_ project on GitHub.
105+
106+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

purchase_manual_delivery/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import models
2+
from . import wizard
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2019 ForgeFlow S.L.
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
{
5+
'name': 'Purchase Manual Delivery',
6+
'summary': """
7+
Prevents pickings to be auto generated upon Purchase Order confirmation
8+
and adds the ability to manually generate them as the supplier confirms
9+
the different purchase order lines.
10+
""",
11+
'version': '12.0.1.0.0',
12+
'license': 'AGPL-3',
13+
'author': 'ForgeFlow S.L.,'
14+
'Odoo Community Association (OCA)',
15+
'website': 'https://github.com/OCA/purchase-workflow',
16+
'depends': [
17+
'purchase_stock'
18+
],
19+
'data': [
20+
'wizard/create_manual_stock_picking.xml',
21+
'views/purchase_order_views.xml',
22+
],
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import purchase_order
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Copyright 2019 ForgeFlow S.L.
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import api, fields, models
5+
from odoo.addons import decimal_precision as dp
6+
from odoo.tools import float_compare
7+
8+
9+
class PurchaseOrder(models.Model):
10+
_inherit = "purchase.order"
11+
12+
pending_to_receive = fields.Boolean(compute="_compute_pending_to_receive")
13+
14+
def _compute_pending_to_receive(self):
15+
for order in self:
16+
order.pending_to_receive = True
17+
if all(
18+
val is False
19+
for val in order.mapped("order_line.pending_to_receive")
20+
):
21+
order.pending_to_receive = False
22+
23+
@api.multi
24+
def button_confirm_manual(self):
25+
super(
26+
PurchaseOrder, self.with_context(manual_delivery=True)
27+
).button_confirm()
28+
29+
@api.multi
30+
def _create_picking(self):
31+
if self.env.context.get("manual_delivery", False):
32+
# We do not want to create the picking when confirming the order
33+
# if it comes from manual confirmation
34+
return
35+
return super()._create_picking()
36+
37+
38+
class PurchaseOrderLine(models.Model):
39+
_inherit = "purchase.order.line"
40+
41+
existing_qty = fields.Float(
42+
compute="_compute_existing_qty",
43+
string="Existing Qty",
44+
digits=dp.get_precision("Product Unit of Measure"),
45+
help="Quantity already planned or shipped (stock movements "
46+
"already created)",
47+
)
48+
pending_to_receive = fields.Boolean(
49+
compute="_compute_existing_qty",
50+
store=True,
51+
string="Pending Qty to Receive",
52+
help="There is pending quantity to receive not yet planned",
53+
)
54+
55+
@api.depends(
56+
"move_ids",
57+
"move_ids.state",
58+
"move_ids.location_id",
59+
"move_ids.location_dest_id",
60+
)
61+
def _compute_existing_qty(self):
62+
for line in self:
63+
rounding = line.company_id.currency_id.rounding
64+
total = 0.0
65+
for move in line.move_ids:
66+
if move.state not in ["cancel"]:
67+
if move.location_dest_id.usage == "supplier":
68+
if move.to_refund:
69+
total -= move.product_uom._compute_quantity(
70+
move.product_uom_qty, line.product_uom
71+
)
72+
elif (
73+
move.origin_returned_move_id._is_dropshipped()
74+
and not move._is_dropshipped_returned()
75+
):
76+
# Edge case: the dropship is returned to the stock,
77+
# no to the supplier.
78+
# In this case, the received quantity on the PO is
79+
# set although we didn't receive the product
80+
# physically in our stock. To avoid counting the
81+
# quantity twice, we do nothing.
82+
pass
83+
else:
84+
total += move.product_uom._compute_quantity(
85+
move.product_uom_qty, line.product_uom
86+
)
87+
line.existing_qty = total
88+
if float_compare(
89+
line.product_uom_qty,
90+
line.existing_qty,
91+
precision_rounding=rounding,
92+
):
93+
line.pending_to_receive = True
94+
else:
95+
line.pending_to_receive = False
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Adria Gil Sorribes <adria.gil@forgeflow.com>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The goal of this module is to allow the manual creation of incoming shipments. When installed,
2+
a purchase order won't impact directly the stock. It will not create the pickings upon order confirmation.
3+
It allows the reception and the impact on stock to be done manually when needed.
4+
The goal is to be used when a supplier does not confirm the full order at once. As the supplier
5+
confirms the different purchase order lines, the user can manually create the incoming
6+
shipments for those specific lines.
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
There are two main ways to use this module:
2+
3+
* From Purchase Order
4+
5+
When creating a purchase order and confirming it, no picking will be automatically created.
6+
Lines with pending quantities to receive will appear in blue color, to create
7+
the manual picking press the button "Create Incoming Shipment":
8+
9+
.. figure:: ../static/description/create_incoming_shipment_button.png
10+
:width: 800px
11+
12+
This will trigger the wizard that lets the user choose which lines should be taken for the
13+
creation of the picking and also the quantities. Clicking on the "Create and View Picking"
14+
will create the reception and redirect the user to the picking form.
15+
16+
.. figure:: ../static/description/create_incoming_shipment_wizard.png
17+
:width: 800px
18+
19+
20+
* From Purchase Order Line
21+
22+
The module adds a new list view for Purchase Order Lines (in Purchase Menu). From there you can select multiple
23+
PO lines (in this base module only PO lines from same PO can be selected) and create the
24+
manual delivery. Follow the same steps as above to manually generate the incoming shipment.
Loading
Loading
Loading

0 commit comments

Comments
 (0)