Skip to content

Commit 33392f3

Browse files
committed
[MIG] account_invoice_production_lot: Migration to 17.0
1 parent 9cbe61d commit 33392f3

File tree

6 files changed

+23
-37
lines changed

6 files changed

+23
-37
lines changed

account_invoice_production_lot/__manifest__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
{
99
"name": "Invoice Production Lots",
10-
"version": "16.0.1.0.0",
10+
"version": "17.0.1.0.0",
1111
"author": "Agile Business Group," "Tecnativa," "Odoo Community Association (OCA)",
1212
"summary": "Display delivered serial numbers in invoice",
1313
"website": "https://github.com/OCA/account-invoice-reporting",
1414
"license": "AGPL-3",
1515
"category": "Accounting & Finance",
1616
"depends": ["account", "stock_picking_invoice_link", "sale_management"],
17-
"data": ["views/account_invoice_views.xml", "report/report_invoice.xml"],
17+
"data": ["views/account_move_views.xml", "report/report_invoice.xml"],
1818
"demo": ["demo/sale.xml"],
1919
"installable": True,
2020
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
22

3-
from . import account_invoice
3+
from . import account_move_line

account_invoice_production_lot/models/account_invoice.py account_invoice_production_lot/models/account_move_line.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ def lots_grouped_by_quantity(self):
2525
lot_dict = defaultdict(float)
2626
for sml in self.mapped("move_line_ids.move_line_ids"):
2727
if sml.lot_id:
28-
lot_dict[sml.lot_id.name] += sml.qty_done
28+
lot_dict[sml.lot_id.name] += sml.quantity
2929
return lot_dict

account_invoice_production_lot/report/report_invoice.xml

+11-19
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,21 @@
1212
</t>
1313
</t>
1414
</xpath>
15-
<xpath expr="//t[@name='account_invoice_line_accountable']/.." position="after">
16-
<t
17-
t-if="not line.display_type and lots and line.product_id.tracking == 'lot'"
15+
<xpath expr="//td[@name='account_invoice_line_name']" position="inside">
16+
<div
17+
t-if="line.display_type == 'product' and lots and line.product_id.tracking == 'lot'"
1818
name="account_invoice_line_lot"
1919
groups="stock.group_production_lot"
2020
>
21-
<tr>
22-
<td colspan="99">
23-
<div class="row ml-1">
24-
<div class="col">
25-
<b class="font-italic">Serial numbers</b>
26-
</div>
21+
<b class="font-italic">Serial numbers</b>
22+
<t t-foreach="lots" t-as="lot">
23+
<div class="row ml-1 mt-1">
24+
<div class="col">
25+
<span t-esc="lot[0]" /> (<span t-esc="lot[1]" />)
2726
</div>
28-
<t t-foreach="lots" t-as="lot">
29-
<div class="row ml-1 mt-1">
30-
<div class="col">
31-
<span t-esc="lot[0]" /> (<span t-esc="lot[1]" />)
32-
</div>
33-
</div>
34-
</t>
35-
</td>
36-
</tr>
37-
</t>
27+
</div>
28+
</t>
29+
</div>
3830
</xpath>
3931
</template>
4032
</odoo>

account_invoice_production_lot/tests/test_invoice_production_lot.py

+8-14
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,13 @@ def setUpClass(cls):
6666
"company_id": cls.user_company.id,
6767
}
6868
)
69+
cls.location = cls.env.ref("stock.stock_location_stock")
6970

7071
def qty_on_hand(self, product, quantity, lot):
7172
"""Update Product quantity."""
72-
res = product.action_update_quantity_on_hand()
73-
stock_quant_form = Form(
74-
self.env["stock.quant"].with_context(**res["context"]),
75-
view="stock.view_stock_quant_tree_inventory_editable",
73+
self.env["stock.quant"]._update_available_quantity(
74+
product, self.location, lot_id=lot, quantity=quantity
7675
)
77-
stock_quant_form.inventory_quantity = quantity
78-
stock_quant_form.lot_id = lot
79-
quant = stock_quant_form.save()
80-
quant.action_apply_inventory()
8176

8277
def test_00_sale_stock_invoice_product_lot(self):
8378
# update quantities with their related lots
@@ -89,9 +84,7 @@ def test_00_sale_stock_invoice_product_lot(self):
8984
picking = self.sale.picking_ids[:1]
9085
picking.action_confirm()
9186
picking.action_assign()
92-
for sml in picking.move_ids.mapped("move_line_ids"):
93-
sml.qty_done = sml.reserved_qty
94-
picking._action_done()
87+
picking.button_validate()
9588
# create invoice
9689
invoice = self.sale._create_invoices()
9790
self.assertEqual(len(invoice.invoice_line_ids), 2)
@@ -115,7 +108,8 @@ def test_01_sale_stock_delivery_partial_invoice_product_lot(self):
115108
picking.action_confirm()
116109
picking.action_assign()
117110
# deliver partially only one lot
118-
picking.move_ids[0].move_line_ids[0].write({"qty_done": 2.0})
111+
picking.move_ids[0].move_line_ids[0].write({"quantity": 2.0})
112+
picking.move_ids[0].move_line_ids[1].write({"quantity": 0.0})
119113
backorder_wizard_dict = picking.button_validate()
120114
backorder_wiz = Form(
121115
self.env[backorder_wizard_dict["res_model"]].with_context(
@@ -145,8 +139,8 @@ def test_02_sale_stock_delivery_partial_invoice_product_lot(self):
145139
picking.action_confirm()
146140
picking.action_assign()
147141
# deliver partially both lots
148-
picking.move_ids[0].move_line_ids[0].write({"qty_done": 1.0})
149-
picking.move_ids[0].move_line_ids[1].write({"qty_done": 1.0})
142+
picking.move_ids[0].move_line_ids[0].write({"quantity": 1.0})
143+
picking.move_ids[0].move_line_ids[1].write({"quantity": 1.0})
150144
backorder_wizard_dict = picking.button_validate()
151145
backorder_wiz = Form(
152146
self.env[backorder_wizard_dict["res_model"]].with_context(

0 commit comments

Comments
 (0)