diff options
| author | Mitali Patel <mpa@odoo.com> | 2019-07-08 11:10:45 +0000 |
|---|---|---|
| committer | Simon Lejeune <sle@openerp.com> | 2020-03-05 14:31:13 +0000 |
| commit | 6f247d799a5e15ca0e6d3ea77f3cb378b1c92e8a (patch) | |
| tree | 841dbde12d9de7bd3cabb3b6b9cb17e03134f04d /addons/purchase_stock/tests | |
| parent | ffc6fe1704b748b03cdd66d81e54b202a4128c6f (diff) | |
[IMP] stock, sale_stock, mrp, purchase_stock: transfer the custom variant information
Allow to propagate custom information to upper document. It could be
usefull in many buisness that do custom stuff for people
(t-shirt with user defined text, poster with own pictures...)
The customes values are pass throught procurements'values and are
display on MO or purchase order line.
Task: 1970476
Diffstat (limited to 'addons/purchase_stock/tests')
| -rw-r--r-- | addons/purchase_stock/tests/common.py | 6 | ||||
| -rw-r--r-- | addons/purchase_stock/tests/test_purchase_lead_time.py | 51 |
2 files changed, 57 insertions, 0 deletions
diff --git a/addons/purchase_stock/tests/common.py b/addons/purchase_stock/tests/common.py index 99917378ff1..feada30badc 100644 --- a/addons/purchase_stock/tests/common.py +++ b/addons/purchase_stock/tests/common.py @@ -35,6 +35,12 @@ class PurchaseTestCommon(TestStockCommon): 'route_ids': [(6, 0, [cls.route_buy, cls.route_mto])], 'seller_ids': [(0, 0, {'name': cls.partner_1.id, 'delay': 5})]}) + cls.t_shirt = cls.env['product.product'].create({ + 'name': 'T-shirt', + 'route_ids': [(6, 0, [cls.route_buy, cls.route_mto])], + 'seller_ids': [(0, 0, {'name': cls.partner_1.id, 'delay': 5})] + }) + # Update product_2 with type, route and Delivery Lead Time cls.product_2.write({ 'type': 'product', diff --git a/addons/purchase_stock/tests/test_purchase_lead_time.py b/addons/purchase_stock/tests/test_purchase_lead_time.py index 45d29ce71f2..2706527dd78 100644 --- a/addons/purchase_stock/tests/test_purchase_lead_time.py +++ b/addons/purchase_stock/tests/test_purchase_lead_time.py @@ -242,6 +242,57 @@ class TestPurchaseLeadTime(PurchaseTestCommon): self.assertEqual(po_line[0].product_qty, 10, 'the purchase order line has a wrong quantity') self.assertEqual(po_line[1].product_qty, 5, 'the purchase order line has a wrong quantity') + def test_merge_po_line_3(self): + """Chage merging po line if same procurement is done depending on + propagate_date, propagate_date_minimum_delta and custom values. + """ + # Create procurement order of product_1 + ProcurementGroup = self.env['procurement.group'] + procurement_values = { + 'warehouse_id': self.warehouse_1, + 'rule_id': self.warehouse_1.buy_pull_id, + 'date_planned': fields.Datetime.to_string(fields.datetime.now() + timedelta(days=10)), + 'group_id': False, + 'route_ids': [], + } + + procurement_values['product_description_variants'] = '[{"color": "Red"}]' + procurement_values['description'] = "T-shirt (Red)" + order_1_values = procurement_values + ProcurementGroup.run([self.env['procurement.group'].Procurement( + self.t_shirt, 5, self.uom_unit, self.warehouse_1.lot_stock_id, + self.t_shirt.name, '/', self.env.company, order_1_values) + ]) + purchase_order = self.env['purchase.order.line'].search([('product_id', '=', self.t_shirt.id)], limit=1).order_id + self.assertEqual(len(purchase_order.order_line), 1, 'wrong number of order line is created') + + procurement_values['product_description_variants'] = '[{"color": "Red"}]' + order_2_values = procurement_values + ProcurementGroup.run([self.env['procurement.group'].Procurement( + self.t_shirt, 10, self.uom_unit, self.warehouse_1.lot_stock_id, + self.t_shirt.name, '/', self.env.company, order_2_values) + ]) + self.env['procurement.group'].run_scheduler() + self.assertEqual(len(purchase_order.order_line), 1, 'line with same custom value should be merged') + self.assertEqual(purchase_order.order_line[0].product_qty, 15, 'line with same custom value should be merged and qty should be update') + + procurement_values['product_description_variants'] = '[{"color": "Green"}]' + procurement_values['description'] = "T-shirt (Green)" + + order_3_values = procurement_values + ProcurementGroup.run([self.env['procurement.group'].Procurement( + self.t_shirt, 10, self.uom_unit, self.warehouse_1.lot_stock_id, + self.t_shirt.name, '/', self.env.company, order_3_values) + ]) + self.assertEqual(len(purchase_order.order_line), 2, 'line with different custom value should not be merged') + self.assertEqual(purchase_order.order_line.filtered(lambda x: x.product_qty == 15).name, "T-shirt (Red)", 'wrong description in po lines') + self.assertEqual(purchase_order.order_line.filtered(lambda x: x.product_qty == 10).name, "T-shirt (Green)", 'wrong description in po lines') + + purchase_order.button_confirm() + + self.assertEqual(purchase_order.picking_ids[0].move_ids_without_package.filtered(lambda x: x.product_uom_qty == 15).description_picking, "T-shirt (Red)", 'wrong description in picking') + self.assertEqual(purchase_order.picking_ids[0].move_ids_without_package.filtered(lambda x: x.product_uom_qty == 10).description_picking, "T-shirt (Green)", 'wrong description in picking') + def test_reordering_days_to_purchase(self): self.patcher = patch('odoo.addons.stock.models.stock_orderpoint.fields.Date', wraps=fields.Date) self.mock_date = self.patcher.start() |
