Skip to content

Commit

Permalink
[MIG] account_invoice_production_lot: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ioans73 committed May 9, 2024
1 parent 9cbe61d commit ad4e765
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 36 deletions.
4 changes: 2 additions & 2 deletions account_invoice_production_lot/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

{
"name": "Invoice Production Lots",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"author": "Agile Business Group," "Tecnativa," "Odoo Community Association (OCA)",
"summary": "Display delivered serial numbers in invoice",
"website": "https://github.com/OCA/account-invoice-reporting",
"license": "AGPL-3",
"category": "Accounting & Finance",
"depends": ["account", "stock_picking_invoice_link", "sale_management"],
"data": ["views/account_invoice_views.xml", "report/report_invoice.xml"],
"data": ["views/account_move_views.xml", "report/report_invoice.xml"],
"demo": ["demo/sale.xml"],
"installable": True,
}
2 changes: 1 addition & 1 deletion account_invoice_production_lot/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import account_invoice
from . import account_move_line
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ def lots_grouped_by_quantity(self):
lot_dict = defaultdict(float)
for sml in self.mapped("move_line_ids.move_line_ids"):
if sml.lot_id:
lot_dict[sml.lot_id.name] += sml.qty_done
lot_dict[sml.lot_id.name] += sml.quantity
return lot_dict
30 changes: 11 additions & 19 deletions account_invoice_production_lot/report/report_invoice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,21 @@
</t>
</t>
</xpath>
<xpath expr="//t[@name='account_invoice_line_accountable']/.." position="after">
<t
t-if="not line.display_type and lots and line.product_id.tracking == 'lot'"
<xpath expr="//td[@name='account_invoice_line_name']" position="inside">
<div
t-if="line.display_type == 'product' and lots and line.product_id.tracking == 'lot'"
name="account_invoice_line_lot"
groups="stock.group_production_lot"
>
<tr>
<td colspan="99">
<div class="row ml-1">
<div class="col">
<b class="font-italic">Serial numbers</b>
</div>
<b class="font-italic">Serial numbers</b>
<t t-foreach="lots" t-as="lot">
<div class="row ml-1 mt-1">
<div class="col">
<span t-esc="lot[0]" /> (<span t-esc="lot[1]" />)
</div>
<t t-foreach="lots" t-as="lot">
<div class="row ml-1 mt-1">
<div class="col">
<span t-esc="lot[0]" /> (<span t-esc="lot[1]" />)
</div>
</div>
</t>
</td>
</tr>
</t>
</div>
</t>
</div>
</xpath>
</template>
</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,13 @@ def setUpClass(cls):
"company_id": cls.user_company.id,
}
)
cls.location = cls.env.ref("stock.stock_location_stock")

def qty_on_hand(self, product, quantity, lot):
"""Update Product quantity."""
res = product.action_update_quantity_on_hand()
stock_quant_form = Form(
self.env["stock.quant"].with_context(**res["context"]),
view="stock.view_stock_quant_tree_inventory_editable",
self.env["stock.quant"]._update_available_quantity(
product, self.location, lot_id=lot, quantity=quantity
)
stock_quant_form.inventory_quantity = quantity
stock_quant_form.lot_id = lot
quant = stock_quant_form.save()
quant.action_apply_inventory()

def test_00_sale_stock_invoice_product_lot(self):
# update quantities with their related lots
Expand All @@ -89,8 +84,6 @@ def test_00_sale_stock_invoice_product_lot(self):
picking = self.sale.picking_ids[:1]
picking.action_confirm()
picking.action_assign()
for sml in picking.move_ids.mapped("move_line_ids"):
sml.qty_done = sml.reserved_qty
picking._action_done()
# create invoice
invoice = self.sale._create_invoices()
Expand All @@ -115,7 +108,8 @@ def test_01_sale_stock_delivery_partial_invoice_product_lot(self):
picking.action_confirm()
picking.action_assign()
# deliver partially only one lot
picking.move_ids[0].move_line_ids[0].write({"qty_done": 2.0})
picking.move_ids[0].move_line_ids[0].write({"quantity": 2.0})
picking.move_ids[0].move_line_ids[1].write({"quantity": 0.0})
backorder_wizard_dict = picking.button_validate()
backorder_wiz = Form(
self.env[backorder_wizard_dict["res_model"]].with_context(
Expand Down Expand Up @@ -145,8 +139,8 @@ def test_02_sale_stock_delivery_partial_invoice_product_lot(self):
picking.action_confirm()
picking.action_assign()
# deliver partially both lots
picking.move_ids[0].move_line_ids[0].write({"qty_done": 1.0})
picking.move_ids[0].move_line_ids[1].write({"qty_done": 1.0})
picking.move_ids[0].move_line_ids[0].write({"quantity": 1.0})
picking.move_ids[0].move_line_ids[1].write({"quantity": 1.0})
backorder_wizard_dict = picking.button_validate()
backorder_wiz = Form(
self.env[backorder_wizard_dict["res_model"]].with_context(
Expand Down

0 comments on commit ad4e765

Please sign in to comment.