Skip to content

Commit 7242fcc

Browse files
committed
[MIG] stock_picking_batch_extended: finish migration to 18.0
1 parent eced696 commit 7242fcc

File tree

16 files changed

+151
-149
lines changed

16 files changed

+151
-149
lines changed

stock_picking_batch_extended/README.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Stock batch picking extended
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:2a60deeaeb86880a5da8255ca2d35888776a39724817647f7406defa489f28ab
10+
!! source digest: sha256:145e388b3d5a20965b2351bf7d4edf791aae2d90869e15803c0b995739910cdc
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
@@ -46,17 +46,17 @@ deactivate which approach for batch handling will be used per company.
4646
By default after installation this option will be activated for all
4747
companies.
4848

49-
|image1|
49+
|settings|
5050

51-
.. |image1| image:: https://raw.githubusercontent.com/OCA/stock-logistics-workflow/18.0/stock_picking_batch_extended/static/picking_batch_configuration_settings.png
51+
.. |settings| image:: https://raw.githubusercontent.com/OCA/stock-logistics-workflow/18.0/stock_picking_batch_extended/static/picking_batch_configuration_settings.png
5252

5353
Usage
5454
=====
5555

5656
When you create a batch pick, the creation wizard will appear with the
5757
new fields added.
5858

59-
|image1|
59+
|wizard|
6060

6161
1. Name: Allows to rename the batch. But be careful, if this is done, it
6262
overwrites the name that Odoo assigns to the batch by default.
@@ -68,7 +68,7 @@ Adds to the form view of batch picking:
6868

6969
**In "Draft" status:**
7070

71-
|image2|
71+
|draft|
7272

7373
1. Delete all delivery notes in the batch whose status is not done or
7474
canceled.
@@ -84,7 +84,7 @@ Adds to the form view of batch picking:
8484

8585
**"In progress" status:**
8686

87-
|image3|
87+
|in_progress|
8888

8989
1. Delete all pickings in the batch whose status is not done or
9090
cancelled.
@@ -102,7 +102,7 @@ validation approach in the inventory settings.
102102

103103
**In "Done" status:**
104104

105-
|image4|
105+
|done|
106106

107107
1. Print pickings.
108108
2. Smart button with counting and access to pickings.
@@ -111,10 +111,10 @@ validation approach in the inventory settings.
111111
4. Notes. Reflects the notes that have been entered from the wizard and
112112
allows you to modify them.
113113

114-
.. |image1| image:: https://raw.githubusercontent.com/OCA/stock-logistics-workflow/18.0/stock_picking_batch_extended/static/batch_wizard.png
115-
.. |image2| image:: https://raw.githubusercontent.com/OCA/stock-logistics-workflow/18.0/stock_picking_batch_extended/static/batch_form_draft.png
116-
.. |image3| image:: https://raw.githubusercontent.com/OCA/stock-logistics-workflow/18.0/stock_picking_batch_extended/static/batch_form_in_progress.png
117-
.. |image4| image:: https://raw.githubusercontent.com/OCA/stock-logistics-workflow/18.0/stock_picking_batch_extended/static/batch_form_done.png
114+
.. |wizard| image:: https://raw.githubusercontent.com/OCA/stock-logistics-workflow/18.0/stock_picking_batch_extended/static/batch_wizard.png
115+
.. |draft| image:: https://raw.githubusercontent.com/OCA/stock-logistics-workflow/18.0/stock_picking_batch_extended/static/batch_form_draft.png
116+
.. |in_progress| image:: https://raw.githubusercontent.com/OCA/stock-logistics-workflow/18.0/stock_picking_batch_extended/static/batch_form_in_progress.png
117+
.. |done| image:: https://raw.githubusercontent.com/OCA/stock-logistics-workflow/18.0/stock_picking_batch_extended/static/batch_form_done.png
118118

119119
Bug Tracker
120120
===========
@@ -164,6 +164,7 @@ Contributors
164164
- Carlos Dauden
165165
- Sergio Teruel
166166
- César A. Sánchez
167+
- Carlos Lopez
167168

168169
- `Trobz <https://trobz.com>`__:
169170

stock_picking_batch_extended/models/stock_batch_picking.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,9 @@ class StockPickingBatch(models.Model):
1010

1111
_inherit = "stock.picking.batch"
1212

13-
name = fields.Char(
14-
index=True,
15-
readonly=False, # allow edition in draft state
16-
)
13+
name = fields.Char(index=True)
1714
date = fields.Date(
1815
required=True,
19-
readonly=False, # allow edition in draft,in_progress state
2016
index=True,
2117
default=fields.Date.context_today,
2218
help="date on which the batch picking is to be processed",
@@ -42,14 +38,13 @@ class StockPickingBatch(models.Model):
4238

4339
def _compute_picking_count(self):
4440
"""Calculate number of pickings."""
45-
groups = self.env["stock.picking"].read_group(
46-
domain=[("batch_id", "in", self.ids)],
47-
fields=["batch_id"],
48-
groupby=["batch_id"],
41+
counts = dict(
42+
self.env["stock.picking"]._read_group(
43+
[("batch_id", "in", self.ids)], ["batch_id"], ["__count"]
44+
)
4945
)
50-
counts = {g["batch_id"][0]: g["batch_id_count"] for g in groups}
5146
for batch in self:
52-
batch.picking_count = counts.get(batch.id, 0)
47+
batch.picking_count = counts.get(batch, 0)
5348

5449
def action_cancel(self):
5550
"""Call action_cancel for all batches pickings
@@ -91,7 +86,7 @@ def action_picking_move_tree(self):
9186
action["views"] = [
9287
(
9388
self.env.ref("stock_picking_batch.view_picking_move_tree_inherited").id,
94-
"tree",
89+
"list",
9590
),
9691
]
9792
return action
@@ -103,7 +98,7 @@ def action_picking_move_line_tree(self):
10398
action["views"] = [
10499
(
105100
self.env.ref("stock_picking_batch_extended.view_move_line_tree").id,
106-
"tree",
101+
"list",
107102
),
108103
]
109104
ctx = self.env.context.copy()

stock_picking_batch_extended/models/stock_move.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ class StockMove(models.Model):
1010
comodel_name="stock.picking.batch",
1111
related="picking_id.batch_id",
1212
store=True,
13+
index=True,
1314
)

stock_picking_batch_extended/models/stock_move_line.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
class StockMoveLine(models.Model):
77
_inherit = "stock.move.line"
88

9-
def _add_to_wave(self, wave=False):
10-
super()._add_to_wave(wave)
9+
def _add_to_wave(self, wave=False, description=False):
10+
super()._add_to_wave(wave, description)
1111
return self.env["stock.picking.to.batch"].action_view_batch_picking(
1212
self.batch_id
1313
)

stock_picking_batch_extended/readme/CONFIGURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ deactivate which approach for batch handling will be used per company.
33
By default after installation this option will be activated for all
44
companies.
55

6-
![](../static/picking_batch_configuration_settings.png)
6+
![settings](../static/picking_batch_configuration_settings.png)

stock_picking_batch_extended/readme/CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- Carlos Dauden
2525
- Sergio Teruel
2626
- César A. Sánchez
27+
- Carlos Lopez
2728

2829
- [Trobz](https://trobz.com):
2930

stock_picking_batch_extended/readme/USAGE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
When you create a batch pick, the creation wizard will appear with the
22
new fields added.
33

4-
![](../static/batch_wizard.png)
4+
![wizard](../static/batch_wizard.png)
55

66
1. Name: Allows to rename the batch. But be careful, if this is done,
77
it overwrites the name that Odoo assigns to the batch by default.
@@ -13,7 +13,7 @@ Adds to the form view of batch picking:
1313

1414
**In "Draft" status:**
1515

16-
![](../static/batch_form_draft.png)
16+
![draft](../static/batch_form_draft.png)
1717

1818
1. Delete all delivery notes in the batch whose status is not done or
1919
canceled.
@@ -29,7 +29,7 @@ Adds to the form view of batch picking:
2929

3030
**"In progress" status:**
3131

32-
![](../static/batch_form_in_progress.png)
32+
![in_progress](../static/batch_form_in_progress.png)
3333

3434
1. Delete all pickings in the batch whose status is not done or
3535
cancelled.
@@ -47,7 +47,7 @@ validation approach in the inventory settings.
4747

4848
**In "Done" status:**
4949

50-
![](../static/batch_form_done.png)
50+
![done](../static/batch_form_done.png)
5151

5252
1. Print pickings.
5353
2. Smart button with counting and access to pickings.

stock_picking_batch_extended/report/batch_report.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
# Copyright 2018 Tecnativa - Carlos Dauden
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3-
import logging
43

54
from odoo import api, fields, models
6-
from odoo.tools.float_utils import float_is_zero
7-
8-
_logger = logging.getLogger(__name__)
95

106

117
class ReportPrintBatchPicking(models.AbstractModel):
@@ -22,8 +18,8 @@ def key_level_1(self, operation):
2218

2319
@api.model
2420
def new_level_0(self, operation):
25-
location_name = operation.location_id.name_get()[0][1]
26-
location_dest_name = operation.location_dest_id.name_get()[0][1]
21+
location_name = operation.location_id.display_name
22+
location_dest_name = operation.location_dest_id.display_name
2723
level_0_name = f"{location_name} \u21e8 {location_dest_name}"
2824
return {
2925
"name": level_0_name,
@@ -32,28 +28,17 @@ def new_level_0(self, operation):
3228
"l1_items": {},
3329
}
3430

35-
@api.model
36-
def _get_operation_qty(self, operation):
37-
return (
38-
float_is_zero(
39-
operation.reserved_qty,
40-
precision_rounding=operation.product_uom_id.rounding,
41-
)
42-
and operation.qty_done
43-
or operation.reserved_qty
44-
)
45-
4631
@api.model
4732
def new_level_1(self, operation):
4833
return {
4934
"product": operation.product_id,
50-
"product_qty": self._get_operation_qty(operation),
35+
"product_qty": operation.quantity,
5136
"operations": operation,
5237
}
5338

5439
@api.model
5540
def update_level_1(self, group_dict, operation):
56-
group_dict["product_qty"] += self._get_operation_qty(operation)
41+
group_dict["product_qty"] += operation.quantity
5742
group_dict["operations"] += operation
5843

5944
@api.model

0 commit comments

Comments
 (0)