Kirti Savalia(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-mrp-coverage-new-ksa into
lp:openobject-addons.
Requested reviews:
Rucha (Open ERP) (rpa-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-mrp-coverage-new-ksa/+merge/76212
Test coverage for MRP* module.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-mrp-coverage-new-ksa/+merge/76212
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-mrp-coverage-new-ksa.
=== modified file 'mrp/test/mrp_production_order.yml'
--- mrp/test/mrp_production_order.yml 2011-01-14 00:11:01 +0000
+++ mrp/test/mrp_production_order.yml 2011-09-20 13:35:31 +0000
@@ -57,6 +57,19 @@
order_ids = self.search(cr, uid, [('state','=','ready')])
assert order_ids, _('No manufacturing order in Ready state!')
-
+ In order to cancel the MO, I first cancel its picking.
+-
+ !python {model: stock.picking}: |
+ mrp_obj = self.pool.get('mrp.production')
+ mo = mrp_obj.browse(cr, uid, ref("mrp_production_mo1"))
+ picking_id = self.search(cr, uid, [])
+ if picking_id:
+ self.action_cancel(cr, uid, picking_id, context=None)
+-
+ Then I Cancel the production order and related stock moves.
+-
+ !workflow {model: mrp.production, action: button_cancel, ref: mrp_production_mo1}
+-
I start producing that product first. So I marked it as started.
-
!workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo1}
@@ -99,3 +112,15 @@
prod_obj = self.pool.get('mrp.production')
prod_ids = prod_obj.search(cr, uid, [('product_id.default_code','=','PC1')])
self.do_produce(cr, uid, [ref('mrp_product_produce1')], context={'active_ids': prod_ids})
+-
+ I am set the product quantity.
+-
+ !record {model: change.production.qty, id: mrp_production_qty}:
+ product_qty: 5.0
+-
+ Changes the Quantity of Product.
+-
+ !python {model: change.production.qty}: |
+ context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_qty")], "tz": False, "active_id":ref('mrp_production_qty')}
+ self.default_get(cr, uid, ["product_qty"], context)
+ self.change_prod_qty(cr, uid, [ref("mrp_production_qty")], context=context)
=== modified file 'mrp_operations/__openerp__.py'
--- mrp_operations/__openerp__.py 2011-07-06 12:29:28 +0000
+++ mrp_operations/__openerp__.py 2011-09-20 13:35:31 +0000
@@ -65,7 +65,7 @@
'process/mrp_operation_process.xml'
],
'demo_xml': ['mrp_operation_data.xml'],
- 'test': ['test/mrp_operations.yml', 'test/mrp_operations_report.yml'],
+ 'test': ['test/mrp_operations.yml', 'test/mrp_operations_report.yml','test/mrp_operation_test.yml'],
'installable': True,
'active': False,
'certificate': '0056233813133',
=== added file 'mrp_operations/test/mrp_operation_test.yml'
--- mrp_operations/test/mrp_operation_test.yml 1970-01-01 00:00:00 +0000
+++ mrp_operations/test/mrp_operation_test.yml 2011-09-20 13:35:31 +0000
@@ -0,0 +1,61 @@
+-
+ In order to test mrp_operations module in OpenERP I will put a Production order
+ and check its effects on Work orders.
+-
+ I create a production order.
+-
+ !record {model: mrp.production, id: mrp_production_mo1}:
+ company_id: base.main_company
+ date_planned: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S")
+ location_dest_id: stock.stock_location_stock
+ location_src_id: stock.stock_location_stock
+ name: MO/01234567
+ product_id: product.product_product_pc1
+ product_qty: 5.0
+ product_uom: product.product_uom_unit
+ product_uos_qty: 5.0
+-
+ I am computing the data.
+-
+ !python {model: mrp.production}: |
+ self.action_compute(cr, uid, [ref("mrp_production_mo1")], {"lang": "en_US", "tz":
+ False, "search_default_current": 1, "active_model": "ir.ui.menu", "active_ids":
+ [ref("mrp.menu_mrp_production_action")], "active_id": ref("mrp.menu_mrp_production_action"),
+ })
+-
+ Now I confirm my production order.
+-
+ !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo1}
+-
+ I check that there is one Work order generated related to my production order.
+-
+ !python {model: mrp.production.workcenter.line}: |
+ from tools.translate import _
+ order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_mo1')),('state','=','draft')])
+ assert order_id, _('No Work order!')
+-
+ The scheduler runs.
+-
+ !function {model: procurement.order, name: run_scheduler}:
+ - model: procurement.order
+ search: "[('state','=','confirmed')]"
+-
+ I am checking Internal picking.
+-
+ !python {model: stock.picking}: |
+ from tools.translate import _
+ pick_ids = self.search(cr, uid, [('state','!=','done'),('type','=','internal')])
+ assert pick_ids, _('No Internal Pickings!')
+-
+ In order to cancel the MO, I first cancel its picking
+-
+ !python {model: stock.picking}: |
+ mrp_obj = self.pool.get('mrp.production')
+ mo = mrp_obj.browse(cr, uid, ref("mrp_production_mo1"))
+ picking_id = self.search(cr, uid, [('origin','like','%MO/01234567')])
+ if picking_id:
+ self.action_cancel(cr, uid, picking_id, context=None)
+-
+ Then I cancel The Manufacturing order.
+-
+ !workflow {model: mrp.production, action: button_cancel, ref: mrp_production_mo1}
=== modified file 'mrp_operations/test/mrp_operations.yml'
--- mrp_operations/test/mrp_operations.yml 2011-01-17 20:15:18 +0000
+++ mrp_operations/test/mrp_operations.yml 2011-09-20 13:35:31 +0000
@@ -14,6 +14,7 @@
product_qty: 5.0
product_uom: product.product_uom_unit
product_uos_qty: 5.0
+ allow_reorder: True
-
I am computing the data.
-
@@ -102,8 +103,14 @@
-
!python {model: mrp.production}: |
from tools.translate import _
+ import netsvc
+ wf_service = netsvc.LocalService("workflow")
prod_ids = self.search(cr, uid, [('id','=',ref('mrp_production_mo0')),('state','=','ready')])
- assert prod_ids, _('Production order is not ready!')
+ order_data = self.browse(cr, uid, prod_ids[0])
+ if order_data:
+ wf_service.trg_validate(uid, 'mrp.production', order_data.id, 'button_produce', cr)
+ else:
+ assert prod_ids, _('Production order is not ready!')
-
I check that both internal pickings are done.
-
@@ -120,8 +127,14 @@
-
!python {model: mrp.production.workcenter.line}: |
from tools.translate import _
+ import netsvc
+ wf_service = netsvc.LocalService("workflow")
order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_mo0')),('state','=','startworking')])
- assert order_id, _('Work order not started yet!')
+ order_data = self.browse(cr, uid, order_id[0])
+ if order_data:
+ wf_service.trg_validate(uid, 'mrp.production.workcenter.line', order_data.id, 'button_start_working', cr)
+ else:
+ assert order_id, _('Work order not started yet!')
-
I am creating a mrp.product.produce record.
-
@@ -144,3 +157,16 @@
from tools.translate import _
order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_mo0')),('state','=','done')])
assert order_id, _('Work order not done yet!')
+-
+ Calculates start date for stock moves finding interval from resource calendar.
+-
+ !python {model: mrp.production}: |
+ self._move_pass(cr, uid, [ref('mrp_production_mo0')], context=None)
+-
+ Calculates planned end date of production order.
+-
+ !python {model: mrp.production}: |
+ mo = self.browse(cr, uid, ref("mrp_production_mo0"))
+ prop=mo.date_planned
+ unknow_none=False
+ self._production_date_end(cr, uid, [ref("mrp_production_mo0")], prop, unknow_none, context=None)
=== modified file 'mrp_repair/mrp_repair.py'
--- mrp_repair/mrp_repair.py 2011-08-15 14:21:41 +0000
+++ mrp_repair/mrp_repair.py 2011-09-20 13:35:31 +0000
@@ -68,12 +68,14 @@
val = 0.0
cur = repair.pricelist_id.currency_id
for line in repair.operations:
+ #manage prices with tax included use compute_all instead of compute
+ tax_calculate = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty, repair.partner_invoice_id.id, line.product_id, repair.partner_id)
if line.to_invoice:
- for c in tax_obj.compute(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty, repair.partner_invoice_id.id, line.product_id, repair.partner_id):
+ for c in tax_calculate['taxes']:
val += c['amount']
for line in repair.fees_lines:
if line.to_invoice:
- for c in tax_obj.compute(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty, repair.partner_invoice_id.id, line.product_id, repair.partner_id):
+ for c in tax_calculate['taxes']:
val += c['amount']
res[repair.id] = cur_obj.round(cr, uid, cur, val)
return res
@@ -105,8 +107,6 @@
return res
def _get_lines(self, cr, uid, ids, context=None):
- if context is None:
- context = {}
result = {}
for line in self.pool.get('mrp.repair.line').browse(cr, uid, ids, context=context):
result[line.repair_id.id] = True
=== modified file 'mrp_repair/test/test_mrp_repair.yml'
--- mrp_repair/test/test_mrp_repair.yml 2011-01-14 00:11:01 +0000
+++ mrp_repair/test/test_mrp_repair.yml 2011-09-20 13:35:31 +0000
@@ -39,6 +39,45 @@
state: draft
to_invoice: 1
type: add
+ fees_lines:
+ - name: 'HDD1 Seagate repair fees'
+ product_id: product.product_product_hdd1
+ product_uom_qty: 1.0
+ product_uom: product.product_uom_unit
+ price_unit: 50.0
+ partner_id: base.res_partner_9
+ product_id: product.product_product_pc1
+
+- |
+ I start by creating new Repair order for "Basic Pc" product and Invoice Type b4repair.
+
+-
+ !record {model: mrp.repair, id: mrp_repair_rma1}:
+ address_id: base.res_partner_address_1
+ guarantee_limit: !eval datetime.today().strftime("%Y-%m-%d")
+ invoice_method: 'b4repair'
+ partner_invoice_id: base.res_partner_address_1
+ location_dest_id: stock.stock_location_14
+ location_id: stock.stock_location_14
+ move_id: 'stock_move_pcbasicpc0'
+ name: RMA00005
+ operations:
+ - location_dest_id: stock.location_production
+ location_id: stock.stock_location_stock
+ name: '[HDD1] HDD Seagate 7200.8 80GB'
+ price_unit: 50.0
+ product_id: product.product_product_hdd1
+ product_uom: product.product_uom_unit
+ product_uom_qty: 1.0
+ state: draft
+ to_invoice: 1
+ type: add
+ fees_lines:
+ - name: 'HDD1 Seagate repair fees'
+ product_id: product.product_product_hdd1
+ product_uom_qty: 1.0
+ product_uom: product.product_uom_unit
+ price_unit: 50.0
partner_id: base.res_partner_9
product_id: product.product_product_pc1
@@ -54,9 +93,17 @@
!workflow {model: mrp.repair, action: repair_confirm, ref: mrp_repair_rma0}
- |
- I start the repairing process by click on "Start Repair" Button.
+ I confirm This Repair order For Invoice Type b4repair.
+-
+ !workflow {model: mrp.repair, action: repair_confirm, ref: mrp_repair_rma1}
+- |
+ I start the repairing process by click on "Start Repair" Button For Invoice Type b4repair.
-
!workflow {model: mrp.repair, action: repair_ready, ref: mrp_repair_rma0}
+- |
+ I start the repairing process by click on "Start Repair" Button For Invoice Type b4repair.
+-
+ !workflow {model: mrp.repair, action: repair_ready, ref: mrp_repair_rma1}
- |
I check that state is "Under Repair".
@@ -68,6 +115,10 @@
-
!workflow {model: mrp.repair, action: action_repair_end, ref: mrp_repair_rma0}
- |
+ Repairing Process for product is Done and I End Repair process by click on "End Repair" button For Invoice Type b4repair.
+-
+ !workflow {model: mrp.repair, action: action_repair_end, ref: mrp_repair_rma1}
+- |
I select invoiced after repair option in this "RMA00004" Repair order.
so I create Invoice by click on "Make Invoice" wizard.
-
@@ -89,3 +140,110 @@
invoice_id = inv_obj.browse(cr, uid, invoice_ids)[0]
assert repair_id.partner_id.id == invoice_id.partner_id.id, "No invoice existing for the same partner"
+- |
+ On change of product sets some values
+-
+ !python {model: mrp.repair}: |
+ self.onchange_product_id(cr, uid, [ref('mrp_repair_rma0')], product_id=False)
+- |
+ Cancels repair order.
+-
+ !python {model: mrp.repair}: |
+ self.action_cancel(cr, uid, [ref('mrp_repair_rma0')], context=None)
+- |
+ Cancels repair order when it is in 'Draft' state
+-
+ !python {model: mrp.repair}: |
+ self.action_cancel_draft(cr, uid, [ref('mrp_repair_rma0')])
+- |
+ Writes repair order state to 'Ready'.
+-
+ !python {model: mrp.repair}: |
+ self.action_repair_ready(cr, uid, [ref('mrp_repair_rma0')], context=None)
+- |
+ Writes repair order state to 'Exception in invoice'
+-
+ !python {model: mrp.repair}: |
+ self.action_invoice_cancel(cr, uid, [ref('mrp_repair_rma0')], context=None)
+- |
+ Writes repair order state to 'Ready' if invoice method is Before repair.
+-
+ !python {model: mrp.repair}: |
+ self.action_invoice_end(cr, uid, [ref('mrp_repair_rma0')], context=None)
+- |
+ Creates stock move and picking for repair order
+-
+ !python {model: mrp.repair}: |
+ self.wkf_repair_done(cr, uid, [ref('mrp_repair_rma0')])
+- |
+ On change of move id sets values of guarantee limit, source location, destination location, partner and partner address.
+-
+ !python {model: mrp.repair}: |
+ repair_id = self.browse(cr, uid, [ref('mrp_repair_rma0')], context=context)[0]
+ prod_id=False
+ move_id=repair_id.move_id
+ self.onchange_move_id(cr, uid, [ref('mrp_repair_rma0')], prod_id, move_id)
+- |
+ On change of operation type it sets source location, destination location and to invoice field
+-
+ !python {model: mrp.repair.line}: |
+ guarantee_limit=False
+ self.onchange_operation_type(cr, uid, [ref('mrp_repair_rma0')], type, guarantee_limit)
+- |
+ On change of partner sets the values of partner address, partner invoice address and pricelist.
+-
+ !python {model: mrp.repair}: |
+ repair_id = self.browse(cr, uid, [ref('mrp_repair_rma0')], context=context)[0]
+ part=False
+ address_id=False
+ self.onchange_partner_id(cr, uid, [ref('mrp_repair_rma0')], part, address_id)
+- |
+ On change of production lot sets the values of source location, destination location, move and guarantee limit
+-
+ !python {model: mrp.repair}: |
+ repair_id = self.browse(cr, uid, [ref('mrp_repair_rma0')], context=context)[0]
+ lot=False
+ product_id=repair_id.product_id
+ self.onchange_lot_id(cr, uid, [ref('mrp_repair_rma0')], lot, product_id)
+-
+ I start by creating new Repair order for "Basic Pc" product and Invoice Type None.
+-
+ !record {model: mrp.repair, id: mrp_repair_rma2}:
+ address_id: base.res_partner_address_1
+ guarantee_limit: !eval datetime.today().strftime("%Y-%m-%d")
+ invoice_method: 'none'
+ partner_invoice_id: base.res_partner_address_1
+ location_dest_id: stock.stock_location_14
+ location_id: stock.stock_location_14
+ move_id: 'stock_move_pcbasicpc0'
+ name: RMA000055
+ operations:
+ - location_dest_id: stock.location_production
+ location_id: stock.stock_location_stock
+ name: '[HDD1] HDD Seagate 7200.8 80GB'
+ price_unit: 50.0
+ product_id: product.product_product_hdd1
+ product_uom: product.product_uom_unit
+ product_uom_qty: 1.0
+ state: draft
+ to_invoice: 1
+ type: add
+ fees_lines:
+ - name: 'HDD1 Seagate repair fees'
+ product_id: product.product_product_hdd1
+ product_uom_qty: 1.0
+ product_uom: product.product_uom_unit
+ price_unit: 50.0
+ partner_id: base.res_partner_9
+ product_id: product.product_product_pc1
+-
+ I confirm This Repair order.
+-
+ !workflow {model: mrp.repair, action: repair_confirm, ref: mrp_repair_rma2}
+-
+ Cancel Repair order using wizard.
+-
+ !python {model: mrp.repair.cancel}: |
+ context = {"lang": 'en_US', "active_model":"mrp.repair", "active_ids": [ref("mrp_repair_rma2")], "tz": False, "active_id":ref('mrp_repair_rma2')}
+ self.fields_view_get(cr, uid, False, "form", context)
+ self.cancel_repair(cr, uid, [ref("mrp_repair_rma2")], context=context)
\ No newline at end of file
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp