Skip to content

Commit

Permalink
[MIG] stock_change_qty_reason: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JasminSForgeFlow committed Sep 18, 2024
1 parent 5bcc748 commit 180027a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 55 deletions.
2 changes: 1 addition & 1 deletion stock_change_qty_reason/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"author": "ACSONE SA/NV, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"category": "Warehouse Management",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"depends": ["stock"],
"data": [
Expand Down
11 changes: 9 additions & 2 deletions stock_change_qty_reason/models/stock_quant.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ def _get_inventory_fields_write(self):
res.extend(["reason", "preset_reason_id"])
return res

def _get_inventory_move_values(self, qty, location_id, location_dest_id, out=False):
def _get_inventory_move_values(
self,
qty,
location_id,
location_dest_id,
package_id=False,
package_dest_id=False,
):
# Called when user manually set a new quantity (via `inventory_quantity`)
res = super()._get_inventory_move_values(
qty, location_id, location_dest_id, out
qty, location_id, location_dest_id, package_id, package_dest_id
)
# Aftect the reason to the move line
context = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class TestStockQuantityChangeReason(TransactionCase):
@classmethod
def setUpClass(cls):
super(TestStockQuantityChangeReason, cls).setUpClass()
super().setUpClass()

# MODELS
cls.stock_move_line = cls.env["stock.move.line"]
Expand Down
21 changes: 6 additions & 15 deletions stock_change_qty_reason/views/base_config_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,12 @@
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="stock.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@id='production_lot_info']" position='after'>
<h2>Inventory Adjustment</h2>
<div class="row mt16 o_settings_container">
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="group_qty_reason_preset" />
</div>
<div class="o_setting_right_pane">
<label for="group_qty_reason_preset" />
<div class="text-muted">
Manage predefined change quantity reasons
</div>
</div>
</div>
</div>
<xpath expr="//block[@id='production_lot_info']" position='after'>
<block title="Inventory Adjustment" name="inventory_adjustment">
<setting title="Manage predefined change quantity reasons">
<field name="group_qty_reason_preset" />
</setting>
</block>
</xpath>
</field>
</record>
Expand Down
20 changes: 4 additions & 16 deletions stock_change_qty_reason/views/stock_move_line_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,16 @@
<field name="inherit_id" ref="stock.view_move_line_tree" />
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="reason" />
</field>
</field>
</record>
<record id="preset_reason_view_move_line_tree" model="ir.ui.view">
<field name="name">stock.move.line.tree</field>
<field name="model">stock.move.line</field>
<field name="inherit_id" ref="reason_view_move_line_tree" />
<field name="priority">99</field>
<field name="arch" type="xml">
<field name="reason" position="after">
<field
name="reason"
groups="!stock_change_qty_reason.group_qty_reason_preset"
/>
<field
name="preset_reason_id"
string="Reason"
groups="stock_change_qty_reason.group_qty_reason_preset"
/>
</field>
<xpath expr="//field[@name='reason']" position="attributes">
<t groups="stock_change_qty_reason.group_qty_reason_preset">
<attribute name="invisible">True</attribute>
</t>
</xpath>
</field>
</record>
</odoo>
24 changes: 4 additions & 20 deletions stock_change_qty_reason/views/stock_quant_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<!-- Copyright 2019-2023 ForgeFlow S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>

<record id="reason_view_stock_quant_tree_inventory_editable" model="ir.ui.view">
<field name="name">stock.quant.tree</field>
<field name="model">stock.quant</field>
Expand All @@ -10,32 +11,15 @@
<button name="action_inventory_history" position="before">
<field
name="reason"
attrs="{'invisible': [('inventory_quantity_set', '=', False)]}"
invisible="not inventory_quantity_set"
groups="!stock_change_qty_reason.group_qty_reason_preset"
/>
</button>
</field>
</record>
<record id="reason_stock_inventory_line_tree_reason_id" model="ir.ui.view">
<field name="name">stock.quant.tree.reason.code</field>
<field name="model">stock.quant</field>
<field
name="inherit_id"
ref="reason_view_stock_quant_tree_inventory_editable"
/>
<field name="priority">99</field>
<field name="arch" type="xml">
<field name="reason" position="after">
<field
name="preset_reason_id"
string="Reason"
groups="stock_change_qty_reason.group_qty_reason_preset"
/>
</field>
<xpath expr="//field[@name='reason']" position="attributes">
<t groups="stock_change_qty_reason.group_qty_reason_preset">
<attribute name="invisible">True</attribute>
</t>
</xpath>
</button>
</field>
</record>
</odoo>

0 comments on commit 180027a

Please sign in to comment.