Skip to content

Commit

Permalink
[IMP]l10n_it_delivery_note_batch: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PicchiSeba committed Feb 23, 2024
1 parent 578d476 commit 31f4936
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions l10n_it_delivery_note_batch/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_delivery_note_batch
46 changes: 46 additions & 0 deletions l10n_it_delivery_note_batch/tests/test_delivery_note_batch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from odoo.tests.common import TransactionCase


class TestDeliveryNoteBatch(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()

cls.StockDeliveryNote = cls.env["stock.delivery.note"]
cls.SaleOrder = cls.env["sale.order"]
cls.SaleOrderLine = cls.env["sale.order.line"]
cls.StockPickingBatch = cls.env["stock.picking.batch"]

cls.partner = cls.env.ref("base.res_partner_address_15")
cls.product = cls.env.ref(
"sale_product_configurator.product_product_1_product_template"
)
cls.env["stock.delivery.note.type"].search(
[("name", "=", "Outgoing")]
).company_id = cls.env.company

def generate_stock_picking(self):
sale_order = self.SaleOrder.create(
{
"partner_id": self.partner.id,
"order_line": [(0, 0, {"product_id": self.product.id})],
}
)
sale_order.action_confirm()
return sale_order.picking_ids

def test_stock_picking_batch(self):
picking_1 = self.generate_stock_picking()
picking_2 = self.generate_stock_picking()
pickings = picking_1 + picking_2

stock_picking_batch = self.StockPickingBatch.create(
{
"user_id": self.env.ref("base.user_demo").id,
"picking_ids": [(6, 0, pickings.ids)],
}
)
self.assertFalse(stock_picking_batch.all_pickings_have_delivery_note)
stock_picking_batch.create_delivery_notes()
stock_picking_batch._compute_all_pickings_have_delivery_note()
self.assertTrue(stock_picking_batch.all_pickings_have_delivery_note)

0 comments on commit 31f4936

Please sign in to comment.