From 345845415d0e3a507cac078c4c5b887d7ab19213 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 28 Feb 2013 10:30:26 +0530 Subject: [PATCH 1/7] [IMP] change all data of stock yml bzr revid: fka@tinyerp.com-20130228050026-5yaf2ftrps77jlff --- addons/stock/__openerp__.py | 8 +- addons/stock/product.py | 5 +- addons/stock/stock.py | 1 - addons/stock/stock_demo.yml | 118 ++++++++++++++-------------- addons/stock/test/opening_stock.yml | 62 +++++++-------- addons/stock/test/shipment.yml | 103 ++++++++++++------------ 6 files changed, 146 insertions(+), 151 deletions(-) diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index b3d7e30f1ce..e1c96ba0c25 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -59,7 +59,6 @@ Dashboard / Reports for Warehouse Management will include: 'sequence': 16, 'demo': [ 'stock_demo.xml', -# 'stock_demo.yml', ], 'data': [ 'security/stock_security.xml', @@ -91,9 +90,10 @@ Dashboard / Reports for Warehouse Management will include: 'res_config_view.xml', ], 'test': [ -# 'test/opening_stock.yml', -# 'test/shipment.yml', -# 'test/stock_report.yml', + 'stock_demo.yml', + 'test/opening_stock.yml', + 'test/shipment.yml', + #'test/stock_report.yml', ], 'installable': True, 'application': True, diff --git a/addons/stock/product.py b/addons/stock/product.py index 1d56ce64988..b00f8615667 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -55,15 +55,14 @@ class product_product(osv.osv): if context is None: context = {} product_obj = self.pool.get('product.product').browse(cr, uid, product_id, context=context) - stock_input_acc = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id or False if not stock_input_acc: stock_input_acc = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id or False - + stock_output_acc = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id or False if not stock_output_acc: stock_output_acc = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id or False - + journal_id = product_obj.categ_id.property_stock_journal and product_obj.categ_id.property_stock_journal.id or False account_valuation = product_obj.categ_id.property_stock_valuation_account_id and product_obj.categ_id.property_stock_valuation_account_id.id or False return { diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 8e4611dc5d0..ed2b36bd1f5 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2233,7 +2233,6 @@ class stock_move(osv.osv): acc_valuation = accounts.get('property_stock_valuation_account_id', False) journal_id = accounts['stock_journal'] - if acc_dest == acc_valuation: raise osv.except_osv(_('Error!'), _('Cannot create Journal Entry, Output Account of this product and Valuation account on category of this product are same.')) diff --git a/addons/stock/stock_demo.yml b/addons/stock/stock_demo.yml index 99565f0c08c..8e9ea4977b8 100644 --- a/addons/stock/stock_demo.yml +++ b/addons/stock/stock_demo.yml @@ -1,99 +1,97 @@ - - !record {model: stock.location, id: location_refrigerator}: - name: Refrigerator + !record {model: stock.location, id: location_monitor}: + name: chicago shop usage: internal - - !record {model: stock.location, id: location_delivery_counter}: - name: Delivery Counter + !record {model: stock.location, id: stock_location_output}: + name: Output usage: internal - - !record {model: stock.location, id: location_refrigerator_small}: - name: Small Refrigerator + !record {model: stock.location, id: location_monitor_small}: + name: Small chicago shop usage: internal - location_id: location_refrigerator + location_id: location_monitor - !record {model: stock.location, id: location_opening}: name: opening usage: inventory - - !record {model: stock.location, id: location_convenience_shop}: - name: Convenient Store + !record {model: stock.location, id: stock_location_3}: + name: IT Suppliers usage: supplier - - !record {model: stock.warehouse, id: warehouse_icecream}: - name: Ice Cream Shop - lot_input_id: location_refrigerator - lot_stock_id: location_refrigerator - lot_output_id: location_delivery_counter + !record {model: stock.warehouse, id: stock_warehouse_shop0}: + name: Chicago Warehouse + lot_input_id: location_monitor + lot_stock_id: location_monitor + lot_output_id: stock_location_output - - !record {model: product.product, id: product_icecream}: - default_code: 001 - name: Ice Cream - type: product - categ_id: product.product_category_1 - list_price: 100.0 - standard_price: 70.0 - uom_id: product.product_uom_kgm - uom_po_id: product.product_uom_kgm - procure_method: make_to_stock + !record {model: product.product, id: product_product_6}: + default_code: LCD15 + name: 15” LCD Monitor + type: consu + categ_id: product.product_category_8 + list_price: 1200.0 + standard_price: 800.0 + uom_id: product.product_uom_unit + uom_po_id: product.product_uom_unit property_stock_inventory: location_opening valuation: real_time cost_method: average - property_stock_account_input: account.o_expense - property_stock_account_output: account.o_income - description: Ice cream can be mass-produced and thus is widely available in developed parts of the world. Ice cream can be purchased in large cartons (vats and squrounds) from supermarkets and grocery stores, in smaller quantities from ice cream shops, convenience stores, and milk bars, and in individual servings from small carts or vans at public events. - + property_stock_account_input: account.conf_o_expense + property_stock_account_output: account.conf_o_income - - !record {model: stock.production.lot, id: lot_icecream_0}: - name: Lot0 for Ice cream - product_id: product_icecream + !record {model: stock.production.lot, id: lot_monitor_0}: + name: Lot0 for LCD Monitor + product_id: product_product_6 - - !record {model: stock.production.lot, id: lot_icecream_1}: - name: Lot1 for Ice cream - product_id: product_icecream + !record {model: stock.production.lot, id: lot_monitor_1}: + name: Lot1 for LCD Monitor + product_id: product_product_6 - - !record {model: stock.inventory, id: stock_inventory_icecream}: - name: Inventory for icecream + !record {model: stock.inventory, id: stock_inventory_0}: + name: Starting Inventory + state: draft - - !record {model: stock.inventory.line, id: stock_inventory_line_icecream_lot0}: - product_id: product_icecream - product_uom: product.product_uom_kgm - inventory_id: stock_inventory_icecream + !record {model: stock.inventory.line, id: stock_inventory_line_3}: + product_id: product_product_6 + product_uom: product.product_uom_unit + inventory_id: stock_inventory_0 product_qty: 50.0 - prod_lot_id: lot_icecream_0 - location_id: location_refrigerator + prod_lot_id: lot_monitor_0 + location_id: location_monitor - - !record {model: stock.inventory.line, id: stock_inventory_line_icecream_lot1}: - product_id: product_icecream - product_uom: product.product_uom_kgm - inventory_id: stock_inventory_icecream + !record {model: stock.inventory.line, id: stock_inventory_line_monitor}: + product_id: product_product_6 + product_uom: product.product_uom_unit + inventory_id: stock_inventory_0 product_qty: 40.0 - prod_lot_id: lot_icecream_1 - location_id: location_refrigerator + prod_lot_id: lot_monitor_1 + location_id: location_monitor - !record {model: stock.picking, id: outgoing_shipment}: type: out - location_dest_id: location_delivery_counter + location_dest_id: stock_location_output - - !record {model: stock.move, id: outgoing_shipment_icecream}: + !record {model: stock.move, id: outgoing_shipment_monitor}: picking_id: outgoing_shipment - product_id: product_icecream - product_uom: product.product_uom_kgm + product_id: product_product_6 + product_uom: product.product_uom_unit product_qty: 130.0 - location_id: location_refrigerator - location_dest_id: location_delivery_counter + location_id: location_monitor + location_dest_id: stock_location_output - !record {model: stock.picking, id: incomming_shipment}: type: in invoice_state: 2binvoiced partner_id: base.res_partner_address_9 - location_dest_id: location_refrigerator + location_dest_id: location_monitor - - !record {model: stock.move, id: incomming_shipment_icecream}: + !record {model: stock.move, id: incomming_shipment_monitor}: picking_id: incomming_shipment - product_id: product_icecream - product_uom: product.product_uom_kgm + product_id: product_product_6 + product_uom: product.product_uom_unit product_qty: 50.0 - location_id: location_convenience_shop - location_dest_id: location_refrigerator + location_id: stock_location_3 + location_dest_id: location_monitor diff --git a/addons/stock/test/opening_stock.yml b/addons/stock/test/opening_stock.yml index 2e3eaeadc74..41b906e560c 100644 --- a/addons/stock/test/opening_stock.yml +++ b/addons/stock/test/opening_stock.yml @@ -1,42 +1,42 @@ - - I update the price of the Ice-cream. + I update the price of the 15” LCD Monitor. - !python {model: stock.change.standard.price}: | - context.update({'active_model':'product.product', 'active_id': ref('product_icecream'), 'active_ids':[ref('product_icecream')]}) + context.update({'active_model':'product.product', 'active_id': ref('product_product_6'), 'active_ids':[ref('product_product_6')]}) - !record {model: stock.change.standard.price, id: change_price}: - new_price: 120 + new_price: 1500 - !python {model: stock.change.standard.price}: | self.change_price(cr, uid, [ref('change_price')], context=context) - - I check price of Ice-cream after update price. + I check price of 15” LCD Monitor after update price. - !python {model: product.product}: | - product = self.browse(cr, uid, ref('product_icecream'), context=context) - assert product.standard_price == 120, "Price is not updated." + product = self.browse(cr, uid, ref('product_product_6'), context=context) + assert product.standard_price == 1500, "Price is not updated." - - I update the current stock of the Ice-cream with 10 kgm in Small Refrigerator in lot0. + I update the current stock of the 15” LCD Monitor with 10 unit in stock location shop1 in lot0. - !record {model: stock.change.product.qty, id: change_qty}: - location_id: location_refrigerator_small + location_id: location_monitor_small new_quantity: 10 - product_id: product_icecream - prodlot_id: lot_icecream_1 + product_id: product_product_6 + prodlot_id: lot_monitor_1 - !python {model: stock.change.product.qty}: | self.change_product_qty(cr, uid, [ref('change_qty')], context=context) - - I check available stock of Ice-cream after update stock. + I check available stock of 15” LCD Monitor after update stock. - !python {model: product.product}: | - product = self.browse(cr, uid, ref('product_icecream'), context=context) + product = self.browse(cr, uid, ref('product_product_6'), context=context) assert product.qty_available == 10, "Stock is not updated." - I merge inventory. - !python {model: stock.inventory.merge }: | - context.update({'active_model': 'stock.inventory', 'active_id': ref('stock_inventory_icecream'), 'active_ids': [ref('stock_inventory_icecream')]}) + context.update({'active_model': 'stock.inventory', 'active_id': ref('stock_inventory_0'), 'active_ids': [ref('stock_inventory_0')]}) - !record {model: stock.inventory.merge, id: merge_inventory}: - @@ -46,22 +46,22 @@ I cancel inventory. - !python {model: stock.inventory}: | - self.action_cancel_inventory(cr, uid, [ref('stock_inventory_icecream')]) + self.action_cancel_inventory(cr, uid, [ref('stock_inventory_0')]) - I reset to draft inventory. - !python {model: stock.inventory}: | - self.action_cancel_draft(cr, uid, [ref('stock_inventory_icecream')]) + self.action_cancel_draft(cr, uid, [ref('stock_inventory_0')]) - - I confirm physical inventory of Ice-cream which are came in different lots. + I confirm physical inventory of 15” LCD Monitor which are came in different lots. - !python {model: stock.inventory}: | - self.action_confirm(cr, uid, [ref('stock_inventory_icecream')], context=context) + self.action_confirm(cr, uid, [ref('stock_inventory_0')], context=context) - I check move details after confirmed physical inventory. - !python {model: stock.inventory}: | - inventory = self.browse(cr, uid, ref('stock_inventory_icecream'), context=context) + inventory = self.browse(cr, uid, ref('stock_inventory_0'), context=context) assert len(inventory.move_ids) == len(inventory.inventory_line_id), "moves are not correspond." for move_line in inventory.move_ids: for line in inventory.inventory_line_id: @@ -77,15 +77,15 @@ I split inventory line. - !python {model: stock.inventory.line.split}: | - context.update({'active_model': 'stock.inventory.line', 'active_id': ref('stock_inventory_line_icecream_lot0'), 'active_ids': [ref('stock_inventory_line_icecream_lot0')]}) + context.update({'active_model': 'stock.inventory.line', 'active_id': ref('stock_inventory_line_3'), 'active_ids': [ref('stock_inventory_line_3')]}) - !record {model: stock.inventory.line.split, id: split_inventory_lot0}: use_exist: True line_exist_ids: - quantity: 6 - prodlot_id: lot_icecream_0 + prodlot_id: lot_monitor_0 - quantity: 4 - prodlot_id: lot_icecream_0 + prodlot_id: lot_monitor_0 - !python {model: stock.inventory.line.split }: | self.split_lot(cr, uid, [ref('split_inventory_lot0')], context=context) @@ -93,39 +93,39 @@ I fill inventory line. - !python {model: stock.fill.inventory}: | - context.update({'active_model': 'stock.inventory', 'active_id': ref('stock_inventory_icecream'), 'active_ids': [ref('stock_inventory_icecream')]}) + context.update({'active_model': 'stock.inventory', 'active_id': ref('stock_inventory_0'), 'active_ids': [ref('stock_inventory_0')]}) - !record {model: stock.fill.inventory, id: fill_inventory}: - location_id: location_refrigerator + location_id: location_monitor recursive: True - !python {model: stock.fill.inventory }: | self.fill_inventory(cr, uid, [ref('fill_inventory')], context=context) - - Now I check vitual stock of Ice-cream after confirmed physical inventory. + Now I check vitual stock of 15” LCD Monitor after confirmed physical inventory. - !python {model: product.product}: | - product = self.browse(cr, uid, ref('product_icecream'), context=context) + product = self.browse(cr, uid, ref('product_product_6'), context=context) assert product.virtual_available == 100, "Vitual stock is not updated." - - I close physical inventory of Ice-cream. + I close physical inventory of 15” LCD Monitor. - !python {model: stock.inventory}: | - self.action_done(cr, uid, [ref('stock_inventory_icecream')], context=context) + self.action_done(cr, uid, [ref('stock_inventory_0')], context=context) - - I check closed move and real stock of Ice-cream after closed physical inventory. + I check closed move and real stock of 15” LCD Monitor after closed physical inventory. - !python {model: stock.inventory}: | - inventory = self.browse(cr, uid, ref('stock_inventory_icecream'), context=context) + inventory = self.browse(cr, uid, ref('stock_inventory_0'), context=context) assert inventory.state == 'done', "inventory is not closed." for move_line in inventory.move_ids: assert move_line.state == 'done', "Move is not closed." - product = self.pool.get('product.product').browse(cr, uid, ref('product_icecream'), context=context) + product = self.pool.get('product.product').browse(cr, uid, ref('product_product_6'), context=context) product.qty_available == 100, "Real stock is not updated." - I check stock in lot. - !python {model: stock.production.lot}: | - lot = self.browse(cr, uid, ref('lot_icecream_0'), context=context) + lot = self.browse(cr, uid, ref('lot_monitor_0'), context=context) assert lot.stock_available == 50, "Stock in lot is not correspond." diff --git a/addons/stock/test/shipment.yml b/addons/stock/test/shipment.yml index b30feccdacf..27d5c44d199 100644 --- a/addons/stock/test/shipment.yml +++ b/addons/stock/test/shipment.yml @@ -1,5 +1,5 @@ - - I confirm outgoing shipment of 130 kgm Ice-cream. + I confirm outgoing shipment of 130 unit 15” LCD Monitor. - !workflow {model: stock.picking, action: button_confirm, ref: outgoing_shipment} - @@ -12,18 +12,18 @@ assert move_line.state == "confirmed", "Move should be confirmed." - - Now I check vitual stock of Ice-cream after confirmed outgoing shipment. + Now I check vitual stock of 15” LCD Monitor after confirmed outgoing shipment. - !python {model: product.product}: | - product = self.browse(cr, uid, ref('product_icecream'), context=context) + product = self.browse(cr, uid, ref('product_product_6'), context=context) product.virtual_available == -30, "Vitual stock is not updated." - - I confirm incomming shipment of 50 kgm Ice-cream. + I confirm incomming shipment of 50 unit 15” LCD Monitor. - !workflow {model: stock.picking, action: button_confirm, ref: incomming_shipment} - - I receive 40kgm Ice-cream so I make backorder of incomming shipment for 40 kgm. + I receive 40 unit 15” LCD Monitor so I make backorder of incomming shipment for 40 unit. - !python {model: stock.partial.picking}: | context.update({'active_model': 'stock.picking', 'active_id': ref('incomming_shipment'), 'active_ids': [ref('incomming_shipment')]}) @@ -31,11 +31,11 @@ !record {model: stock.partial.picking, id: partial_incomming}: move_ids: - quantity: 40 - product_id: product_icecream - product_uom: product.product_uom_kgm - move_id: incomming_shipment_icecream - location_id: location_convenience_shop - location_dest_id: location_refrigerator + product_id: product_product_6 + product_uom: product.product_uom_unit + move_id: incomming_shipment_monitor + location_id: stock_location_3 + location_dest_id: location_monitor - !python {model: stock.partial.picking }: | self.do_partial(cr, uid, [ref('partial_incomming')], context=context) @@ -51,16 +51,16 @@ assert move_line.product_qty == 40, "Qty in backorder does not correspond." assert move_line.state == 'done', "Move line of backorder should be closed." - - I receive another 10kgm Ice-cream. + I receive another 10 unit 15” LCD Monitor. - !record {model: stock.partial.picking, id: partial_incomming}: move_ids: - quantity: 10 - product_id: product_icecream - product_uom: product.product_uom_kgm - move_id: incomming_shipment_icecream - location_id: location_convenience_shop - location_dest_id: location_refrigerator + product_id: product_product_6 + product_uom: product.product_uom_unit + move_id: incomming_shipment_monitor + location_id: stock_location_3 + location_dest_id: location_monitor - !python {model: stock.partial.picking }: | self.do_partial(cr, uid, [ref('partial_incomming')], context=context) @@ -77,7 +77,7 @@ assert move_line.state == 'done', "Move line should be closed." - - I return last incomming shipment for 10 kgm Ice-cream. + I return last incomming shipment for 10 unit 15” LCD Monitor. - !record {model: stock.return.picking, id: return_incomming}: invoice_state: none @@ -115,11 +115,11 @@ I check available stock after received incomming shipping. - !python {model: product.product}: | - product = self.browse(cr, uid, ref('product_icecream'), context=context) + product = self.browse(cr, uid, ref('product_product_6'), context=context) assert product.qty_available == 140, "Stock does not correspond." assert product.virtual_available == 0, "Vitual stock does not correspond." - - I split incomming shipment into lots. each lot contain 10 kgm Ice-cream. + I split incomming shipment into lots. each lot contain 10 unit 15” LCD Monitor. - !python {model: stock.picking}: | shipment = self.browse(cr, uid, ref("incomming_shipment")) @@ -147,7 +147,7 @@ lot = self.pool.get('stock.move.split').browse(cr, uid, ref('split_lot_incomming'), context=context) lot_ids = self.pool.get('stock.production.lot').search(cr, uid, [('name','in',[x.name for x in lot.line_ids])]) assert len(lot_ids) == 4, 'lots of incomming shipment are not correspond.' - move_ids = self.search(cr, uid, [('location_dest_id','=',ref('location_refrigerator')),('prodlot_id','in',lot_ids)]) + move_ids = self.search(cr, uid, [('location_dest_id','=',ref('location_monitor')),('prodlot_id','in',lot_ids)]) assert len(move_ids) == 4, 'move lines are not correspond per prodcution lot after splited.' for move in self.browse(cr, uid, move_ids, context=context): assert move.prodlot_id.name in ['incoming_lot0', 'incoming_lot1', 'incoming_lot2', 'incoming_lot3'], "lot does not correspond." @@ -171,39 +171,39 @@ assert account_move_line.credit == 0.0, "Credit amount does not correspond." assert account_move_line.debit == 800.0, "Debit amount does not correspond." - - I consume 1 kgm ice-cream from each incoming lots into internal production. + I consume 1 unit 15” LCD Monitor from each incoming lots into internal production. - !record {model: stock.move.consume, id: consume_lot_incomming}: product_qty: 1 - location_id: location_refrigerator + location_id: location_monitor - !python {model: stock.move.consume}: | self.do_move_consume(cr, uid, [ref('consume_lot_incomming')], context=context) - - I scrap 10 gm ice-cream from each incoming lots into scrap location. + I scrap 1 unit 15” LCD Monitor from each incoming lots into scrap location. - !record {model: stock.move.scrap, id: scrap_lot_incomming}: - product_qty: 0.010 + product_qty: 1 - !python {model: stock.move.scrap}: | self.move_scrap(cr, uid, [ref('scrap_lot_incomming')], context=context) - - I check stock in scrap location and refrigerator location. + I check stock in scrap location and stock location shop0. - !python {model: stock.location}: | - ctx = {'product_id': ref('product_icecream')} - refrigerator_location = self.pool.get('stock.location').browse(cr, uid, ref('location_refrigerator'), context=ctx) - assert refrigerator_location.stock_real == 135.96, 'stock does not correspond in refrigerator location.' + ctx = {'product_id': ref('product_product_6')} + refrigerator_location = self.pool.get('stock.location').browse(cr, uid, ref('location_monitor'), context=ctx) + assert refrigerator_location.stock_real == 36.0, 'stock does not correspond in stock location shop0.' scrapped_location = self.browse(cr, uid, ref('stock_location_scrapped'), context=ctx) - assert scrapped_location.stock_real == 0.010*4, 'scraped stock does not correspond in scrap location.' + assert scrapped_location.stock_real == 1*4, 'scraped stock does not correspond in scrap location.' - I check availabile stock after consumed and scraped. - !python {model: product.product}: | - product = self.browse(cr, uid, ref('product_icecream'), context=context) - assert product.qty_available == 135.96, "Stock does not correspond." - assert round(product.virtual_available, 2) == -4.04, "Vitual stock does not correspond." + product = self.browse(cr, uid, ref('product_product_6'), context=context) + assert product.qty_available == 136.0, "Stock does not correspond." + assert round(product.virtual_available, 2) == -4.00, "Vitual stock does not correspond." - I trace all incoming lots. - @@ -212,40 +212,39 @@ lot_ids = self.search(cr, uid, [('name', 'in', [x.name for x in lot.line_ids])]) self.action_traceability(cr, uid, lot_ids, context=context) - - I check outgoing shipment after stock availablity in refrigerator. + I check outgoing shipment after stock availablity in Chicago shop. - !python {model: stock.picking}: | shipment = self.browse(cr, uid, ref("outgoing_shipment"), context=context) - self.pool.get('stock.move').action_assign(cr, uid, [x.id for x in shipment.move_lines]) #TOFIX: assignment of move lines should be call before testing assigment otherwise picking never gone in assign state - #TOFIX: shipment should be assigned if stock available - #assert shipment.state == "assigned", "Shipment should be assigned." - #for move_line in shipment.move_lines: - # assert move_line.state == "assigned", "Move should be assigned." + self.pool.get('stock.move').action_assign(cr, uid, [x.id for x in shipment.move_lines]) + assert shipment.state == "assigned", "Shipment should be assigned." + for move_line in shipment.move_lines: + assert move_line.state == "assigned", "Move should be assigned." self.force_assign(cr, uid, [shipment.id]) - - I deliver 5kgm Ice-cream to customer so I make partial deliver + I deliver 5 unit 15” LCD Monitor to customer so I make partial deliver - !python {model: stock.partial.move}: | - context.update({'active_model': 'stock.move', 'active_id': ref('outgoing_shipment_icecream'), 'active_ids': [ref('outgoing_shipment_icecream')]}) + context.update({'active_model': 'stock.move', 'active_id': ref('outgoing_shipment_monitor'), 'active_ids': [ref('outgoing_shipment_monitor')]}) - - !record {model: stock.partial.move, id: partial_outgoing_icecream}: + !record {model: stock.partial.move, id: partial_outgoing_monitor}: move_ids: - quantity: 5 - product_id: product_icecream - product_uom: product.product_uom_kgm - move_id: outgoing_shipment_icecream - location_id: location_refrigerator - location_dest_id: location_delivery_counter + product_id: product_product_6 + product_uom: product.product_uom_unit + move_id: outgoing_shipment_monitor + location_id: location_monitor + location_dest_id: stock_location_output - !python {model: stock.partial.move }: | - self.do_partial(cr, uid, [ref('partial_outgoing_icecream')], context=context) + self.do_partial(cr, uid, [ref('partial_outgoing_monitor')], context=context) - - I packing outgoing shipment into box per 10kgm with unique tracking lot. + I packing outgoing shipment into box per 10 unit with unique tracking lot. - !python {model: stock.move}: | stock_split = self.pool.get('stock.split.into') - move = self.browse(cr, uid, ref('outgoing_shipment_icecream'), context=context) + move = self.browse(cr, uid, ref('outgoing_shipment_monitor'), context=context) context.update({'active_model': 'stock.move', 'active_id': move.id, 'active_ids': [move.id]}) total_qty = move.product_qty split_qty = 10 @@ -277,6 +276,6 @@ I check availaible stock after deliver. - !python {model: product.product}: | - product = self.browse(cr, uid, ref('product_icecream'), context=context) - assert round(product.qty_available, 2) == 5.96, "Stock does not correspond." - assert round(product.virtual_available, 2) == -4.04, "Vitual stock does not correspond." + product = self.browse(cr, uid, ref('product_product_6'), context=context) + assert round(product.qty_available, 2) == 6, "Stock does not correspond." + assert round(product.virtual_available, 2) == -4.00, "Vitual stock does not correspond." From 4de42a4254bb6abc30321d183c8609e04dc18009 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 28 Feb 2013 12:01:46 +0530 Subject: [PATCH 2/7] [IMP] improve stock yml bzr revid: fka@tinyerp.com-20130228063146-kfy538aq3p1hh029 --- addons/stock/stock_demo.yml | 4 ++-- addons/stock/test/shipment.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/stock/stock_demo.yml b/addons/stock/stock_demo.yml index 8e9ea4977b8..b79fd68d509 100644 --- a/addons/stock/stock_demo.yml +++ b/addons/stock/stock_demo.yml @@ -38,8 +38,8 @@ property_stock_inventory: location_opening valuation: real_time cost_method: average - property_stock_account_input: account.conf_o_expense - property_stock_account_output: account.conf_o_income + property_stock_account_input: account.conf_o_income + property_stock_account_output: account.conf_o_expense - !record {model: stock.production.lot, id: lot_monitor_0}: name: Lot0 for LCD Monitor diff --git a/addons/stock/test/shipment.yml b/addons/stock/test/shipment.yml index 27d5c44d199..4622e0072bc 100644 --- a/addons/stock/test/shipment.yml +++ b/addons/stock/test/shipment.yml @@ -165,11 +165,11 @@ for account_move_line in account_move.line_id: for stock_move in incomming_shipment.move_lines: if account_move_line.account_id.id == stock_move.product_id.property_stock_account_input.id: - assert account_move_line.credit == 800.0, "Credit amount does not correspond." + assert account_move_line.credit == 10000.0, "Credit amount does not correspond." assert account_move_line.debit == 0.0, "Debit amount does not correspond." else: assert account_move_line.credit == 0.0, "Credit amount does not correspond." - assert account_move_line.debit == 800.0, "Debit amount does not correspond." + assert account_move_line.debit == 10000.0, "Debit amount does not correspond." - I consume 1 unit 15” LCD Monitor from each incoming lots into internal production. - @@ -193,7 +193,7 @@ !python {model: stock.location}: | ctx = {'product_id': ref('product_product_6')} refrigerator_location = self.pool.get('stock.location').browse(cr, uid, ref('location_monitor'), context=ctx) - assert refrigerator_location.stock_real == 36.0, 'stock does not correspond in stock location shop0.' + assert refrigerator_location.stock_real == 136.0, 'stock does not correspond in stock location shop0.' scrapped_location = self.browse(cr, uid, ref('stock_location_scrapped'), context=ctx) assert scrapped_location.stock_real == 1*4, 'scraped stock does not correspond in scrap location.' From 506b7c9c64f5e0022aa15aeab05d18ca6b766fed Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 28 Feb 2013 12:13:38 +0530 Subject: [PATCH 3/7] [IMP] change data of stock_report.yml bzr revid: fka@tinyerp.com-20130228064338-r93gtraqgrfc76mc --- addons/stock/__openerp__.py | 2 +- addons/stock/test/shipment.yml | 4 ++-- addons/stock/test/stock_report.yml | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index e1c96ba0c25..323fac889be 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -93,7 +93,7 @@ Dashboard / Reports for Warehouse Management will include: 'stock_demo.yml', 'test/opening_stock.yml', 'test/shipment.yml', - #'test/stock_report.yml', + 'test/stock_report.yml', ], 'installable': True, 'application': True, diff --git a/addons/stock/test/shipment.yml b/addons/stock/test/shipment.yml index 4622e0072bc..96273a081b7 100644 --- a/addons/stock/test/shipment.yml +++ b/addons/stock/test/shipment.yml @@ -192,8 +192,8 @@ - !python {model: stock.location}: | ctx = {'product_id': ref('product_product_6')} - refrigerator_location = self.pool.get('stock.location').browse(cr, uid, ref('location_monitor'), context=ctx) - assert refrigerator_location.stock_real == 136.0, 'stock does not correspond in stock location shop0.' + monitor_location = self.pool.get('stock.location').browse(cr, uid, ref('location_monitor'), context=ctx) + assert monitor_location.stock_real == 136.0, 'stock does not correspond in stock location shop0.' scrapped_location = self.browse(cr, uid, ref('stock_location_scrapped'), context=ctx) assert scrapped_location.stock_real == 1*4, 'scraped stock does not correspond in scrap location.' diff --git a/addons/stock/test/stock_report.yml b/addons/stock/test/stock_report.yml index b1590a4d819..b16ade8a085 100644 --- a/addons/stock/test/stock_report.yml +++ b/addons/stock/test/stock_report.yml @@ -4,7 +4,7 @@ !python {model: stock.location}: | import os from openerp import netsvc, tools - (data, format) = netsvc.LocalService('report.lot.stock.overview').create(cr, uid, [ref('location_refrigerator')], {}, {}) + (data, format) = netsvc.LocalService('report.lot.stock.overview').create(cr, uid, [ref('location_monitor')], {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'stock-overview'+format), 'wb+').write(data) - @@ -13,7 +13,7 @@ !python {model: stock.location}: | import os from openerp import netsvc, tools - (data, format) = netsvc.LocalService('report.lot.stock.overview_all').create(cr, uid, [ref('location_refrigerator')], {}, {}) + (data, format) = netsvc.LocalService('report.lot.stock.overview_all').create(cr, uid, [ref('location_monitor')], {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'stock-overviewall'+format), 'wb+').write(data) - @@ -22,7 +22,7 @@ !python {model: stock.inventory}: | import os from openerp import netsvc, tools - (data, format) = netsvc.LocalService('report.stock.inventory.move').create(cr, uid, [ref('stock_inventory_icecream')], {}, {}) + (data, format) = netsvc.LocalService('report.stock.inventory.move').create(cr, uid, [ref('stock_inventory_0')], {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'stock-stock_inventory_move.'+format), 'wb+').write(data) - @@ -40,7 +40,7 @@ !python {model: product.product}: | import os from openerp import netsvc, tools - (data, format) = netsvc.LocalService('report.stock.product.history').create(cr, uid, [ref('product_icecream')], {}, {}) + (data, format) = netsvc.LocalService('report.stock.product.history').create(cr, uid, [ref('product_product_6')], {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'stock-product_stock_report.'+format), 'wb+').write(data) From 721daed4c6bdd35ae44476ad9ae0c3edbb823e89 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 28 Feb 2013 14:35:06 +0530 Subject: [PATCH 4/7] [IMP] add stock_users.yml file in stock for test access rights bzr revid: fka@tinyerp.com-20130228090506-esh7d6nycoqqymay --- addons/stock/__openerp__.py | 1 + addons/stock/stock_demo.yml | 10 ++++++++++ addons/stock/test/stock_users.yml | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 addons/stock/test/stock_users.yml diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index 323fac889be..dd2a996f6dd 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -90,6 +90,7 @@ Dashboard / Reports for Warehouse Management will include: 'res_config_view.xml', ], 'test': [ + 'test/stock_users.yml', 'stock_demo.yml', 'test/opening_stock.yml', 'test/shipment.yml', diff --git a/addons/stock/stock_demo.yml b/addons/stock/stock_demo.yml index b79fd68d509..64be92f8d06 100644 --- a/addons/stock/stock_demo.yml +++ b/addons/stock/stock_demo.yml @@ -1,3 +1,8 @@ +- + Only stock manager can create location,warehouse and product, so let's check data with giving the access rights of manager +- + !context + uid: 'res_users_stock_manager' - !record {model: stock.location, id: location_monitor}: name: chicago shop @@ -40,6 +45,11 @@ cost_method: average property_stock_account_input: account.conf_o_income property_stock_account_output: account.conf_o_expense +- + Stock user can handled production lot,inventory and picking, so let's check data with giving the access rights of user +- + !context + uid: 'res_users_stock_user' - !record {model: stock.production.lot, id: lot_monitor_0}: name: Lot0 for LCD Monitor diff --git a/addons/stock/test/stock_users.yml b/addons/stock/test/stock_users.yml new file mode 100644 index 00000000000..82d48197b0d --- /dev/null +++ b/addons/stock/test/stock_users.yml @@ -0,0 +1,20 @@ +- + Create a user as 'Stock Manager' +- + !record {model: res.users, id: res_users_stock_manager}: + company_id: base.main_company + name: Stock Manager + login: sam + password: sam + groups_id: + - stock.group_stock_manager +- + Create a user as 'Stock User' +- + !record {model: res.users, id: res_users_stock_user}: + company_id: base.main_company + name: Stock User + login: sau + password: sau + groups_id: + - stock.group_stock_user From 8009999e2981260e73fd11e11bacfa8a1fd84e2f Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 28 Feb 2013 18:58:36 +0530 Subject: [PATCH 5/7] [IMP] give access rights to the user in stock ymls bzr revid: fka@tinyerp.com-20130228132836-e2f7rknoodpqix0p --- addons/stock/security/stock_security.xml | 2 +- addons/stock/test/opening_stock.yml | 30 ++++++++++++++++++++++++ addons/stock/test/stock_report.yml | 5 ++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/addons/stock/security/stock_security.xml b/addons/stock/security/stock_security.xml index 10ae6a16d59..e51f20c67c9 100644 --- a/addons/stock/security/stock_security.xml +++ b/addons/stock/security/stock_security.xml @@ -10,7 +10,7 @@ Manager - + diff --git a/addons/stock/test/opening_stock.yml b/addons/stock/test/opening_stock.yml index 41b906e560c..9efcfd3af99 100644 --- a/addons/stock/test/opening_stock.yml +++ b/addons/stock/test/opening_stock.yml @@ -1,3 +1,8 @@ +- + Only stock manager can change the price and update stock of products, so let's check data with giving the access rights of manager +- + !context + uid: 'res_users_stock_manager' - I update the price of the 15” LCD Monitor. - @@ -32,6 +37,11 @@ !python {model: product.product}: | product = self.browse(cr, uid, ref('product_product_6'), context=context) assert product.qty_available == 10, "Stock is not updated." +- + Stock user can merge inventory, so let's check data with giving the access rights of user. +- + !context + uid: 'res_users_stock_user' - I merge inventory. - @@ -42,11 +52,21 @@ - !python {model: stock.inventory.merge }: | self.do_merge(cr, uid, [ref('merge_inventory')], context=context) +- + Only stock manager cancelled inventory, so let's check data with giving the access rights of manager +- + !context + uid: 'res_users_stock_manager' - I cancel inventory. - !python {model: stock.inventory}: | self.action_cancel_inventory(cr, uid, [ref('stock_inventory_0')]) +- + stock user can reset inventory, so let's check data with giving the access rights of user +- + !context + uid: 'res_users_stock_user' - I reset to draft inventory. - @@ -108,11 +128,21 @@ !python {model: product.product}: | product = self.browse(cr, uid, ref('product_product_6'), context=context) assert product.virtual_available == 100, "Vitual stock is not updated." +- + Only stock manager can close physical inventory, so let's check data with giving the access rights of manager +- + !context + uid: 'res_users_stock_manager' - I close physical inventory of 15” LCD Monitor. - !python {model: stock.inventory}: | self.action_done(cr, uid, [ref('stock_inventory_0')], context=context) +- + Stock user can check closed move and real stock, so let's check data with giving the access rights of user +- + !context + uid: 'res_users_stock_user' - I check closed move and real stock of 15” LCD Monitor after closed physical inventory. - diff --git a/addons/stock/test/stock_report.yml b/addons/stock/test/stock_report.yml index b16ade8a085..f1a31f23d93 100644 --- a/addons/stock/test/stock_report.yml +++ b/addons/stock/test/stock_report.yml @@ -1,3 +1,8 @@ +- + Stock user can print all reports related to stock, so let's check data with giving the access rights of user. +- + !context + uid: 'res_users_stock_user' - I print a stock overview report of location. - From 8eb3f28c28d54a7cca27ac274f78054db9185991 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 1 Mar 2013 11:12:53 +0530 Subject: [PATCH 6/7] [IMP] remove space bzr revid: fka@tinyerp.com-20130301054253-qbep31elzopq6xa4 --- addons/stock/product.py | 5 +++-- addons/stock/stock.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/stock/product.py b/addons/stock/product.py index b00f8615667..254eb53d255 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -55,14 +55,15 @@ class product_product(osv.osv): if context is None: context = {} product_obj = self.pool.get('product.product').browse(cr, uid, product_id, context=context) + stock_input_acc = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id or False if not stock_input_acc: stock_input_acc = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id or False - + stock_output_acc = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id or False if not stock_output_acc: stock_output_acc = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id or False - + journal_id = product_obj.categ_id.property_stock_journal and product_obj.categ_id.property_stock_journal.id or False account_valuation = product_obj.categ_id.property_stock_valuation_account_id and product_obj.categ_id.property_stock_valuation_account_id.id or False return { diff --git a/addons/stock/stock.py b/addons/stock/stock.py index ed2b36bd1f5..8e4611dc5d0 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2233,6 +2233,7 @@ class stock_move(osv.osv): acc_valuation = accounts.get('property_stock_valuation_account_id', False) journal_id = accounts['stock_journal'] + if acc_dest == acc_valuation: raise osv.except_osv(_('Error!'), _('Cannot create Journal Entry, Output Account of this product and Valuation account on category of this product are same.')) From b6cbd45d01274615bdb1ee17a831dbddc4fdc091 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 1 Mar 2013 11:17:45 +0530 Subject: [PATCH 7/7] [IMP] remove space bzr revid: fka@tinyerp.com-20130301054745-52t0n0mh8b3xo4qt --- addons/stock/product.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/stock/product.py b/addons/stock/product.py index 254eb53d255..1d56ce64988 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -55,15 +55,15 @@ class product_product(osv.osv): if context is None: context = {} product_obj = self.pool.get('product.product').browse(cr, uid, product_id, context=context) - + stock_input_acc = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id or False if not stock_input_acc: stock_input_acc = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id or False - + stock_output_acc = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id or False if not stock_output_acc: stock_output_acc = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id or False - + journal_id = product_obj.categ_id.property_stock_journal and product_obj.categ_id.property_stock_journal.id or False account_valuation = product_obj.categ_id.property_stock_valuation_account_id and product_obj.categ_id.property_stock_valuation_account_id.id or False return {