Skip to content

Commit

Permalink
[MIG] stock_picking_mass_action: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinafernandez-tecnativa committed Nov 13, 2023
1 parent f3f6db7 commit 5706081
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 39 deletions.
3 changes: 2 additions & 1 deletion stock_picking_mass_action/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Copyright 2014 Camptocamp SA - Guewen Baconnier
# Copyright 2018 Tecnativa - Vicent Cubells
# Copyright 2019 Tecnativa - Carlos Dauden
# Copyright 2023 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Stock Picking Mass Action",
"version": "15.0.1.0.1",
"version": "16.0.1.0.0",
"author": "Camptocamp, GRAP, Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-workflow",
"license": "AGPL-3",
Expand Down
2 changes: 2 additions & 0 deletions stock_picking_mass_action/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
* Vicent Cubells
* Carlos Dauden
* Sergio Teruel
* Carolina Fernandez
* Pau Sanchez ([email protected])
3 changes: 2 additions & 1 deletion stock_picking_mass_action/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:
* Vicent Cubells
* Carlos Dauden
* Sergio Teruel</li>
* Sergio Teruel
* Carolina Fernandez</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
13 changes: 3 additions & 10 deletions stock_picking_mass_action/tests/test_mass_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def setUpClass(cls):
"picking_type_id": picking_type_out.id,
"location_id": stock_location.id,
"location_dest_id": customer_location.id,
"move_lines": [
"move_ids": [
(
0,
0,
Expand All @@ -58,19 +58,12 @@ def test_mass_action(self):
wiz_confirm.confirm = True
wiz_confirm.mass_action()
self.assertEqual(self.picking.state, "confirmed")
# We test checking availability
wiz_check = wiz.with_context(check_availability=True).create(
{"picking_ids": [(4, self.picking.id)]}
)
wiz_check.confirm = True
wiz_check.mass_action()
self.assertEqual(self.picking.state, "assigned")
# We test transferring picking
wiz_tranfer = wiz.with_context(transfer=True).create(
{"picking_ids": [(4, self.picking.id)]}
)
wiz_tranfer.confirm = True
for line in self.picking.move_lines:
for line in self.picking.move_ids:
line.quantity_done = line.product_uom_qty
wiz_tranfer.mass_action()
self.assertEqual(self.picking.state, "done")
Expand Down Expand Up @@ -103,6 +96,6 @@ def test_mass_action_backorder(self):
{"picking_ids": [(4, self.picking.id)], "confirm": True, "transfer": True}
)
self.picking.action_assign()
self.picking.move_lines[0].quantity_done = 30
self.picking.move_ids[0].quantity_done = 30
res = wiz_tranfer.mass_action()
self.assertEqual(res["res_model"], "stock.backorder.confirmation")
16 changes: 0 additions & 16 deletions stock_picking_mass_action/wizard/mass_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ class StockPickingMassAction(TransientModel):
_name = "stock.picking.mass.action"
_description = "Stock Picking Mass Action"

@api.model
def _default_check_availability(self):
return self.env.context.get("check_availability", False)

@api.model
def _default_transfer(self):
return self.env.context.get("transfer", False)
Expand All @@ -27,11 +23,6 @@ def _default_picking_ids(self):
default=True,
help="check this box if you want to mark as Todo the" " selected Pickings.",
)
check_availability = fields.Boolean(
default=lambda self: self._default_check_availability(),
help="check this box if you want to check the availability of"
" the selected Pickings.",
)
transfer = fields.Boolean(
default=lambda self: self._default_transfer(),
help="check this box if you want to transfer all the selected"
Expand All @@ -56,13 +47,6 @@ def mass_action(self):
).sorted(key=lambda r: r.scheduled_date)
draft_picking_lst.action_confirm()

# check availability if asked
if self.check_availability:
pickings_to_check = self.picking_ids.filtered(
lambda x: x.state not in ["draft", "cancel", "done"]
).sorted(key=lambda r: r.scheduled_date)
pickings_to_check.action_assign()

# Get all pickings ready to transfer and transfer them if asked
if self.transfer:
assigned_picking_lst = self.picking_ids.filtered(
Expand Down
12 changes: 1 addition & 11 deletions stock_picking_mass_action/wizard/mass_action_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<form string="Mass Action for the selected stock picking">
<group>
<field name="confirm" />
<field name="check_availability" />
<field name="transfer" />
</group>
<footer>
Expand All @@ -30,22 +29,13 @@
<field name="target">new</field>
<field name="binding_model_id" ref="stock.model_stock_picking" />
</record>
<!-- Check Availability Action -->
<record id="action_check_availability" model="ir.actions.act_window">
<field name="name">Check Availability</field>
<field name="res_model">stock.picking.mass.action</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context">{'check_availability': 1}</field>
<field name="binding_model_id" ref="stock.model_stock_picking" />
</record>
<!-- Transfer Action -->
<record id="action_transfer" model="ir.actions.act_window">
<field name="name">Transfer</field>
<field name="res_model">stock.picking.mass.action</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context">{'check_availability': 1, 'transfer': 1,}</field>
<field name="context">{'transfer': 1}</field>
<field name="binding_model_id" ref="stock.model_stock_picking" />
</record>
</odoo>

0 comments on commit 5706081

Please sign in to comment.