Skip to content

Commit 82374ac

Browse files
committed
[MIG] stock_move_line_expiration_date_required: Migration to 18.0
1 parent 63f250d commit 82374ac

File tree

6 files changed

+26
-24
lines changed

6 files changed

+26
-24
lines changed

stock_move_line_expiration_date_required/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "Stock Move Line Expiration Date Required",
55
"Summary": "Expiration date is required to enter manually on Move Lines.",
6-
"version": "16.0.1.0.2",
6+
"version": "18.0.1.0.0",
77
"author": "Moduon, Odoo Community Association (OCA)",
88
"website": "https://github.com/OCA/stock-logistics-workflow",
99
"category": "Warehouse Management",

stock_move_line_expiration_date_required/models/stock_move.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def _compute_all_expiry_dates_set(self):
1717
"""Check if all move lines have an expiration date set."""
1818
for record in self:
1919
record.all_expiry_dates_set = not record.use_expiration_date or all(
20-
record.move_line_ids.filtered("qty_done").mapped("expiration_date")
20+
record.move_line_ids.filtered("quantity").mapped("expiration_date")
2121
)
2222

2323
def _generate_serial_move_line_commands(self, lot_names, origin_move_line=None):

stock_move_line_expiration_date_required/models/stock_picking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def _sanity_check(self, separate_pickings=True):
1515
move_lines = self.env["stock.move.line"].browse()
1616
for move in picking.move_ids:
1717
# For assigned moves
18-
move_lines |= move._get_move_lines()
18+
move_lines |= move.move_line_ids
1919
move_lines_wo_expiration_date = move_lines.filtered_domain(
2020
[
2121
("use_expiration_date", "=", True),

stock_move_line_expiration_date_required/tests/test_expiration_date_required.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def setUpClass(cls):
1515
cls.product = cls.env["product.product"].create(
1616
{
1717
"name": "Test Expiration Product",
18-
"type": "product",
18+
"type": "consu",
1919
"use_expiration_date": True,
2020
"expiration_time": 0,
2121
"tracking": "lot",
@@ -39,11 +39,11 @@ def test_expiration_date_required_and_not_auto_calculated(self):
3939
view="stock.view_stock_move_operations",
4040
)
4141
with self.assertRaisesRegex(
42-
AssertionError, "expiration_date is a required field"
42+
AssertionError, "'expiration_date' is a required field"
4343
):
44-
with move_form.move_line_ids.new() as move_line_tree:
44+
with move_form.move_line_ids.edit(0) as move_line_tree:
4545
move_line_tree.lot_name = "TLE1"
46-
move_line_tree.qty_done = 1
46+
move_line_tree.quantity = 1
4747
self.assertEqual(move_line_tree.expiration_date, False)
4848

4949
def test_expiration_date_auto_caulculated(self):
@@ -55,9 +55,9 @@ def test_expiration_date_auto_caulculated(self):
5555
self.picking.move_ids_without_package,
5656
view="stock.view_stock_move_operations",
5757
)
58-
with move_form.move_line_ids.new() as move_line_tree:
58+
with move_form.move_line_ids.edit(0) as move_line_tree:
5959
move_line_tree.lot_name = "TLE2"
60-
move_line_tree.qty_done = 1
60+
move_line_tree.quantity = 1
6161
self.assertNotEqual(move_line_tree.expiration_date, False)
6262
move_form.save()
6363

@@ -76,9 +76,8 @@ def test_expiration_date_generate_serials(self):
7676
picking.action_confirm()
7777
# Prepare serial generation
7878
move = picking.move_ids_without_package
79-
move.next_serial = "001"
8079
move.next_serial_count = move.product_uom_qty
81-
picking.move_ids_without_package._generate_serial_numbers()
80+
picking.move_ids_without_package._generate_serial_numbers("001")
8281
# Check expiration date is empty
8382
for move_line in picking.move_line_ids:
8483
self.assertEqual(move_line.expiration_date, False)
@@ -95,9 +94,9 @@ def test_lot_no_expiration_date(self):
9594
self.picking.move_ids_without_package,
9695
view="stock.view_stock_move_operations",
9796
)
98-
with move_form.move_line_ids.new() as move_line_tree:
97+
with move_form.move_line_ids.edit(0) as move_line_tree:
9998
move_line_tree.lot_name = "TLE3"
100-
move_line_tree.qty_done = 10
99+
move_line_tree.quantity = 10
101100
move_form.save()
102101
self.picking.with_context(skip_sanity_check=False).button_validate()
103102

@@ -116,7 +115,6 @@ def test_serials_no_expiration_date(self):
116115
picking.action_confirm()
117116
# Prepare serial generation
118117
move = picking.move_ids_without_package
119-
move.next_serial = "001"
120118
move.next_serial_count = move.product_uom_qty
121-
picking.move_ids_without_package._generate_serial_numbers()
119+
picking.move_ids_without_package._generate_serial_numbers("001")
122120
picking.with_context(skip_sanity_check=False).button_validate()

stock_move_line_expiration_date_required/views/stock_move_line_view.xml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@
99
/>
1010
<field name="arch" type="xml">
1111
<xpath expr="//field[@name='expiration_date']" position="attributes">
12-
<attribute name="attrs">{
13-
'column_invisible': ['|', ('parent.use_expiration_date', '!=', True), ('parent.picking_code', '!=', 'incoming')],
14-
'readonly': [('picking_type_use_existing_lots', '=', True)],
15-
'required': [('parent.use_expiration_date', '=', True), ('parent.picking_code', '=', 'incoming')]
16-
}</attribute>
12+
<attribute name="column_invisible">
13+
not parent.use_expiration_date or parent.picking_code != 'incoming'
14+
</attribute>
15+
<attribute name="readonly">
16+
picking_type_use_existing_lots
17+
</attribute>
18+
<attribute name="required">
19+
parent.use_expiration_date and parent.picking_code == 'incoming'
20+
</attribute>
1721
</xpath>
1822
</field>
1923
</record>

stock_move_line_expiration_date_required/views/stock_move_view.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<odoo>
3-
<record id="view_stock_move_nosuggest_operations" model="ir.ui.view">
4-
<field name="name">stock.move.operations.nosuggest.form</field>
3+
<record id="view_stock_move_operations" model="ir.ui.view">
4+
<field name="name">stock.move.form</field>
55
<field name="model">stock.move</field>
6-
<field name="inherit_id" ref="stock.view_stock_move_nosuggest_operations" />
6+
<field name="inherit_id" ref="stock.view_stock_move_operations" />
77
<field name="arch" type="xml">
88
<xpath expr="//form/*[1]" position="before">
99
<field name="all_expiry_dates_set" invisible="1" />
1010
<div
1111
class="alert alert-warning"
1212
role="alert"
13-
attrs="{'invisible': [('all_expiry_dates_set', '=', True)]}"
13+
invisible="all_expiry_dates_set"
1414
>
1515
You won't be able to confirm the parent picking until all Expiry dates are set
1616
</div>

0 commit comments

Comments
 (0)