odoo/addons/sale_mrp/test/sale_mrp.yml

113 lines
4.2 KiB
YAML
Raw Permalink Normal View History

-
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 procurement has been generated for sale order
-
!python {model: procurement.order, id: False}: |
so = self.env['sale.order'].browse(ref("sale_order_so0"))
procs = self.search([('origin','=',so.name)])
assert procs, 'No Procurements!'
-
Then I click on the "Run Procurement" button
-
!python {model: procurement.order, id: False}: |
so = self.env['sale.order'].browse(ref("sale_order_so0"))
procs = self.search([('origin','like',so.name)])
procs.run()
-
I verify that a procurement state is "running"
-
!python {model: procurement.order, id: False}: |
so = self.env['sale.order'].browse(ref("sale_order_so0"))
procs = self.search([('origin','like',so.name)])
# Check that all procurement are running
for procu in procs:
assert procu.state == u'running', 'Procurement with id %d should be with a state "running" but is with a state : %s!' %(procu.id,procu.state)
-
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'
assert mo.sale_name == self.name, 'Wrong Name for the Manufacturing Order. Expected %s, Got %s' % (self.name, mo.sale_name)
assert mo.sale_ref == self.client_order_ref, 'Wrong Sale Reference for the Manufacturing Order'