Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion despatch_advice_import/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ To use this module, you need to:
Known issues / Roadmap
======================

* ...


Bug Tracker
===========
Expand Down
3 changes: 1 addition & 2 deletions despatch_advice_import/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# -*- coding: utf-8 -*-

from . import wizard
from . import wizard
24 changes: 12 additions & 12 deletions despatch_advice_import/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
'name': 'Despatch Advice Import',
'summary': """
Despatch Advice import""",
'version': '10.0.1.0.0',
'license': 'AGPL-3',
'author': 'ACSONE SA/NV,Odoo Community Association (OCA)',
'depends': ['purchase', 'base_business_document_import_stock'
"name": "Despatch Advice Import",
"summary": "Despatch Advice import",
"version": "10.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"depends": [
"purchase",
"base_business_document_import_stock",
],
'data': [
'wizard/despatch_advice_import.xml',
"data": [
"wizard/despatch_advice_import.xml",
],
'demo': [
],
'installable': True,
"demo": [],
"installable": True,
}
2 changes: 1 addition & 1 deletion despatch_advice_import/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import test_despatch_advice_import
from . import test_despatch_advice_import
95 changes: 34 additions & 61 deletions despatch_advice_import/tests/test_despatch_advice_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def setUpClass(cls):

cls.DespatchAdviceImport = cls.env["despatch.advice.import"]


def order_line_to_data(self, order_line, qty=None, backorder_qty=None):
return {
"backorder_qty": backorder_qty,
Expand All @@ -126,7 +125,7 @@ def _get_base_data(self):
@classmethod
def _add_procurements(cls, line, qties):
for qty in qties:
cls.env['procurement.order'].create(
cls.env["procurement.order"].create(
{
"name": "Test",
"product_id": line.product_id.id,
Expand All @@ -137,7 +136,6 @@ def _add_procurements(cls, line, qties):
}
)


def test_00(self):
"""
Data:
Expand All @@ -162,32 +160,27 @@ def test_01(self):
data = self._get_base_data()
confirmed_qty = self.line1.product_qty - 21
data["lines"] = [
self.order_line_to_data(
self.line1, qty=confirmed_qty, backorder_qty=21
),
self.order_line_to_data(self.line1, qty=confirmed_qty, backorder_qty=21),
self.order_line_to_data(self.line2),
self.order_line_to_data(self.line3),
self.order_line_to_data(self.line4)
self.order_line_to_data(self.line4),
]
self.DespatchAdviceImport.process_data(data)

self.assertTrue(self.purchase_order.picking_ids)
move_ids = self.line1.move_ids
self.assertEqual(len(move_ids), 2)
self.assertEqual(
sum(move_ids.mapped("product_qty")), self.line1.product_qty
self.assertEqual(sum(move_ids.mapped("product_qty")), self.line1.product_qty)
assigned = move_ids.filtered(
lambda s: s.state == "assigned" and s.product_qty == 3
)
assigned = move_ids.filtered(lambda s: s.state == "assigned" and s.product_qty == 3)
self.assertEqual(assigned.product_qty, confirmed_qty)

move_backorder = move_ids.filtered(
lambda s: s.state == "assigned" and s.product_qty == 21
)
self.assertTrue(move_backorder)
self.assertEqual(
move_backorder.picking_id.backorder_id, assigned.picking_id
)

self.assertEqual(move_backorder.picking_id.backorder_id, assigned.picking_id)

def test_02(self):
"""
Expand All @@ -196,21 +189,17 @@ def test_02(self):
data = self._get_base_data()
confirmed_qty = self.line1.product_qty - 21
data["lines"] = [
self.order_line_to_data(
self.line1, qty=confirmed_qty
),
self.order_line_to_data(self.line1, qty=confirmed_qty),
self.order_line_to_data(self.line2),
self.order_line_to_data(self.line3),
self.order_line_to_data(self.line4)
self.order_line_to_data(self.line4),
]
self.DespatchAdviceImport.process_data(data)

self.assertTrue(self.purchase_order.picking_ids)
move_ids = self.line1.move_ids
self.assertEqual(len(move_ids), 2)
self.assertEqual(
sum(move_ids.mapped("product_qty")), self.line1.product_qty
)
self.assertEqual(sum(move_ids.mapped("product_qty")), self.line1.product_qty)
assigned = move_ids.filtered(lambda s: s.state == "assigned")
self.assertEqual(assigned.product_qty, confirmed_qty)
cancel = move_ids.filtered(lambda s: s.state == "cancel")
Expand All @@ -235,9 +224,9 @@ def test_03(self):
backorder_qty=3,
),
self.order_line_to_data(self.line3),
self.order_line_to_data(self.line4)
self.order_line_to_data(self.line4),
]

