|
| 1 | +from odoo.exceptions import UserError |
1 | 2 | from odoo.tests.common import TransactionCase
|
2 | 3 | from odoo.tools.safe_eval import safe_eval
|
3 | 4 |
|
@@ -31,6 +32,13 @@ def setUp(self):
|
31 | 32 | "picking_type_id": self.type_pick_out_id.id,
|
32 | 33 | }
|
33 | 34 | )
|
| 35 | + self.output_loc = self.env.ref("stock.stock_location_output") |
| 36 | + self.bac1 = self.env["stock.location"].create( |
| 37 | + {"name": "BAC-0001", "location_id": self.output_loc.id} |
| 38 | + ) |
| 39 | + self.bac2 = self.env["stock.location"].create( |
| 40 | + {"name": "BAC-0002", "location_id": self.output_loc.id} |
| 41 | + ) |
34 | 42 |
|
35 | 43 | def test_no_rule_no_batch(self):
|
36 | 44 | # No batch creation without rules
|
@@ -92,3 +100,35 @@ def test_cancel_batch(self):
|
92 | 100 | batch_ids[0].action_cancel()
|
93 | 101 | for move_line in move_lines:
|
94 | 102 | self.assertFalse(move_line.picking_id.batch_id)
|
| 103 | + |
| 104 | + def test_category_no_limit(self): |
| 105 | + """Product from catagory with "no order limit in box" settings |
| 106 | + can be put all in the same box, |
| 107 | + no matter the box attributed to the others products from the same order |
| 108 | + and no matter the number of order already in the destination box""" |
| 109 | + |
| 110 | + self.picking_batch.search([]).mapped(lambda r: r.action_cancel()) |
| 111 | + batch = self.rule.batch_creation(True)[0] |
| 112 | + batch[0].picking_ids.move_line_ids.mapped("product_id.categ_id").write( |
| 113 | + {"no_order_box_limit": True} |
| 114 | + ) |
| 115 | + try: |
| 116 | + for line in batch[0].picking_ids.move_line_ids: |
| 117 | + line.write({"location_dest_id": self.bac1.id}) |
| 118 | + except Exception as e: |
| 119 | + self.fail("test_category_no_limit raise unwanted error:{}".format(e)) |
| 120 | + |
| 121 | + def test_category_with_limit(self): |
| 122 | + """Product from catagory with "no order limit in box" settings |
| 123 | + can be put all in the same box, |
| 124 | + no matter the box attributed to the others products from the same order |
| 125 | + and no matter the number of order already in the destination box""" |
| 126 | + |
| 127 | + self.picking_batch.search([]).mapped(lambda r: r.action_cancel()) |
| 128 | + batch = self.rule.batch_creation(True)[0] |
| 129 | + batch[0].picking_ids.move_line_ids.mapped("product_id.categ_id").write( |
| 130 | + {"no_order_box_limit": False} |
| 131 | + ) |
| 132 | + with self.assertRaises(UserError): |
| 133 | + for line in batch[0].picking_ids.move_line_ids: |
| 134 | + line.write({"location_dest_id": self.bac1.id}) |
0 commit comments