[MERGE] merged the branch with test coverage improvements of mrp modules
bzr revid: qdp-launchpad@openerp.com-20111010110858-487iie6kuoidgjvu
This commit is contained in:
@@ -97,6 +97,7 @@ Dashboard provided by this module:
|
||||
'test/mrp_packs.yml',
|
||||
'test/mrp_phantom_bom.yml',
|
||||
'test/mrp_production_order.yml',
|
||||
'test/mrp_production_cancel.yml',
|
||||
'test/mrp_report.yml',
|
||||
|
||||
],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-
|
||||
In order to test the Packs in OpenERP, we will try to sell a "Pack of 24
|
||||
beers" which is composed of 24 "Beers" and a "Beers Pack".
|
||||
- |
|
||||
-
|
||||
I start by creating the Beers product.
|
||||
-
|
||||
!record {model: product.product, id: product_product_beers0}:
|
||||
@@ -16,7 +16,7 @@
|
||||
type: product
|
||||
uom_id: product.product_uom_unit
|
||||
uom_po_id: product.product_uom_unit
|
||||
- |
|
||||
-
|
||||
I create the "Beers Pack" product.
|
||||
-
|
||||
!record {model: product.product, id: product_product_beerspack0}:
|
||||
@@ -31,7 +31,7 @@
|
||||
type: product
|
||||
uom_id: product.product_uom_unit
|
||||
uom_po_id: product.product_uom_unit
|
||||
- |
|
||||
-
|
||||
I create the "Pack of 24 beers" product
|
||||
-
|
||||
!record {model: product.product, id: product_product_packofbeers0}:
|
||||
@@ -42,7 +42,7 @@
|
||||
type: product
|
||||
uom_id: product.product_uom_unit
|
||||
uom_po_id: product.product_uom_unit
|
||||
- |
|
||||
-
|
||||
I define the Phantom Bill of Material for the "Pack of 24 beers"
|
||||
-
|
||||
!record {model: mrp.bom, id: mrp_bom_packofbeers0}:
|
||||
@@ -64,10 +64,10 @@
|
||||
product_qty: 1.0
|
||||
product_uom: product.product_uom_unit
|
||||
type: phantom
|
||||
- |
|
||||
-
|
||||
As all my data are created, I will create an outgoing order picking for a
|
||||
"Pack of 24 Beers"
|
||||
-
|
||||
-
|
||||
!record {model: stock.picking, id: picking_out}:
|
||||
address_id: base.res_partner_address_tang
|
||||
company_id: base.main_company
|
||||
@@ -82,15 +82,15 @@
|
||||
product_uom: product.product_uom_unit
|
||||
move_type: direct
|
||||
type: out
|
||||
- |
|
||||
-
|
||||
I validate the newly created picking.
|
||||
-
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
self.draft_validate(cr, uid, [ref("picking_out")], {
|
||||
"active_ids": [ref("stock.menu_action_picking_tree")],
|
||||
"active_id": ref("stock.menu_action_picking_tree"), }
|
||||
)
|
||||
- |
|
||||
-
|
||||
I check that my Picking of a "Pack of 24 beers" has been automatically
|
||||
converted to a picking of 24 beers and a pack of beer, so that my
|
||||
stock of beers remains exact.
|
||||
|
||||
@@ -96,6 +96,12 @@
|
||||
product_qty: 1.0
|
||||
product_uom: product_uom_litre0
|
||||
type: phantom
|
||||
-
|
||||
changes UOM and name if product change.
|
||||
-
|
||||
!python {model: mrp.bom}: |
|
||||
production_id = self.browse(cr, uid, [ref('mrp_bom_orangejuice0')], context=context)[0]
|
||||
self.onchange_product_id(cr, uid, [ref('mrp_bom_orangejuice0')], production_id.product_id.id, False)
|
||||
-
|
||||
I create bom lines for BoM for Orange Juice.
|
||||
-
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
-
|
||||
In order to test the manufacturing order in Openerp,
|
||||
I am creating one manufacturing 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
|
||||
product_id: product.product_product_pc1
|
||||
name: MO/01234
|
||||
product_qty: 5.0
|
||||
product_uom: product.product_uom_unit
|
||||
product_uos_qty: 0.0
|
||||
-
|
||||
I confirm the order.
|
||||
-
|
||||
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo1}
|
||||
-
|
||||
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"))
|
||||
self.action_cancel(cr, uid, [mo.picking_id.id], context=None)
|
||||
-
|
||||
Then I Cancel the production order and related stock moves.
|
||||
-
|
||||
!workflow {model: mrp.production, action: button_cancel, ref: mrp_production_mo1}
|
||||
@@ -11,6 +11,7 @@
|
||||
location_dest_id: stock.stock_location_stock
|
||||
location_src_id: stock.stock_location_stock
|
||||
product_id: product.product_product_pc1
|
||||
name: MO/0123
|
||||
product_qty: 5.0
|
||||
product_uom: product.product_uom_unit
|
||||
product_uos_qty: 0.0
|
||||
@@ -18,14 +19,28 @@
|
||||
I compute 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"),
|
||||
})
|
||||
self.action_compute(cr, uid, [ref("mrp_production_mo1")])
|
||||
-
|
||||
I confirm the order.
|
||||
-
|
||||
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo1}
|
||||
-
|
||||
I create record for changing production quantity to 6.00
|
||||
-
|
||||
!record {model: change.production.qty, id: mrp_production_qty}:
|
||||
product_qty: 6.0
|
||||
-
|
||||
Changes the Quantity of Product.
|
||||
-
|
||||
!python {model: change.production.qty}: |
|
||||
context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_mo1")], "tz": False, "active_id":ref('mrp_production_mo1')}
|
||||
self.default_get(cr, uid, ["product_qty"], context)
|
||||
self.change_prod_qty(cr, uid, [ref("mrp_production_qty")], context=context)
|
||||
-
|
||||
I check now quantity of the production order is 6 or not.
|
||||
-
|
||||
!assert {model: mrp.production, id: mrp_production_mo1}:
|
||||
- product_qty == 6
|
||||
-
|
||||
I am checking Procurement orders for components of PC1.
|
||||
-
|
||||
@@ -50,28 +65,28 @@
|
||||
pick_ids = self.search(cr, uid, [('type','=','internal')])
|
||||
assert pick_ids, _('No Internal Pickings!')
|
||||
-
|
||||
I see that there is a manufacturing order for the sub product of PC1 with ready state.
|
||||
I see that there is a manufacturing order for the sub product CPU_GEN with ready state and I start production of it.
|
||||
-
|
||||
!python {model: mrp.production}: |
|
||||
from tools.translate import _
|
||||
order_ids = self.search(cr, uid, [('state','=','ready')])
|
||||
order_ids = self.search(cr, uid, [('state','=','ready'), ('product_id', '=', ref('product.product_product_cpu_gen'))])
|
||||
assert order_ids, _('No manufacturing order in Ready state!')
|
||||
import netsvc
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for order in order_ids:
|
||||
wf_service.trg_validate(uid, 'mrp.production', order, 'button_produce', cr)
|
||||
-
|
||||
I start producing that product first. So I marked it as started.
|
||||
-
|
||||
!workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo1}
|
||||
-
|
||||
I create record for producing products with quantity 5.00.
|
||||
I create record for producing products with quantity 6.00.
|
||||
-
|
||||
!record {model: mrp.product.produce, id: mrp_product_produce0}:
|
||||
product_qty: 5.00
|
||||
product_qty: 6.00
|
||||
mode: 'consume_produce'
|
||||
-
|
||||
I produce the product.
|
||||
-
|
||||
!python {model: mrp.product.produce}: |
|
||||
prod_obj = self.pool.get('mrp.production')
|
||||
prod_ids = prod_obj.search(cr, uid, [('state','=','confirmed')])
|
||||
prod_ids = prod_obj.search(cr, uid, [('state','=','in_production'), ('product_id', '=', ref('product.product_product_cpu_gen'))])
|
||||
self.do_produce(cr, uid, [ref('mrp_product_produce0')], context={'active_ids': prod_ids})
|
||||
-
|
||||
Now the manufacturing order for subproduct CPU_GEN is done and manufacturing
|
||||
@@ -79,23 +94,26 @@
|
||||
-
|
||||
!python {model: mrp.production}: |
|
||||
from tools.translate import _
|
||||
prod_ids = self.search(cr, uid, [('state','=','done')])
|
||||
assert prod_ids, _('Manufacturing order is yet not done!')
|
||||
prod_ids = self.search(cr, uid, [('state','=','done'), ('product_id', '=', ref('product.product_product_cpu_gen'))])
|
||||
assert prod_ids, _('Manufacturing order for CPU_GEN is yet not done!')
|
||||
-
|
||||
I start producing the product PC1.
|
||||
-
|
||||
!workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo1}
|
||||
-
|
||||
I create record for producing products with quantity 5.00.
|
||||
I create record for producing products with quantity 6.00.
|
||||
-
|
||||
!record {model: mrp.product.produce, id: mrp_product_produce1}:
|
||||
product_qty: 5.00
|
||||
product_qty: 6.00
|
||||
mode: 'consume_produce'
|
||||
-
|
||||
Finally my production order is done.
|
||||
-
|
||||
!python {model: mrp.product.produce}: |
|
||||
from tools.translate import _
|
||||
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})
|
||||
context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_mo1")], "tz": False, "active_id":ref('mrp_production_mo1')}
|
||||
self.do_produce(cr, uid, [ref('mrp_product_produce1')], context=context)
|
||||
-
|
||||
I check now the production order for PC1 is done.
|
||||
-
|
||||
!assert {model: mrp.production, id: mrp_production_mo1}:
|
||||
- state == 'done'
|
||||
|
||||
@@ -65,7 +65,7 @@ So that we can compare the theoretic delay and real delay.
|
||||
'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',
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
-
|
||||
In order to test mrp_operations module in OpenERP,
|
||||
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
|
||||
-
|
||||
Now I confirm the production order.
|
||||
-
|
||||
!workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo1}
|
||||
-
|
||||
I check that there is one Work order generated related to the 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 defined for this production order!')
|
||||
-
|
||||
The scheduler runs.
|
||||
-
|
||||
!function {model: procurement.order, name: run_scheduler}:
|
||||
- model: procurement.order
|
||||
search: "[('state','=','confirmed')]"
|
||||
-
|
||||
I am checking Internal picking.
|
||||
-
|
||||
!python {model: mrp.production}: |
|
||||
from tools.translate import _
|
||||
pick_ids = self.browse(cr, uid, ref("mrp_production_mo1"))
|
||||
assert pick_ids.picking_id.id, _('No Internal Picking generated!')
|
||||
-
|
||||
In order to cancel the MO, 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"))
|
||||
self.action_cancel(cr, uid, [mo.picking_id.id], context=None)
|
||||
-
|
||||
Then cancel The Manufacturing order.
|
||||
-
|
||||
!workflow {model: mrp.production, action: button_cancel, ref: mrp_production_mo1}
|
||||
-
|
||||
I check that there is one Work order generated related to the production order that is cancelled or not.
|
||||
-
|
||||
!python {model: mrp.production.workcenter.line}: |
|
||||
from tools.translate import _
|
||||
order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_mo1')),('state','=','cancel')])
|
||||
assert order_id, _('Work order is not cancelled for this production order!')
|
||||
@@ -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.
|
||||
-
|
||||
@@ -32,7 +33,7 @@
|
||||
!python {model: mrp.production.workcenter.line}: |
|
||||
from tools.translate import _
|
||||
order_id = self.search(cr, uid, [('production_id','=', ref('mrp_production_mo0')),('state','=','draft')])
|
||||
assert order_id, _('No Work order!')
|
||||
assert order_id, _('No Work order define for this production order!')
|
||||
-
|
||||
The scheduler runs.
|
||||
-
|
||||
@@ -61,7 +62,7 @@
|
||||
prod_obj = self.pool.get('mrp.production')
|
||||
prod_order_ids = prod_obj.search(cr, uid, [('state','=','ready'),('origin','like','%MO/0123456')])
|
||||
workorder_id = self.search(cr, uid, [('production_id','=', prod_order_ids[0]),('state','=','draft')])
|
||||
assert workorder_id, _('No Work order!')
|
||||
assert workorder_id, _('No Work order define for this production order!')
|
||||
-
|
||||
I start the second production order of the CPU_GEN product.
|
||||
-
|
||||
@@ -144,3 +145,14 @@
|
||||
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"))
|
||||
self._production_date_end(cr, uid, [ref("mrp_production_mo0")], mo.date_planned, False, context=None)
|
||||
|
||||
@@ -48,7 +48,7 @@ The aim is to have a complete module to manage all products repairs. The followi
|
||||
'mrp_repair_report.xml',
|
||||
],
|
||||
'demo_xml': [],
|
||||
'test': ['test/test_mrp_repair.yml', 'test/mrp_repair_report.yml'],
|
||||
'test': ['test/test_mrp_repair.yml', 'test/mrp_repair_report.yml','test/mrp_repair_cancel.yml'],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
'certificate': '0060814381277',
|
||||
|
||||
@@ -68,12 +68,15 @@ class mrp_repair(osv.osv):
|
||||
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
|
||||
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):
|
||||
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)
|
||||
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):
|
||||
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)
|
||||
for c in tax_calculate['taxes']:
|
||||
val += c['amount']
|
||||
res[repair.id] = cur_obj.round(cr, uid, cur, val)
|
||||
return res
|
||||
@@ -105,8 +108,6 @@ class mrp_repair(osv.osv):
|
||||
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
|
||||
@@ -462,13 +463,6 @@ class mrp_repair(osv.osv):
|
||||
self.write(cr, uid, [repair.id], {'state': 'ready'})
|
||||
return True
|
||||
|
||||
def action_invoice_cancel(self, cr, uid, ids, context=None):
|
||||
""" Writes repair order state to 'Exception in invoice'
|
||||
@return: True
|
||||
"""
|
||||
self.write(cr, uid, ids, {'state': 'invoice_except'})
|
||||
return True
|
||||
|
||||
def action_repair_start(self, cr, uid, ids, context=None):
|
||||
""" Writes repair order state to 'Under Repair'
|
||||
@return: True
|
||||
@@ -480,22 +474,6 @@ class mrp_repair(osv.osv):
|
||||
repair.write({'state': 'under_repair'})
|
||||
return True
|
||||
|
||||
def action_invoice_end(self, cr, uid, ids, context=None):
|
||||
""" Writes repair order state to 'Ready' if invoice method is Before repair.
|
||||
@return: True
|
||||
"""
|
||||
repair_line = self.pool.get('mrp.repair.line')
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
val = {}
|
||||
if (order.invoice_method == 'b4repair'):
|
||||
val['state'] = 'ready'
|
||||
repair_line.write(cr, uid, [l.id for
|
||||
l in order.operations], {'state': 'confirmed'}, context=context)
|
||||
else:
|
||||
pass
|
||||
self.write(cr, uid, [order.id], val, context=context)
|
||||
return True
|
||||
|
||||
def action_repair_end(self, cr, uid, ids, context=None):
|
||||
""" Writes repair order state to 'To be invoiced' if invoice method is
|
||||
After repair else state is set to 'Ready'.
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
-
|
||||
In order to test repair orders I have created stock move line record.
|
||||
-
|
||||
!record {model: stock.move, id: stock_move_pcbasicpc0}:
|
||||
company_id: base.main_company
|
||||
date: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S")
|
||||
date_expected: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S")
|
||||
location_dest_id: stock.stock_location_14
|
||||
location_id: stock.stock_location_stock
|
||||
name: '[PC1] Basic PC'
|
||||
product_id: product.product_product_pc1
|
||||
product_qty: 1.0
|
||||
product_uom: product.product_uom_unit
|
||||
product_uos_qty: 1.0
|
||||
|
||||
-
|
||||
I start by creating new Repair order for "Basic PC" product and Invoice Method is "No Invoice".
|
||||
-
|
||||
!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}
|
||||
-
|
||||
I Cancel this Repair order.
|
||||
-
|
||||
!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)
|
||||
-
|
||||
I check that Repair order is in "Cancel" state.
|
||||
-
|
||||
!assert {model: mrp.repair, id: mrp_repair_rma2}:
|
||||
- state == 'cancel'
|
||||
-
|
||||
I Reopen the repair order as new.
|
||||
-
|
||||
!python {model: mrp.repair}: |
|
||||
self.action_cancel_draft(cr, uid, [ref('mrp_repair_rma2')])
|
||||
-
|
||||
I change the Invoice method of the repair order to Before repair.
|
||||
-
|
||||
!python {model: mrp.repair}: |
|
||||
self.write(cr, uid, [ref('mrp_repair_rma2')], {'invoice_method': 'b4repair'})
|
||||
-
|
||||
I confirm the Repair order again.
|
||||
-
|
||||
!workflow {model: mrp.repair, action: repair_confirm, ref: mrp_repair_rma2}
|
||||
-
|
||||
Repair order state to 'Ready'.
|
||||
-
|
||||
!python {model: mrp.repair}: |
|
||||
self.action_repair_ready(cr, uid, [ref('mrp_repair_rma2')], context=None)
|
||||
-
|
||||
I click on "Create Invoice" button of this wizard to make invoice.
|
||||
-
|
||||
!workflow {model: mrp.repair, action: action_invoice_create, ref: mrp_repair_rma2}
|
||||
-
|
||||
I check that Invoice is created for this repair order.
|
||||
-
|
||||
!python {model: mrp.repair}: |
|
||||
repair_id = self.browse(cr, uid, [ref('mrp_repair_rma2')], context=context)[0]
|
||||
assert repair_id.invoice_id.id, _("No invoice exists for this repair order.")
|
||||
-
|
||||
I start the repairing process by click on "Start Repair" Button.
|
||||
-
|
||||
!workflow {model: mrp.repair, action: action_repair_start, ref: mrp_repair_rma2}
|
||||
-
|
||||
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_rma2}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
- |
|
||||
-
|
||||
In order to test "mrp_repair" module, I start with creating repair order, confirm it, and start repair.
|
||||
|
||||
- |
|
||||
-
|
||||
Given that I have already stock move line created.
|
||||
-
|
||||
!record {model: stock.move, id: stock_move_pcbasicpc0}:
|
||||
company_id: base.main_company
|
||||
date: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S")
|
||||
date_expected: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S")
|
||||
location_dest_id: stock.stock_location_stock
|
||||
location_dest_id: stock.stock_location_14
|
||||
location_id: stock.stock_location_stock
|
||||
name: '[PC1] Basic PC'
|
||||
product_id: product.product_product_pc1
|
||||
@@ -16,8 +15,8 @@
|
||||
product_uom: product.product_uom_unit
|
||||
product_uos_qty: 1.0
|
||||
|
||||
- |
|
||||
I start by creating new Repair order for "Basic Pc" product.
|
||||
-
|
||||
I start by creating new Repair order for "Basic PC" product.
|
||||
-
|
||||
!record {model: mrp.repair, id: mrp_repair_rma0}:
|
||||
address_id: base.res_partner_address_1
|
||||
@@ -39,53 +38,81 @@
|
||||
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
|
||||
|
||||
- |
|
||||
-
|
||||
On change of product sets some values
|
||||
-
|
||||
!python {model: mrp.repair}: |
|
||||
self.onchange_product_id(cr, uid, [ref('mrp_repair_rma0')], product_id=False)
|
||||
-
|
||||
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]
|
||||
self.onchange_move_id(cr, uid, [ref('mrp_repair_rma0')], False, repair_id.move_id)
|
||||
-
|
||||
On change of operation type it sets source location, destination location and to invoice field
|
||||
-
|
||||
!python {model: mrp.repair.line}: |
|
||||
self.onchange_operation_type(cr, uid, [ref('mrp_repair_rma0')], type, False)
|
||||
-
|
||||
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]
|
||||
self.onchange_partner_id(cr, uid, [ref('mrp_repair_rma0')], False, repair_id.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]
|
||||
self.onchange_lot_id(cr, uid, [ref('mrp_repair_rma0')], False, repair_id.product_id)
|
||||
-
|
||||
I check that Repair order is in "Draft" state.
|
||||
-
|
||||
!assert {model: mrp.repair, id: mrp_repair_rma0}:
|
||||
- state == 'draft'
|
||||
|
||||
- |
|
||||
-
|
||||
I confirm This Repair order.
|
||||
-
|
||||
!workflow {model: mrp.repair, action: repair_confirm, ref: mrp_repair_rma0}
|
||||
|
||||
- |
|
||||
I start the repairing process by click on "Start Repair" Button.
|
||||
-
|
||||
I start the repairing process by click on "Start Repair" Button For Invoice Type After repair.
|
||||
-
|
||||
!workflow {model: mrp.repair, action: repair_ready, ref: mrp_repair_rma0}
|
||||
|
||||
- |
|
||||
-
|
||||
I check that state is "Under Repair".
|
||||
-
|
||||
!assert {model: mrp.repair, id: mrp_repair_rma0}:
|
||||
- state == 'under_repair'
|
||||
- |
|
||||
-
|
||||
Repairing Process for product is Done and I End Repair process by click on "End Repair" button.
|
||||
-
|
||||
!workflow {model: mrp.repair, action: action_repair_end, ref: mrp_repair_rma0}
|
||||
- |
|
||||
|
||||
-
|
||||
I select invoiced after repair option in this "RMA00004" Repair order.
|
||||
so I create Invoice by click on "Make Invoice" wizard.
|
||||
-
|
||||
!record {model: mrp.repair.make_invoice, id: mrp_repair_make_invoice_0}:
|
||||
group: 1
|
||||
- |
|
||||
-
|
||||
I click on "Create Invoice" button of this wizard to make invoice.
|
||||
-
|
||||
!python {model: mrp.repair.make_invoice}: |
|
||||
self.make_invoices(cr, uid, [ref("mrp_repair_make_invoice_0")], {"active_ids": [ref("mrp_repair.mrp_repair_rma0")]})
|
||||
- |
|
||||
-
|
||||
I check that Invoice is created for this repair order.
|
||||
-
|
||||
!python {model: mrp.repair}: |
|
||||
obj_lines = self.pool.get('account.invoice.line')
|
||||
inv_obj = self.pool.get('account.invoice')
|
||||
repair_id = self.browse(cr, uid, [ref('mrp_repair_rma0')], context=context)[0]
|
||||
invoice_ids = inv_obj.search(cr, uid, [('partner_id', '=', repair_id.partner_id.id)])
|
||||
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"
|
||||
assert repair_id.invoice_id.id, _("No invoice exists for this repair order")
|
||||
|
||||
Reference in New Issue
Block a user