Skip to content

Commit

Permalink
[MIG] stock_quant_manual_assign: Migration to 14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fanha99 authored and alexis-via committed Oct 29, 2022
1 parent 81e6d0d commit e62d147
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 20 deletions.
8 changes: 6 additions & 2 deletions stock_quant_manual_assign/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{
"name": "Stock - Manual Quant Assignment",
"version": "13.0.1.0.0",
"version": "14.0.1.0.0",
"category": "Warehouse",
"license": "AGPL-3",
"author": "AvanzOSC, "
Expand All @@ -17,6 +17,10 @@
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"depends": ["stock"],
"data": ["wizard/assign_manual_quants_view.xml", "views/stock_move_view.xml"],
"data": [
"wizard/assign_manual_quants_view.xml",
"views/stock_move_view.xml",
"security/ir.model.access.csv",
],
"installable": True,
}
3 changes: 3 additions & 0 deletions stock_quant_manual_assign/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_assign_manual_quants_user,access_assign_manual_quants,model_assign_manual_quants,stock.group_stock_user,1,1,1,1
access_assign_manual_quants_lines_user,access_assign_manual_quants_lines,model_assign_manual_quants_lines,stock.group_stock_user,1,1,1,1
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ def test_quant_manual_assign(self):
self.assertEqual(wizard.move_qty, 250.0)
wizard.assign_quants()
self.assertAlmostEqual(
len(self.move.move_line_ids), len(wizard.quants_lines.filtered("selected"))
len(self.move.move_line_ids),
2,
"There are 2 quants selected",
)

def test_quant_assign_wizard_after_availability_check(self):
Expand Down
2 changes: 1 addition & 1 deletion stock_quant_manual_assign/views/stock_move_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
name="%(assign_manual_quants_action)d"
type="action"
icon="fa-tags"
string="Manual Quants"
title="Manual Quants"
options='{"warn": true}'
attrs="{'invisible':['|',('picking_code','=','incoming'),('state','not in',('confirmed','assigned','partially_available'))]}"
/>
Expand Down
22 changes: 14 additions & 8 deletions stock_quant_manual_assign/wizard/assign_manual_quants.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ def _compute_qties(self):
quants_lines = fields.One2many(
"assign.manual.quants.lines", "assign_wizard", string="Quants"
)
move_id = fields.Many2one(comodel_name="stock.move", string="Move",)
move_id = fields.Many2one(
comodel_name="stock.move",
string="Move",
)

def assign_quants(self):
move = self.move_id
Expand All @@ -76,7 +79,7 @@ def default_get(self, fields):
("quantity", ">", 0),
]
)
quants_lines = []
q_lines = []
for quant in available_quants:
line = {
"quant_id": quant.id,
Expand All @@ -98,10 +101,8 @@ def default_get(self, fields):
line["qty"] = sum(move_lines.mapped("product_uom_qty"))
line["selected"] = bool(line["qty"])
line["reserved"] = quant.reserved_quantity - line["qty"]
quants_lines.append(line)
res.update(
{"quants_lines": [(0, 0, x) for x in quants_lines], "move_id": move.id}
)
q_lines.append(line)
res.update({"quants_lines": [(0, 0, x) for x in q_lines], "move_id": move.id})
return res


Expand All @@ -117,7 +118,10 @@ class AssignManualQuantsLines(models.TransientModel):
ondelete="cascade",
)
quant_id = fields.Many2one(
comodel_name="stock.quant", string="Quant", required=True, ondelete="cascade",
comodel_name="stock.quant",
string="Quant",
required=True,
ondelete="cascade",
)
location_id = fields.Many2one(
comodel_name="stock.location",
Expand Down Expand Up @@ -145,7 +149,9 @@ class AssignManualQuantsLines(models.TransientModel):
)
# This is not correctly shown as related or computed, so we make it regular
on_hand = fields.Float(
readonly=True, string="On Hand", digits="Product Unit of Measure",
readonly=True,
string="On Hand",
digits="Product Unit of Measure",
)
reserved = fields.Float(string="Others Reserved", digits="Product Unit of Measure")
selected = fields.Boolean(string="Select")
Expand Down
17 changes: 9 additions & 8 deletions stock_quant_manual_assign/wizard/assign_manual_quants_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<field name='quants_lines' colspan="4">
<tree editable="top" delete="0" create="0">
<field name="lot_id" />
<field name="quant_id" invisible="1" />
<field name="package_id" />
<field name="owner_id" />
<field name="location_id" />
Expand Down Expand Up @@ -43,12 +44,12 @@
</form>
</field>
</record>
<act_window
name="Manual assignment"
res_model="assign.manual.quants"
binding_model="stock.move"
view_mode="form"
target="new"
id="assign_manual_quants_action"
/>

<record id="assign_manual_quants_action" model="ir.actions.act_window">
<field name="name">Manual assignment</field>
<field name="res_model">assign.manual.quants</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context">{}</field>
</record>
</odoo>

0 comments on commit e62d147

Please sign in to comment.