Skip to content

Commit

Permalink
Fix error when creating stock moves manually
Browse files Browse the repository at this point in the history
  • Loading branch information
astirpe committed Oct 15, 2024
1 parent 254e49d commit 3b3c057
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions stock_lot_on_hand_first/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from . import stock_move
from . import stock_move_line
from . import stock_picking
from . import stock_picking_type
from . import stock_lot
12 changes: 12 additions & 0 deletions stock_lot_on_hand_first/models/stock_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2024 360ERP (<https://www.360erp.com>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from odoo import fields, models


class StockMoveLine(models.Model):
_inherit = "stock.move.line"

display_lots_on_hand_first = fields.Boolean(
related="move_id.display_lots_on_hand_first",
)
10 changes: 8 additions & 2 deletions stock_lot_on_hand_first/views/stock_move_line.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
<field name="model">stock.move.line</field>
<field name="inherit_id" ref="stock.view_stock_move_line_operation_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='lot_id']" position="after">
<field name="display_lots_on_hand_first" column_invisible="True" />
</xpath>
<xpath expr="//field[@name='lot_id']" position="attributes">
<attribute
name="context"
operation="update"
>{'name_search_qty_on_hand_first': parent.display_lots_on_hand_first}</attribute>
>{'name_search_qty_on_hand_first': display_lots_on_hand_first}</attribute>
</xpath>
</field>
</record>
Expand All @@ -27,11 +30,14 @@
ref="stock.view_stock_move_line_detailed_operation_tree"
/>
<field name="arch" type="xml">
<xpath expr="//field[@name='lot_id']" position="after">
<field name="display_lots_on_hand_first" column_invisible="True" />
</xpath>
<xpath expr="//field[@name='lot_id']" position="attributes">
<attribute
name="context"
operation="update"
>{'name_search_qty_on_hand_first': parent.display_lots_on_hand_first}</attribute>
>{'name_search_qty_on_hand_first': display_lots_on_hand_first}</attribute>
</xpath>
</field>
</record>
Expand Down

0 comments on commit 3b3c057

Please sign in to comment.