[IMP] sale_mrp: Convert yml test into python
This commit is contained in:
committed by
Yannick Tivisse
parent
98cde7ca7b
commit
620659d8e8
@@ -19,9 +19,6 @@ from sales order. It adds sales name and sales Reference on production order.
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'demo': [],
|
||||
'test':[
|
||||
'test/sale_mrp.yml',
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
}
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
-
|
||||
In order to test the sale_mrp module in OpenERP, I start by creating a new product 'Slider Mobile'
|
||||
-
|
||||
I define product category Mobile Products Sellable.
|
||||
-
|
||||
!record {model: product.category, id: product_category_allproductssellable0}:
|
||||
name: Mobile Products Sellable
|
||||
-
|
||||
I define product category Mobile Services.
|
||||
-
|
||||
!record {model: product.category, id: product_category_16}:
|
||||
name: Mobile Services
|
||||
-
|
||||
I define product template for Slider Mobile.
|
||||
-
|
||||
!record {model: product.template, id: product_template_slidermobile0}:
|
||||
categ_id: product_category_allproductssellable0
|
||||
list_price: 200.0
|
||||
name: Slider Mobile
|
||||
standard_price: 189.0
|
||||
type: product
|
||||
uom_id: product.product_uom_unit
|
||||
uom_po_id: product.product_uom_unit
|
||||
-
|
||||
I define a product Slider Mobile
|
||||
-
|
||||
!record {model: product.product, id: product_product_slidermobile0, view: False}:
|
||||
categ_id: product_category_allproductssellable0
|
||||
list_price: 200.0
|
||||
name: Slider Mobile
|
||||
seller_ids:
|
||||
- delay: 1
|
||||
name: base.res_partner_2
|
||||
min_qty: 2.0
|
||||
standard_price: 189.0
|
||||
type: product
|
||||
uom_id: product.product_uom_unit
|
||||
uom_po_id: product.product_uom_unit
|
||||
-
|
||||
I add the routes manufacture and mto to the product
|
||||
-
|
||||
!python {model: product.product, id: product_product_slidermobile0}: |
|
||||
route_warehouse0_manufacture_id = self.env['stock.warehouse'].browse(ref('stock.warehouse0')).manufacture_pull_id.route_id.id
|
||||
route_warehouse0_mto_id = self.env['stock.warehouse'].browse(ref('stock.warehouse0')).mto_pull_id.route_id.id
|
||||
self.write({'route_ids': [(6, 0, [route_warehouse0_mto_id,route_warehouse0_manufacture_id])]})
|
||||
-
|
||||
I create a Bill of Material record for Slider Mobile
|
||||
-
|
||||
!record {model: mrp.bom, id: mrp_bom_slidermobile0}:
|
||||
company_id: base.main_company
|
||||
product_tmpl_id: product_product_slidermobile0_product_template
|
||||
product_id: product_product_slidermobile0
|
||||
product_qty: 1.0
|
||||
product_uom_id: product.product_uom_unit
|
||||
sequence: 0.0
|
||||
type: normal
|
||||
-
|
||||
I create a sale order for product Slider mobile
|
||||
-
|
||||
!record {model: sale.order, id: sale_order_so0}:
|
||||
client_order_ref: ref1
|
||||
date_order: !eval time.strftime('%Y-%m-%d')
|
||||
name: Test_SO001
|
||||
order_line:
|
||||
- name: Slider Mobile
|
||||
price_unit: 200
|
||||
product_uom: product.product_uom_unit
|
||||
product_uom_qty: 500.0
|
||||
state: draft
|
||||
customer_lead: 7.0
|
||||
product_id: product_product_slidermobile0
|
||||
partner_id: base.res_partner_4
|
||||
partner_invoice_id: base.res_partner_address_7
|
||||
partner_shipping_id: base.res_partner_address_7
|
||||
picking_policy: direct
|
||||
pricelist_id: product.list0
|
||||
-
|
||||
I confirm the sale order
|
||||
-
|
||||
!python {model: sale.order, id: sale_order_so0}: |
|
||||
self.action_confirm()
|
||||
-
|
||||
I verify that a manufacturing order has been generated, and that its name and reference are correct
|
||||
-
|
||||
!python {model: sale.order, id: sale_order_so0}: |
|
||||
mo = self.env['mrp.production'].search([('origin','like',self.name)], limit=1)
|
||||
assert mo, 'Manufacturing order has not been generated'
|
||||
@@ -4,3 +4,4 @@
|
||||
from . import test_move_explode
|
||||
from . import test_sale_mrp_flow
|
||||
from . import test_sale_mrp_lead_time
|
||||
from . import test_sale_mrp_procurement
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import time
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestSaleMrpProcurement(TransactionCase):
|
||||
|
||||
def test_sale_mrp(self):
|
||||
# In order to test the sale_mrp module in OpenERP, I start by creating a new product 'Slider Mobile'
|
||||
# I define product category Mobile Products Sellable.
|
||||
|
||||
product_category_allproductssellable0 = self.env['product.category'].create({
|
||||
'name': 'Mobile Products Sellable'
|
||||
})
|
||||
|
||||
# I define product category Mobile Services.
|
||||
product_category_16 = self.env['product.category'].create({
|
||||
'name': 'Mobile Services',
|
||||
})
|
||||
|
||||
uom_unit = self.env.ref('product.product_uom_unit')
|
||||
|
||||
# I define product template for Slider Mobile.
|
||||
product_template_slidermobile0 = self.env['product.template'].create({
|
||||
'categ_id': product_category_allproductssellable0.id,
|
||||
'list_price': 200.0,
|
||||
'name': 'Slider Mobile',
|
||||
'standard_price': 189.0,
|
||||
'type': 'product',
|
||||
'uom_id': uom_unit.id,
|
||||
'uom_po_id': uom_unit.id,
|
||||
})
|
||||
|
||||
# I define a product Slider Mobile
|
||||
product_product_slidermobile0 = self.env['product.product'].create({
|
||||
'categ_id': product_category_allproductssellable0.id,
|
||||
'list_price': 200.0,
|
||||
'name': 'Slider Mobile',
|
||||
'seller_ids': [(0, 0, {
|
||||
'delay': 1,
|
||||
'name': self.env.ref('base.res_partner_2').id,
|
||||
'min_qty': 2.0,
|
||||
})],
|
||||
'standard_price': 189.0,
|
||||
'type': 'product',
|
||||
'uom_id': uom_unit.id,
|
||||
'uom_po_id': uom_unit.id,
|
||||
})
|
||||
|
||||
# I add the routes manufacture and mto to the product
|
||||
product_product_slidermobile0.write({
|
||||
'route_ids': [(6, 0, [
|
||||
self.env.ref('stock.warehouse0').mto_pull_id.route_id.id,
|
||||
self.env.ref('stock.warehouse0').manufacture_pull_id.route_id.id,
|
||||
])]
|
||||
})
|
||||
|
||||
# I create a Bill of Material record for Slider Mobile
|
||||
mrp_bom_slidermobile0 = self.env['mrp.bom'].create({
|
||||
'company_id': self.env.ref('base.main_company').id,
|
||||
'product_tmpl_id': product_template_slidermobile0.id,
|
||||
'product_id': product_product_slidermobile0.id,
|
||||
'product_qty': 1.0,
|
||||
'product_uom_id': uom_unit.id,
|
||||
'sequence': 0.0,
|
||||
'type': 'normal',
|
||||
})
|
||||
|
||||
# I create a sale order for product Slider mobile
|
||||
sale_order_so0 = self.env['sale.order'].create({
|
||||
'client_order_ref': 'ref1',
|
||||
'date_order': time.strftime('%Y-%m-%d'),
|
||||
'name': 'Test_SO001',
|
||||
'order_line': [(0, 0, {
|
||||
'name': 'Slider Mobile',
|
||||
'price_unit': 200,
|
||||
'product_uom': uom_unit.id,
|
||||
'product_uom_qty': 500.0,
|
||||
'state': 'draft',
|
||||
'customer_lead': 7.0,
|
||||
'product_id': product_product_slidermobile0.id,
|
||||
})],
|
||||
'partner_id': self.env.ref('base.res_partner_4').id,
|
||||
'partner_invoice_id': self.env.ref('base.res_partner_address_7').id,
|
||||
'partner_shipping_id': self.env.ref('base.res_partner_address_7').id,
|
||||
'picking_policy': 'direct',
|
||||
'pricelist_id': self.env.ref('product.list0').id,
|
||||
})
|
||||
|
||||
# I confirm the sale order
|
||||
sale_order_so0.action_confirm()
|
||||
|
||||
# I verify that a manufacturing order has been generated, and that its name and reference are correct
|
||||
mo = self.env['mrp.production'].search([('origin', 'like', sale_order_so0.name)], limit=1)
|
||||
self.assertTrue(mo, 'Manufacturing order has not been generated')
|
||||
Reference in New Issue
Block a user