self.DespatchAdviceImport.process_data(data)
self.assertEqual(self.purchase_order.state, "purchase")
self.assertEqual(len(self.purchase_order.picking_ids), 2)
Expand All @@ -248,8 +237,7 @@ def test_03(self):
sum(line1_move_ids.mapped("product_qty")), self.line1.product_qty
)
move_confirmed = line1_move_ids.filtered(
lambda s: s.state == "assigned"
and s.product_qty == line1_confirmed_qty
lambda s: s.state == "assigned" and s.product_qty == line1_confirmed_qty
)
self.assertTrue(move_confirmed)
self.assertEqual(move_confirmed.product_qty, line1_confirmed_qty)
Expand All @@ -258,7 +246,8 @@ def test_03(self):
)
self.assertTrue(move_backorder)
self.assertEqual(
move_backorder.picking_id.backorder_id, move_confirmed.picking_id,
move_backorder.picking_id.backorder_id,
move_confirmed.picking_id,
)
# line2
line2_move_ids = self.line2.move_ids
Expand All @@ -267,8 +256,7 @@ def test_03(self):
sum(line2_move_ids.mapped("product_qty")), self.line2.product_qty
)
move_confirmed = line2_move_ids.filtered(
lambda s: s.state == "assigned"
and s.product_qty == line2_confirmed_qty
lambda s: s.state == "assigned" and s.product_qty == line2_confirmed_qty
)
self.assertTrue(move_confirmed)
self.assertEqual(move_confirmed.product_qty, line2_confirmed_qty)
Expand All @@ -278,13 +266,12 @@ def test_03(self):
)
self.assertTrue(move_backorder)
self.assertEqual(
move_backorder.picking_id.backorder_id, move_confirmed.picking_id,
move_backorder.picking_id.backorder_id,
move_confirmed.picking_id,
)


def test_04(self):
"""
"""
""""""
data = self._get_base_data()
confirmed_qty = self.line1.product_qty - 3
data["lines"] = [
Expand All @@ -295,15 +282,13 @@ def test_04(self):
),
self.order_line_to_data(self.line2),
self.order_line_to_data(self.line3),
self.order_line_to_data(self.line4)
self.order_line_to_data(self.line4),
]
self.DespatchAdviceImport.process_data(data)
self.assertEqual(len(self.purchase_order.picking_ids), 2)
move_ids = self.line1.move_ids
self.assertEqual(len(move_ids), 3)
self.assertEqual(
sum(move_ids.mapped("product_qty")), self.line1.product_qty
)
self.assertEqual(sum(move_ids.mapped("product_qty")), self.line1.product_qty)
move_confirmed = move_ids.filtered(
lambda s: s.state == "assigned" and s.product_qty == confirmed_qty
)
Expand All @@ -313,44 +298,37 @@ def test_04(self):
)
self.assertTrue(move_cancel)
self.assertEqual(
_("No backorder planned by the supplier."), move_cancel.note,
_("No backorder planned by the supplier."),
move_cancel.note,
)
move_backorder = move_ids.filtered(
lambda s: s.state == "assigned" and s.product_qty == 2
)
self.assertTrue(move_backorder)
self.assertEqual(
move_backorder.picking_id.backorder_id, move_confirmed.picking_id,
move_backorder.picking_id.backorder_id,
move_confirmed.picking_id,
)

def test_05(self):
"""

"""
""""""
data = self._get_base_data()
confirmed_qty = 6
data["lines"] = [
self.order_line_to_data(self.line1),
self.order_line_to_data(self.line2),
self.order_line_to_data(self.line3,
qty=confirmed_qty,
backorder_qty=3
),
self.order_line_to_data(self.line4)
self.order_line_to_data(self.line3, qty=confirmed_qty, backorder_qty=3),
self.order_line_to_data(self.line4),
]
self.DespatchAdviceImport.process_data(data)
self.assertEqual(len(self.purchase_order.picking_ids), 2)
move_ids = self.line3.move_ids
self.assertEqual(len(move_ids), 4)
self.assertEqual(
sum(move_ids.mapped("product_qty")), self.line3.product_qty
)
self.assertEqual(sum(move_ids.mapped("product_qty")), self.line3.product_qty)
moves_confirmed = move_ids.filtered(
lambda s: s.state == "assigned" and not s.picking_id.backorder_id
)
self.assertEqual(
sum(moves_confirmed.mapped("product_qty")), confirmed_qty
)
self.assertEqual(sum(moves_confirmed.mapped("product_qty")), confirmed_qty)

move_cancel = move_ids.filtered(
lambda s: s.state == "cancel" and s.product_qty == 6
Expand All @@ -365,10 +343,8 @@ def test_05(self):
moves_confirmed[0].picking_id,
)


def test_06(self):
"""
"""
""""""
data = self._get_base_data()
confirmed_qty = 3
data["lines"] = [
Expand All @@ -384,9 +360,7 @@ def test_06(self):
self.DespatchAdviceImport.process_data(data)
self.assertEqual(len(self.purchase_order.picking_ids), 2)
move_ids = self.line4.move_ids
self.assertEqual(
sum(move_ids.mapped("product_qty")), self.line4.product_qty
)
self.assertEqual(sum(move_ids.mapped("product_qty")), self.line4.product_qty)
moves_confirmed = move_ids.filtered(
lambda s: s.state == "assigned" and not s.picking_id.backorder_id
)
Expand All @@ -400,4 +374,3 @@ def test_06(self):
lambda s: s.state == "assigned" and s.picking_id.backorder_id
)
self.assertEqual(sum(moves_backorder.mapped("product_qty")), 3)

2 changes: 1 addition & 1 deletion despatch_advice_import/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import despatch_advice_import
from . import despatch_advice_import
Loading