|
8 | 8 |
|
9 | 9 |
|
10 | 10 | class TestPurchaseOrder(SavepointCase):
|
11 |
| - |
12 | 11 | @classmethod
|
13 | 12 | def setUpClass(cls):
|
14 | 13 | super(TestPurchaseOrder, cls).setUpClass()
|
15 |
| - cls.Product = cls.env['product.product'] |
16 |
| - cls.Purchase = cls.env['purchase.order'] |
17 |
| - cls.PurchaseLine = cls.env['purchase.order.line'] |
| 14 | + cls.Product = cls.env["product.product"] |
| 15 | + cls.Purchase = cls.env["purchase.order"] |
| 16 | + cls.PurchaseLine = cls.env["purchase.order.line"] |
18 | 17 |
|
19 |
| - cls.product_1 = cls.Product.create({ |
20 |
| - 'name': 'Product', |
21 |
| - 'type': 'consu', |
22 |
| - }) |
| 18 | + cls.product_1 = cls.Product.create({"name": "Product", "type": "consu"}) |
23 | 19 |
|
24 |
| - cls.partner_3 = cls.env.ref('base.res_partner_3') |
| 20 | + cls.partner_3 = cls.env.ref("base.res_partner_3") |
25 | 21 | cls.partner_3.fop_shipping = 250
|
26 | 22 |
|
27 | 23 | def test_fop_shipping_reached1(self):
|
28 |
| - po = self.Purchase.create({ |
29 |
| - 'partner_id': self.partner_3.id, |
30 |
| - }) |
31 |
| - self.PurchaseLine.create({ |
32 |
| - 'order_id': po.id, |
33 |
| - 'product_id': self.product_1.id, |
34 |
| - 'date_planned': fields.Datetime.now(), |
35 |
| - 'name': 'Test', |
36 |
| - 'product_qty': 1.0, |
37 |
| - 'product_uom': self.product_1.uom_id.id, |
38 |
| - 'price_unit': 100.0, |
39 |
| - }) |
| 24 | + po = self.Purchase.create({"partner_id": self.partner_3.id}) |
| 25 | + self.PurchaseLine.create( |
| 26 | + { |
| 27 | + "order_id": po.id, |
| 28 | + "product_id": self.product_1.id, |
| 29 | + "date_planned": fields.Datetime.now(), |
| 30 | + "name": "Test", |
| 31 | + "product_qty": 1.0, |
| 32 | + "product_uom": self.product_1.uom_id.id, |
| 33 | + "price_unit": 100.0, |
| 34 | + } |
| 35 | + ) |
40 | 36 |
|
41 | 37 | self.assertFalse(po.fop_reached)
|
42 | 38 |
|
43 | 39 | with self.assertRaises(UserError) as e, self.env.cr.savepoint():
|
44 | 40 | po.button_approve()
|
45 | 41 | self.assertTrue(
|
46 | 42 | "You cannot confirm a purchase order with amount under "
|
47 |
| - "FOP shipping" |
48 |
| - in e.exception.name |
| 43 | + "FOP shipping" in e.exception.name |
49 | 44 | )
|
50 | 45 |
|
51 | 46 | po.force_order_under_fop = True
|
52 | 47 | po.button_approve()
|
53 |
| - self.assertEqual(po.state, 'purchase') |
| 48 | + self.assertEqual(po.state, "purchase") |
54 | 49 |
|
55 | 50 | def test_fop_shipping_reached2(self):
|
56 |
| - po = self.Purchase.create({ |
57 |
| - 'partner_id': self.partner_3.id, |
58 |
| - }) |
59 |
| - self.PurchaseLine.create({ |
60 |
| - 'order_id': po.id, |
61 |
| - 'product_id': self.product_1.id, |
62 |
| - 'date_planned': fields.Datetime.now(), |
63 |
| - 'name': 'Test', |
64 |
| - 'product_qty': 10, |
65 |
| - 'product_uom': self.product_1.uom_id.id, |
66 |
| - 'price_unit': 45, |
67 |
| - }) |
| 51 | + po = self.Purchase.create({"partner_id": self.partner_3.id}) |
| 52 | + self.PurchaseLine.create( |
| 53 | + { |
| 54 | + "order_id": po.id, |
| 55 | + "product_id": self.product_1.id, |
| 56 | + "date_planned": fields.Datetime.now(), |
| 57 | + "name": "Test", |
| 58 | + "product_qty": 10, |
| 59 | + "product_uom": self.product_1.uom_id.id, |
| 60 | + "price_unit": 45, |
| 61 | + } |
| 62 | + ) |
68 | 63 |
|
69 | 64 | self.assertTrue(po.fop_reached)
|
70 | 65 | po.button_approve()
|
71 |
| - self.assertEqual(po.state, 'purchase') |
| 66 | + self.assertEqual(po.state, "purchase") |
0 commit comments