From 4f149e642b7e4e9cf5dc298d895c80fef5ffc298 Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Fri, 29 Jul 2011 16:49:53 +0530 Subject: [PATCH] [IMP]stock:Improvement in yml bzr revid: mma@tinyerp.com-20110729111953-0mbb9za6nhn0hhl9 --- addons/stock/__openerp__.py | 1 + addons/stock/report/UPS.xml | 28 ------ addons/stock/report/__init__.py | 1 - addons/stock/report/ups.py | 39 -------- addons/stock/test/stock_test.yml | 116 +++++++++++++++++++++-- addons/stock/test/stock_test_wizard.yml | 120 ++++++++++++++++++++++++ addons/stock/wizard/__init__.py | 1 - addons/stock/wizard/stock_ups.py | 95 ------------------- addons/stock/wizard/stock_ups_view.xml | 56 ----------- 9 files changed, 231 insertions(+), 226 deletions(-) delete mode 100644 addons/stock/report/UPS.xml delete mode 100644 addons/stock/report/ups.py create mode 100644 addons/stock/test/stock_test_wizard.yml delete mode 100644 addons/stock/wizard/stock_ups.py delete mode 100644 addons/stock/wizard/stock_ups_view.xml diff --git a/addons/stock/__openerp__.py b/addons/stock/__openerp__.py index 1a33fd3012c..3447f0c8358 100644 --- a/addons/stock/__openerp__.py +++ b/addons/stock/__openerp__.py @@ -79,6 +79,7 @@ Thanks to the double entry management, the inventory controlling is powerful and ], 'test': ['test/stock_test.yml', 'test/stock_report.yml', + 'test/stock_test_wizard.yml', ], 'installable': True, 'active': False, diff --git a/addons/stock/report/UPS.xml b/addons/stock/report/UPS.xml deleted file mode 100644 index 0349fda556d..00000000000 --- a/addons/stock/report/UPS.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - ES - - 1 - - - PP - - - - - diff --git a/addons/stock/report/__init__.py b/addons/stock/report/__init__.py index 18bfe2609c2..412e77f3f17 100644 --- a/addons/stock/report/__init__.py +++ b/addons/stock/report/__init__.py @@ -20,7 +20,6 @@ ############################################################################## import product_stock -import ups import picking import lot_overview_all import report_stock diff --git a/addons/stock/report/ups.py b/addons/stock/report/ups.py deleted file mode 100644 index fb8483341ec..00000000000 --- a/addons/stock/report/ups.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from report.interface import report_rml - -class report_custom(report_rml): - def create(self, uid, ids, datas, context): - datas.setdefault('form', {}) - datas['form'].setdefault('weight', 3.0) - - datas['model'] = 'stock.move.lot' - datas['ids'] = ids - del datas['id'] - - return (super(report_custom, self).create(uid, ids, datas, context), 'pdf') - -report_custom('report.stock.move.lot.ups_xml', 'stock.move.lot', 'addons/stock/report/UPS.xml', None) - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/stock/test/stock_test.yml b/addons/stock/test/stock_test.yml index 762908e6b0c..2a6b7b37aeb 100644 --- a/addons/stock/test/stock_test.yml +++ b/addons/stock/test/stock_test.yml @@ -205,8 +205,9 @@ - !record {model: product.product, id: product_product_hpcdwriters0}: categ_id: stock.product_category_computer0 - cost_method: standard - list_price: 1000.0 + cost_method: average + list_price: 1500.0 + standard_price: 1500.0 mes_type: fixed name: HP CD writers procure_method: make_to_stock @@ -220,7 +221,47 @@ uom_po_id: product.product_uom_unit property_account_expense: account_account_productpurchase0 property_account_income: account_account_productsale0 +- + I create change product quantity for product HP CD writers. +- + !record {model: stock.change.product.qty, id: stock_change_product_qty0}: + product_id: stock.product_product_hpcdwriters0 + new_quantity: 10 + location_id: stock.stock_location_stock +- + I apply the new quantity on product HP CD writers. +- + !python {model: stock.change.product.qty }: | + self.change_product_qty(cr, uid, [ref("stock_change_product_qty0")], {"lang": 'en_US', "active_model": + "stock.change.product.qty", "active_ids": ref("stock.product_product_hpcdwriters0"), "tz": False, "active_id":ref('stock.product_product_hpcdwriters0')}) +- + I Read quantity on product HP CD writers. +- + !python {model: stock.location }: | + self.read(cr, uid, [ref("stock.stock_location_stock")],['stock_real_value','stock_virtual'], {'lang': 'en_GB', 'tz': False, 'active_model': 'product.product', 'bin_size': True, 'active_ids': [ref("stock.product_product_hpcdwriters0")], 'product_id':ref("stock.product_product_hpcdwriters0"), 'active_id': ref("stock.product_product_hpcdwriters0")}) +- + I create change location. +- + !python {model: stock.location }: | + to=self.browse(cr,uid,ref('stock.stock_location_stock')) + form=self.browse(cr,uid,ref('stock.stock_location_locations')) + self.picking_type_get(cr, uid, to, form) +- + I create change product standard price for product HP CD writers. +- + !record {model: stock.change.standard.price, id: stock_change_standard_price0}: + new_price: 15 + stock_account_input: account_account_receivable0 + stock_account_output: account_account_payable0 + stock_journal: account_journal_purchasejournal0 + enable_stock_in_out_acc: True +- + I apply the new product standard price on product HP CD writers. +- + !python {model: stock.change.standard.price }: | + self.change_price(cr, uid, [ref("stock_change_product_qty0")], {"lang": 'en_US', "active_model": + "product.product", "active_ids": [ref("stock.product_product_hpcdwriters0")], "tz": False, "active_id":ref('stock.product_product_hpcdwriters0')}) - I create Physical Inventory for the products. - @@ -241,14 +282,62 @@ product_uom: product.product_uom_unit name: Physical inventory state: draft - - +- + I create merge Inventory for the products. +- + !record {model: stock.inventory, id: stock_inventory_mergeinventoy0}: + company_id: base.main_company + date: !eval time.strftime('%Y-%m-%d %H:%M:%S') + date_done: !eval time.strftime('%Y-%m-%d %H:%M:%S') + inventory_line_id: + - company_id: base.main_company + location_id: stock.stock_location_stock + product_id: stock.product_product_hpcdwriters0 + product_qty: 20.0 + product_uom: product.product_uom_unit + - company_id: base.main_company + location_id: stock.stock_location_stock + product_id: stock.product_product_hppaviliondesktoppcs0 + product_qty: 20.0 + product_uom: product.product_uom_unit + name: Physical inventory + state: draft +- + I merge inventory . +- + !python {model: stock.inventory.merge}: | + self.do_merge(cr, uid, [ref("stock_inventory_mergeinventoy0")], {"lang": 'en_US', + "full": "1", "tz": False, "active_model": "stock.inventory", "active_ids": + [ref("stock_inventory_physicalinventoy0"), ref("stock_inventory_mergeinventoy0")], "active_id": ref("stock_inventory_physicalinventoy0"), }) - I confirm the Inventory for HP CD writers. - !python {model: stock.inventory}: | self.action_confirm(cr,uid,[ref('stock_inventory_physicalinventoy0')]) self.action_done(cr,uid,[ref('stock_inventory_physicalinventoy0')]) +- + I create stock.inventory.line.split record. +- + !record {model: stock.inventory.line.split, id: stock_inventory_line_0}: + line_ids: + - name: '00002-stock-test' + quantity: 5 + use_exist: False + product_id: stock.product_product_hpcdwriters0 + product_uom: product.product_uom_unit + use_exist: False + qty: 10 +- + I Split stock.inventory.line into production line. +- + !python {model: stock.inventory.line.split}: | + move_obj=self.pool.get('stock.inventory.line') + product_obj=self.pool.get('product.product') + product_id=product_obj.search(cr,uid,[('name','=','HP CD writers')]) + move_ids=move_obj.search(cr,uid,[('product_id','in',product_id)]) + self.split_lot(cr, uid, [ref("stock_inventory_line_0")], {"lang": 'en_US', "active_model": + "stock.inventory.line", "active_ids": move_ids, "tz": False, "active_id":move_ids[0] + }) - I create stock.fill.inventory . - @@ -284,7 +373,6 @@ "stock.move", "active_ids": move_ids, "tz": False, "active_id":move_ids[0] }) - - In Order to test the picking I create picking with move lines. - !record {model: stock.picking, id: stock_picking_0}: @@ -307,7 +395,22 @@ move_type: direct type: internal - +- + I create stock split.into quantity record. +- + !record {model: stock.split.into, id: stock_split_into0}: + quantity: 1 +- + I apply the split quantity. +- + !python {model: stock.split.into}: | + move_obj=self.pool.get('stock.move') + product_obj=self.pool.get('product.product') + product_id=product_obj.search(cr,uid,[('name','=','HP CD writers')]) + move_ids=move_obj.search(cr,uid,[('product_id','in',product_id)]) + self.split(cr, uid, [ref("stock_split_into0")], {"lang": 'en_US', "active_model": + "stock.move", "active_ids": move_ids, "tz": False, "active_id":move_ids[0] + }) - I click on draft_force_assign on picking. - @@ -345,3 +448,4 @@ 'product_uom': move.product_uom.id, } self.do_partial(cr, uid, [ref('stock_picking_0')],partial_datas) + diff --git a/addons/stock/test/stock_test_wizard.yml b/addons/stock/test/stock_test_wizard.yml new file mode 100644 index 00000000000..c7e870a8d7d --- /dev/null +++ b/addons/stock/test/stock_test_wizard.yml @@ -0,0 +1,120 @@ + +- + In order to test picking i created picking record with move lines +- + !record {model: stock.picking, id: stock_picking_in0}: + address_id: base.main_address + company_id: base.main_company + invoice_state: 2binvoiced + move_lines: + - location_dest_id: stock.stock_location_shop0 + product_id: product.product_product_pc1 + product_qty: 30.0 + product_uom: product.product_uom_unit + date_expected : '2011-01-05 12:58:07' + location_id : stock.stock_location_suppliers + name : '[PC1] Basic PC' + product_uos_qty : 30.0 + name: IN/00010 + type: in + +- + I performed an osv_memory action draft_validate on module stock.picking +- + !python {model: stock.picking}: | + self.draft_validate(cr, uid, [ref("stock_picking_in0")], {"lang": "en_US", "search_default_available": + 1, "tz": False, "active_model": "ir.ui.menu", "section_id": False, "contact_display": + "partner_address", "active_ids": [ref("stock.menu_action_picking_tree4")], + "active_id": ref("stock.menu_action_picking_tree4"), }) + +- + I confirm the picking. +- + + !python {model: stock.picking }: | + import time + pick=self.browse(cr,uid,ref('stock_picking_in0')) + partial_datas={} + for move in pick.move_lines: + partial_datas['move%s'%(move.id)]= { + 'product_id': move.product_id, + 'product_qty': move.product_qty, + } + self.do_partial(cr, uid, [pick.id],partial_datas) +- + I Performing an osv_memory action create_invoice on module stock.invoice.onshipping +- + !python {model: stock.invoice.onshipping}: | + pick=self.browse(cr,uid,ref('stock_picking_in0')) + invoice_line_id = self.pool.get('stock.invoice.onshipping').create(cr, uid,{}, {"lang": 'en_US', "active_model": + "stock.picking", "active_ids": [pick.id], "tz": False, "active_id":pick.id}) + self.open_invoice(cr, uid, [invoice_line_id], {"lang": "en_US", + "search_default_available": 1, "inv_type": "in_invoice" , "tz": False, "active_model": "stock.picking", + "contact_display": "partner_address", "active_ids": [ref("stock_picking_in0")], + "active_id": ref("stock_picking_in0"), }) +- + I Performed an osv_memory action move_scrap and consume move on module stock.move.scrap +- + + !python {model: stock.picking }: | + import time + location_obj = self.pool.get('stock.location') + scrpaed_location_ids = location_obj.search(cr, uid, [('scrap_location','=',True)]) + pick=self.browse(cr,uid,ref('stock_picking_in0')) + scrap_obj=self.pool.get('stock.move.scrap') + consume_obj=self.pool.get('stock.move.consume') + partial_datas={} + move=pick.move_lines[0] + partial_datas= { + 'product_id': move.product_id.id, + 'location_id': scrpaed_location_ids[0], + 'product_qty': move.product_qty, + 'product_uom': move.product_uom.id, + } + scrap_id = self.pool.get('stock.move.scrap').create(cr, uid, partial_datas) + scrap_obj.move_scrap(cr, uid, [scrap_id], {"lang": "en_US", "tz": + False, "active_model": "stock.move", "scrap": True, "active_ids": [move.id], + "active_id": move.id, }) + consume_id = self.pool.get('stock.move.consume').create(cr, uid, partial_datas) + consume_obj.do_move_consume(cr, uid, [consume_id], {"lang": "en_US", "tz": + False, "active_model": "stock.move", "scrap": True, "active_ids": [move.id], + "active_id": move.id, }) +- + I return the picking. +- + + !python {model: stock.picking }: | + import time + pick=self.browse(cr,uid,ref('stock_picking_in0')) + partial_datas={} + partial_pick_id = self.pool.get('stock.return.picking').create(cr, uid,{}, {"lang": 'en_US', "active_model": + "stock.picking", "active_ids": [pick.id], "tz": False, "active_id":pick.id}) + for move in pick.move_lines: + partial_datas= { + 'product_id': move.product_id.id, + 'quantity': move.product_qty, + } + self.pool.get('stock.return.picking').create_returns(cr, uid, [partial_pick_id], {"lang": 'en_US', "active_model": + "stock.picking", "active_ids": [pick.id], "tz": False, "active_id":pick.id}) + +- + I create stock.move record. +- + + !python {model: stock.move }: | + import time + pick_obj = self.pool.get('stock.picking') + pick=pick_obj.browse(cr,uid,ref('stock_picking_in0')) + partial_move_id = self.pool.get('stock.partial.move').create(cr, uid,{}) + search_id = self.search(cr, uid, [('picking_id', '=', pick.id)]) + partial_datas={} + for move in pick.move_lines: + partial_datas['move%s'%(move.id)]= { + 'quantity': move.product_qty, + 'product_uom': move.product_uom.id, + 'prodlot_id': move.prodlot_id and move.prodlot_id.id or False, + 'wizard_id': partial_move_id, + } + self.do_partial(cr, uid, [partial_move_id],partial_datas,{"lang": 'en_US', "active_model": + "stock.move", 'search_default_receive': 1, 'product_receive': True, "active_ids": search_id, "tz": False, "active_id":search_id[0]}) + \ No newline at end of file diff --git a/addons/stock/wizard/__init__.py b/addons/stock/wizard/__init__.py index b903f020f82..b0b091be07a 100644 --- a/addons/stock/wizard/__init__.py +++ b/addons/stock/wizard/__init__.py @@ -25,7 +25,6 @@ import stock_splitinto import stock_partial_picking import stock_partial_move import stock_replacement -import stock_ups import stock_inventory_merge import stock_fill_inventory import stock_inventory_line_split diff --git a/addons/stock/wizard/stock_ups.py b/addons/stock/wizard/stock_ups.py deleted file mode 100644 index fb47587f254..00000000000 --- a/addons/stock/wizard/stock_ups.py +++ /dev/null @@ -1,95 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -import netsvc -from osv import fields, osv -from tools.translate import _ - -class stock_ups(osv.osv_memory): - _name = "stock.ups" - _description = "Stock ups" - - def ups_save(self, cr, uid, ids, context=None): - return { - 'name': False, - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'stock.ups.final', - 'type': 'ir.actions.act_window', - 'target':'new', - } - - def ups_upload(self, cr, uid, ids, context=None): - return { - 'name': False, - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'stock.ups.upload', - 'type': 'ir.actions.act_window', - 'target':'new', - } - - _columns = { - 'weight': fields.float('Lot weight', required=True), - } - - _defaults = { - 'weight': lambda *a: 3.0, - } -stock_ups() - -class stock_ups_final(osv.osv_memory): - _name = "stock.ups.final" - _description = "Stock ups final" - - def create_xmlfile(self, cr, uid, ids, context=None): - """ Creates xml report file. - @return: xml file - """ - data={} - report = netsvc._group['report']['report.stock.move.lot.ups_xml'] - data['report_type'] = 'raw' - return {'xmlfile' : report.create(uid, context['active_id'], ids, {})} - - _columns = { - 'xmlfile': fields.binary('XML File'), - } - -stock_ups_final() - -class stock_ups_upload(osv.osv_memory): - _name = "stock.ups.upload" - _description = "Stock ups upload" - - def upload_xmlfile(self, cr, uid, ids, context=None): - """ Uploads xml report file. - @return: - """ - data={} - report = netsvc._group['report']['report.stock.move.lot.ups_xml'] - data['report_type'] = 'raw' - fp = file('/tmp/test.xml', 'w').write(report.create(uid, context['active_id'], ids, {})) - return {'type': 'ir.actions.act_window_close'} - -stock_ups_upload() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/stock/wizard/stock_ups_view.xml b/addons/stock/wizard/stock_ups_view.xml deleted file mode 100644 index cbce721e1b9..00000000000 --- a/addons/stock/wizard/stock_ups_view.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - Stock ups - stock.ups - form - -
- - - -