diff --git a/addons/board_manufacturing/board_manufacturing_view.xml b/addons/board_manufacturing/board_manufacturing_view.xml index 191f1818612..37624d6e025 100644 --- a/addons/board_manufacturing/board_manufacturing_view.xml +++ b/addons/board_manufacturing/board_manufacturing_view.xml @@ -14,8 +14,8 @@ - - + + diff --git a/addons/board_warehouse/board_warehouse_view.xml b/addons/board_warehouse/board_warehouse_view.xml index af797401935..08ece3f821d 100644 --- a/addons/board_warehouse/board_warehouse_view.xml +++ b/addons/board_warehouse/board_warehouse_view.xml @@ -23,7 +23,7 @@
- + diff --git a/addons/mrp/__init__.py b/addons/mrp/__init__.py index d23cee8d565..30367ec35f8 100644 --- a/addons/mrp/__init__.py +++ b/addons/mrp/__init__.py @@ -26,6 +26,6 @@ import installer import wizard import report import company -import mrp_procurement +import procurement # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp/__openerp__.py b/addons/mrp/__openerp__.py index 97e23f3488d..58320ebfdf7 100644 --- a/addons/mrp/__openerp__.py +++ b/addons/mrp/__openerp__.py @@ -26,7 +26,7 @@ "author" : "Tiny", "website" : "http://www.openerp.com", "category" : "Generic Modules/Production", - "depends" : ["mrp_procurement", "stock", "resource", "purchase", "product","process"], + "depends" : ["procurement", "stock", "resource", "purchase", "product","process"], "description": """ This is the base module to manage the manufacturing process in Open ERP. @@ -76,7 +76,7 @@ 'report/mrp_report_view.xml', 'report/mrp_production_order_view.xml', ], - 'demo_xml': ['mrp_demo.xml', 'mrp_order_point.xml'], + 'demo_xml': ['mrp_demo.xml'], 'test': [ 'test/mrp_phantom_bom.yml', 'test/mrp_production_order.yml', diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index e720de2bee7..690aec2f3ec 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -474,18 +474,6 @@ class mrp_production(osv.osv): result[prod.id] = prod.date_planned[:10] return result - def _ref_calc(self, cr, uid, ids, field_names=None, arg=False, context={}): - """ Finds reference sale order for production order. - @param field_names: Names of fields. - @param arg: User defined arguments - @return: Dictionary of values. - """ - res = {} - for f in field_names: - for order_id in ids: - res[order_id] = {f:False} - return res - _columns = { 'name': fields.char('Reference', size=64, required=True), 'origin': fields.char('Source Document', size=64, help="Reference of the document that generated this production order request."), @@ -526,8 +514,6 @@ class mrp_production(osv.osv): 'hour_total': fields.function(_production_calc, method=True, type='float', string='Total Hours', multi='workorder'), 'cycle_total': fields.function(_production_calc, method=True, type='float', string='Total Cycles', multi='workorder'), - 'sale_name': fields.function(_ref_calc, method=True, multi='sale_name', type='char', string='Sale Name', help='Indicate the name of sale order.'), - 'sale_ref': fields.function(_ref_calc, method=True, multi='sale_ref', type='char', string='Sale Reference', help='Indicate the Customer Reference from sale order.'), 'company_id': fields.many2one('res.company','Company',required=True), } _defaults = { @@ -837,7 +823,7 @@ class mrp_production(osv.osv): seq_obj = self.pool.get('ir.sequence') pick_obj = self.pool.get('stock.picking') move_obj = self.pool.get('stock.move') - proc_obj = self.pool.get('mrp.procurement') + proc_obj = self.pool.get('procurement.order') wf_service = netsvc.LocalService("workflow") for production in self.browse(cr, uid, ids): if not production.product_lines: @@ -931,7 +917,7 @@ class mrp_production(osv.osv): 'move_id': move_id, 'company_id': production.company_id.id, }) - wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr) + wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) proc_ids.append(proc_id) wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) self.write(cr, uid, [production.id], {'picking_id': picking_id, 'move_lines': [(6,0,moves)], 'state':'confirmed'}) diff --git a/addons/mrp/mrp_data.xml b/addons/mrp/mrp_data.xml index a7db7109e55..64dd9f2c9e5 100644 --- a/addons/mrp/mrp_data.xml +++ b/addons/mrp/mrp_data.xml @@ -16,20 +16,5 @@ 1 - - - Stock orderpoint - mrp.warehouse.orderpoint - - - - Stock orderpoint - mrp.warehouse.orderpoint - OP/ - 5 - 1 - 1 - - diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 80587c6956c..8b6b43acd1d 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -406,18 +406,18 @@ Procurement --> - - + - + - + - mrp.procurement.form.inherit - mrp.procurement - + procurement.order.form.inherit + procurement.order + form diff --git a/addons/mrp/mrp_workflow.xml b/addons/mrp/mrp_workflow.xml index a9c83b23b7e..0a55ccdd610 100644 --- a/addons/mrp/mrp_workflow.xml +++ b/addons/mrp/mrp_workflow.xml @@ -117,7 +117,7 @@ - + produce subflow @@ -125,20 +125,20 @@ - + check_product() - + subflow.cancel - + subflow.done diff --git a/addons/mrp/process/procurement_process.xml b/addons/mrp/process/procurement_process.xml index 08d66570b1f..16369eef298 100644 --- a/addons/mrp/process/procurement_process.xml +++ b/addons/mrp/process/procurement_process.xml @@ -4,11 +4,11 @@ - + - + @@ -19,94 +19,94 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/addons/mrp/process/service_product_process.xml b/addons/mrp/process/service_product_process.xml index 60bf3b562b9..a96a7a7bd4d 100644 --- a/addons/mrp/process/service_product_process.xml +++ b/addons/mrp/process/service_product_process.xml @@ -8,7 +8,7 @@ - + @@ -18,7 +18,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/addons/mrp/process/stockable_product_process.xml b/addons/mrp/process/stockable_product_process.xml index c053103f476..bb5c36a015a 100644 --- a/addons/mrp/process/stockable_product_process.xml +++ b/addons/mrp/process/stockable_product_process.xml @@ -8,7 +8,7 @@ - + @@ -18,7 +18,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/addons/mrp/mrp_procurement.py b/addons/mrp/procurement.py similarity index 90% rename from addons/mrp/mrp_procurement.py rename to addons/mrp/procurement.py index 84392b329ea..d704afa46d6 100644 --- a/addons/mrp/mrp_procurement.py +++ b/addons/mrp/procurement.py @@ -27,17 +27,20 @@ import ir import netsvc import time -class mrp_procurement(osv.osv): - _inherit = 'mrp.procurement' +class procurement_order(osv.osv): + _inherit = 'procurement.order' _columns = { 'bom_id': fields.many2one('mrp.bom', 'BoM', ondelete='cascade', select=True), } def check_produce_product(self, cr, uid, procurement, context=[]): + """ Finds the bill of material for the product from procurement order. + @return: True or False + """ properties = [x.id for x in procurement.property_ids] bom_id = self.pool.get('mrp.bom')._bom_find(cr, uid, procurement.product_id.id, procurement.product_uom.id, properties) if not bom_id: - cr.execute('update mrp_procurement set message=%s where id=%s', (_('No BoM defined for this product !'), procurement.id)) + cr.execute('update procurement_order set message=%s where id=%s', (_('No BoM defined for this product !'), procurement.id)) return False return True @@ -45,7 +48,7 @@ class mrp_procurement(osv.osv): """ This is action which call from workflow to assign production order to procurements @return: True """ - procurement_obj = self.pool.get('mrp.procurement') + procurement_obj = self.pool.get('procurement.order') res = procurement_obj.make_mo(cr, uid, ids, context=context) res = res.values() return len(res) and res[0] or 0 #TO CHECK: why workflow is generated error if return not integer value @@ -59,7 +62,7 @@ class mrp_procurement(osv.osv): production_obj = self.pool.get('mrp.production') move_obj = self.pool.get('stock.move') wf_service = netsvc.LocalService("workflow") - procurement_obj = self.pool.get('mrp.procurement') + procurement_obj = self.pool.get('procurement.order') for procurement in procurement_obj.browse(cr, uid, ids): res_id = procurement.move_id.id loc_id = procurement.location_id.id @@ -88,6 +91,6 @@ class mrp_procurement(osv.osv): {'location_id': procurement.location_id.id}) return res -mrp_procurement() +procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp/security/ir.model.access.csv b/addons/mrp/security/ir.model.access.csv index d5e00b9cbda..8f58f7179ad 100644 --- a/addons/mrp/security/ir.model.access.csv +++ b/addons/mrp/security/ir.model.access.csv @@ -7,7 +7,7 @@ "access_mrp_production","mrp.production","model_mrp_production","mrp.group_mrp_user",1,1,1,1 "access_mrp_production_workcenter_line","mrp.production.workcenter.line","model_mrp_production_workcenter_line","mrp.group_mrp_user",1,1,1,1 "access_mrp_production_product_line","mrp.production.product.line","model_mrp_production_product_line","mrp.group_mrp_user",1,1,1,1 -"access_mrp_procurement","mrp.procurement","model_mrp_procurement","mrp.group_mrp_user",1,1,1,1 +"access_procurement","procurement.order","model_procurement_order","mrp.group_mrp_user",1,1,1,1 "access_mrp_workcenter_manager","mrp.workcenter.manager","model_mrp_workcenter","mrp.group_mrp_user",1,1,1,1 "access_mrp_routing_manager","mrp.routing.manager","model_mrp_routing","mrp.group_mrp_manager",1,1,1,1 "access_mrp_routing_workcenter_manager","mrp.routing.workcenter.manager","model_mrp_routing_workcenter","mrp.group_mrp_manager",1,1,1,1 @@ -22,7 +22,7 @@ "access_purchase_order_mrp_worker","purchase.order mrp_worker","purchase.model_purchase_order","mrp.group_mrp_user",1,0,0,0 "access_purchase_order_line_mrp_worker","purchase.order.line mrp_worker","purchase.model_purchase_order_line","mrp.group_mrp_user",1,0,0,0 "access_hr_timesheet_group_mrp_worker","resource.calendar mrp_worker","resource.model_resource_calendar","mrp.group_mrp_user",1,0,0,0 -"access_mrp_procurement_stock_worker","mrp.procurement stock_worker","model_mrp_procurement","stock.group_stock_user",1,1,1,1 +"access_procurement_stock_worker","procurement.order stock_worker","model_procurement_order","stock.group_stock_user",1,1,1,1 "access_mrp_production_stock_worker","mrp.production stock_worker","model_mrp_production","stock.group_stock_user",1,0,0,0 "access_mrp_installer","mrp.installer","model_mrp_installer","mrp.group_mrp_user",1,0,0,0 "access_mrp_product_produce","mrp.product.produce","model_mrp_product_produce","mrp.group_mrp_user",1,0,0,0 diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py index 9bcc92e5c81..67efd0d2753 100644 --- a/addons/mrp/stock.py +++ b/addons/mrp/stock.py @@ -28,82 +28,12 @@ import netsvc import time -class stock_warehouse_orderpoint(osv.osv): - """ - Defines Minimum stock rules. - """ - _name = "stock.warehouse.orderpoint" - _description = "Minimum Inventory Rule" - - _columns = { - 'name': fields.char('Name', size=32, required=True), - 'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the orderpoint without removing it."), - 'logic': fields.selection([('max','Order to Max'),('price','Best price (not yet active!)')], 'Reordering Mode', required=True), - 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True, ondelete="cascade"), - 'location_id': fields.many2one('stock.location', 'Location', required=True, ondelete="cascade"), - 'product_id': fields.many2one('product.product', 'Product', required=True, ondelete='cascade', domain=[('type','=','product')]), - 'product_uom': fields.many2one('product.uom', 'Product UOM', required=True), - 'product_min_qty': fields.float('Min Quantity', required=True, - help="When the virtual stock goes belong the Min Quantity, Open ERP generates "\ - "a procurement to bring the virtual stock to the Max Quantity."), - 'product_max_qty': fields.float('Max Quantity', required=True, - help="When the virtual stock goes belong the Min Quantity, Open ERP generates "\ - "a procurement to bring the virtual stock to the Max Quantity."), - 'qty_multiple': fields.integer('Qty Multiple', required=True, - help="The procurement quantity will by rounded up to this multiple."), - 'procurement_id': fields.many2one('mrp.procurement', 'Latest procurement', ondelete="set null"), - 'company_id': fields.many2one('res.company','Company',required=True), - } - _defaults = { - 'active': lambda *a: 1, - 'logic': lambda *a: 'max', - 'qty_multiple': lambda *a: 1, - 'name': lambda x,y,z,c: x.pool.get('ir.sequence').get(y,z,'mrp.warehouse.orderpoint') or '', - 'product_uom': lambda sel, cr, uid, context: context.get('product_uom', False), - 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.warehouse.orderpoint', context=c) - } - _sql_constraints = [ - ('qty_multiple_check', 'CHECK( qty_multiple > 0 )', _('Qty Multiple must be greater than zero.')), - ] - - def onchange_warehouse_id(self, cr, uid, ids, warehouse_id, context={}): - """ Finds location id for changed warehouse. - @param warehouse_id: Changed id of warehouse. - @return: Dictionary of values. - """ - if warehouse_id: - w = self.pool.get('stock.warehouse').browse(cr, uid, warehouse_id, context) - v = {'location_id': w.lot_stock_id.id} - return {'value': v} - return {} - - def onchange_product_id(self, cr, uid, ids, product_id, context={}): - """ Finds UoM for changed product. - @param product_id: Changed id of product. - @return: Dictionary of values. - """ - if product_id: - prod = self.pool.get('product.product').browse(cr,uid,product_id) - v = {'product_uom': prod.uom_id.id} - return {'value': v} - return {} - - def copy(self, cr, uid, id, default=None,context={}): - if not default: - default = {} - default.update({ - 'name': self.pool.get('ir.sequence').get(cr, uid, 'mrp.warehouse.orderpoint') or '', - }) - return super(stock_warehouse_orderpoint, self).copy(cr, uid, id, default, context) - -stock_warehouse_orderpoint() - class StockMove(osv.osv): _inherit = 'stock.move' _columns = { 'production_id': fields.many2one('mrp.production', 'Production', select=True), - 'procurements': fields.one2many('mrp.procurement', 'move_id', 'Procurements'), + 'procurements': fields.one2many('procurement.order', 'move_id', 'Procurements'), } def copy(self, cr, uid, id, default=None, context=None): @@ -118,7 +48,7 @@ class StockMove(osv.osv): """ bom_obj = self.pool.get('mrp.bom') move_obj = self.pool.get('stock.move') - procurement_obj = self.pool.get('mrp.procurement') + procurement_obj = self.pool.get('procurement.order') product_obj = self.pool.get('product.product') wf_service = netsvc.LocalService("workflow") if move.product_id.supply_method == 'produce' and move.product_id.procure_method == 'make_to_order': @@ -166,7 +96,7 @@ class StockMove(osv.osv): 'move_id': mid, 'company_id': line['company_id'], }) - wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr) + wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) move_obj.write(cr, uid, [move.id], { 'location_id': move.location_dest_id.id, 'auto_validate': True, @@ -175,7 +105,7 @@ class StockMove(osv.osv): 'state': 'waiting' }) for m in procurement_obj.search(cr, uid, [('move_id','=',move.id)], context): - wf_service.trg_validate(uid, 'mrp.procurement', m, 'button_wait_done', cr) + wf_service.trg_validate(uid, 'procurement.order', m, 'button_wait_done', cr) return True def action_consume(self, cr, uid, ids, product_qty, location_id=False, context=None): @@ -231,7 +161,7 @@ class StockPicking(osv.osv): for move in picking.move_lines: if move.state == 'done' and move.procurements: for procurement in move.procurements: - wf_service.trg_validate(user, 'mrp.procurement', + wf_service.trg_validate(user, 'procurement.order', procurement.id, 'button_check', cursor) return res diff --git a/addons/mrp/test/mrp_phantom_bom.yml b/addons/mrp/test/mrp_phantom_bom.yml index c95ab26dd93..4a3e2e3e1da 100644 --- a/addons/mrp/test/mrp_phantom_bom.yml +++ b/addons/mrp/test/mrp_phantom_bom.yml @@ -180,15 +180,15 @@ - I am checking Procurement orders. There are 3 orders generated for Oranges, Sugar and Water. - - !python {model: mrp.procurement}: | + !python {model: procurement.order}: | from tools.translate import _ proc_ids = self.search(cr, uid, [('state','!=','cofirmed')]) assert proc_ids, _('No Procurements!') - The scheduler runs. - - !function {model: mrp.procurement, name: run_scheduler}: - - model: mrp.procurement + !function {model: procurement.order, name: run_scheduler}: + - model: procurement.order search: "[('state','!=','cofirmed')]" - I am checking Internal picking. I see one picking for Orange juice and its diff --git a/addons/mrp/test/mrp_procurement.yml b/addons/mrp/test/mrp_procurement.yml index c52fa4a339b..1fe0f74fa6a 100644 --- a/addons/mrp/test/mrp_procurement.yml +++ b/addons/mrp/test/mrp_procurement.yml @@ -129,7 +129,7 @@ - I create a procurement order for product Shirt. - - !record {model: mrp.procurement, id: mrp_procurement_shirt0}: + !record {model: procurement.order, id: procurement_order_shirt0}: name: 'PROC: Shirt' product_id: product_product_shirt0 product_qty: 5.00 @@ -138,11 +138,11 @@ - I confirm the procurement order. - - !workflow {model: mrp.procurement, action: button_confirm, ref: mrp_procurement_shirt0} + !workflow {model: procurement.order, action: button_confirm, ref: procurement_order_shirt0} - I run the procurement. - - !workflow {model: mrp.procurement, action: button_check, ref: mrp_procurement_shirt0} + !workflow {model: procurement.order, action: button_check, ref: procurement_order_shirt0} - I see that there is a manufacturing order for Shirt. - @@ -153,15 +153,15 @@ - I also check that there are two more procurement orders for sub products Cloth and Buttons. - - !python {model: mrp.procurement}: | + !python {model: procurement.order}: | from tools.translate import _ proc_ids = self.search(cr, uid, [('product_id','in',[ref('product_product_cloth0'),ref('product_product_buttons0')])]) assert proc_ids, 'No Procurements.' - The scheduler runs. - - !function {model: mrp.procurement, name: run_scheduler}: - - model: mrp.procurement + !function {model: procurement.order, name: run_scheduler}: + - model: procurement.order search: "[]" - I check that there is one purchase order for Cloth. @@ -290,8 +290,8 @@ - Run scheduler again. - - !function {model: mrp.procurement, name: run_scheduler}: - - model: mrp.procurement + !function {model: procurement.order, name: run_scheduler}: + - model: procurement.order search: "[]" - Check state of manufacturing order for Shirt. diff --git a/addons/mrp/test/mrp_production_order.yml b/addons/mrp/test/mrp_production_order.yml index 861f52e9c61..0ceebfab107 100644 --- a/addons/mrp/test/mrp_production_order.yml +++ b/addons/mrp/test/mrp_production_order.yml @@ -84,15 +84,15 @@ - I am checking Procurement orders. - - !python {model: mrp.procurement}: | + !python {model: procurement.order}: | from tools.translate import _ proc_ids = self.search(cr, uid, [('state','!=','confirmed')]) assert proc_ids, _('No Procurements!') - The scheduler runs. - - !function {model: mrp.procurement, name: run_scheduler}: - - model: mrp.procurement + !function {model: procurement.order, name: run_scheduler}: + - model: procurement.order search: "[('state','=','confirmed')]" - I am checking Internal picking. diff --git a/addons/mrp_jit/__openerp__.py b/addons/mrp_jit/__openerp__.py index d9a862f5ddd..497a81352f3 100644 --- a/addons/mrp_jit/__openerp__.py +++ b/addons/mrp_jit/__openerp__.py @@ -40,7 +40,7 @@ """, 'author': 'Tiny', - 'depends': ['mrp_procurement'], + 'depends': ['procurement'], 'update_xml': ['mrp_jit.xml'], 'demo_xml': [], 'installable': True, diff --git a/addons/mrp_jit/mrp_jit.xml b/addons/mrp_jit/mrp_jit.xml index bab0d62b495..99f74a19517 100644 --- a/addons/mrp_jit/mrp_jit.xml +++ b/addons/mrp_jit/mrp_jit.xml @@ -2,7 +2,7 @@ - + diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index e8a97a47d9d..d1e66c92889 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -47,6 +47,9 @@ stock_move() class mrp_production_workcenter_line(osv.osv): def _get_date_date(self, cr, uid, ids, field_name, arg, context): + """ Finds starting date. + @return: Dictionary of values. + """ res={} for op in self.browse(cr, uid, ids, context=context): if op.date_start: @@ -54,7 +57,11 @@ class mrp_production_workcenter_line(osv.osv): else: res[op.id]=False return res + def _get_date_end(self, cr, uid, ids, field_name, arg, context): + """ Finds ending date. + @return: Dictionary of values. + """ res = {} for op in self.browse(cr, uid, ids, context=context): res[op.id]= False @@ -66,8 +73,10 @@ class mrp_production_workcenter_line(osv.osv): else: res[op.id] = op.date_planned return res + _inherit = 'mrp.production.workcenter.line' _order = "sequence, date_planned" + _columns = { 'state': fields.selection([('draft','Draft'),('startworking', 'In Progress'),('pause','Pause'),('cancel','Canceled'),('done','Finished')],'State', readonly=True, help="* When a work order is created it is set in 'Draft' state.\n" \ @@ -90,16 +99,21 @@ class mrp_production_workcenter_line(osv.osv): 'qty':fields.related('production_id','product_qty',type='float',string='Qty',readonly=True), 'uom':fields.related('production_id','product_uom',type='many2one',relation='product.uom',string='UOM',readonly=True), } + _defaults = { 'state': lambda *a: 'draft', 'delay': lambda *a: 0.0 } - def modify_production_order_state(self,cr,uid,ids,action): + def modify_production_order_state(self, cr, uid, ids, action): + """ Modifies production order state if work order state is changed. + @param action: Action to perform. + @return: Nothing + """ wf_service = netsvc.LocalService("workflow") - oper_obj=self.browse(cr,uid,ids)[0] - prod_obj=oper_obj.production_id - if action=='start': + oper_obj = self.browse(cr, uid, ids)[0] + prod_obj = oper_obj.production_id + if action == 'start': if prod_obj.state =='confirmed': self.pool.get('mrp.production').force_production(cr, uid, [prod_obj.id]) wf_service.trg_validate(uid, 'mrp.production', prod_obj.id, 'button_produce', cr) @@ -110,12 +124,12 @@ class mrp_production_workcenter_line(osv.osv): else: raise osv.except_osv(_('Error!'),_('Production Order Cannot start in [%s] state') % (prod_obj.state,)) else: - oper_ids=self.search(cr,uid,[('production_id','=',prod_obj.id)]) - obj=self.browse(cr,uid,oper_ids) - flag=True + oper_ids = self.search(cr,uid,[('production_id','=',prod_obj.id)]) + obj = self.browse(cr,uid,oper_ids) + flag = True for line in obj: - if line.state!='done': - flag=False + if line.state != 'done': + flag = False if flag: wf_service.trg_validate(uid, 'mrp.production', oper_obj.production_id.id, 'button_produce_done', cr) return @@ -132,15 +146,24 @@ class mrp_production_workcenter_line(osv.osv): return result def action_draft(self, cr, uid, ids): + """ Sets state to draft. + @return: True + """ self.write(cr, uid, ids, {'state':'draft'}) return True def action_start_working(self, cr, uid, ids): - self.modify_production_order_state(cr,uid,ids,'start') + """ Sets state to start working and writes starting date. + @return: True + """ + self.modify_production_order_state(cr, uid, ids, 'start') self.write(cr, uid, ids, {'state':'startworking', 'date_start': time.strftime('%Y-%m-%d %H:%M:%S')}) return True def action_done(self, cr, uid, ids): + """ Sets state to done, writes finish date and calculates delay. + @return: True + """ delay = 0.0 date_now = time.strftime('%Y-%m-%d %H:%M:%S') obj_line = self.browse(cr, uid, ids[0]) @@ -155,14 +178,23 @@ class mrp_production_workcenter_line(osv.osv): return True def action_cancel(self, cr, uid, ids): + """ Sets state to cancel. + @return: True + """ self.write(cr, uid, ids, {'state':'cancel'}) return True def action_pause(self, cr, uid, ids): + """ Sets state to pause. + @return: True + """ self.write(cr, uid, ids, {'state':'pause'}) return True def action_resume(self, cr, uid, ids): + """ Sets state to startworking. + @return: True + """ self.write(cr, uid, ids, {'state':'startworking'}) return True @@ -175,6 +207,9 @@ class mrp_production(osv.osv): } def _production_date_end(self, cr, uid, ids, prop, unknow_none, context={}): + """ Calculates planned end date of production order. + @return: Dictionary of values + """ result = {} for prod in self.browse(cr, uid, ids, context=context): result[prod.id] = prod.date_planned @@ -183,10 +218,13 @@ class mrp_production(osv.osv): return result def action_production_end(self, cr, uid, ids): - obj=self.browse(cr,uid,ids)[0] + """ Finishes work order if production order is done. + @return: Super method + """ + obj = self.browse(cr, uid, ids)[0] for workcenter_line in obj.workcenter_lines: - tmp = self.pool.get('mrp.production.workcenter.line').action_done(cr,uid,[workcenter_line.id]) - return super(mrp_production,self).action_production_end(cr,uid,ids) + tmp = self.pool.get('mrp.production.workcenter.line').action_done(cr, uid, [workcenter_line.id]) + return super(mrp_production,self).action_production_end(cr, uid, ids) def action_in_production(self, cr, uid, ids): """ Changes state to In Production and writes starting date. @@ -199,12 +237,18 @@ class mrp_production(osv.osv): return super(mrp_production,self).action_in_production(cr, uid, ids) def action_cancel(self, cr, uid, ids): - obj=self.browse(cr,uid,ids)[0] + """ Cancels work order if production order is canceled. + @return: Super method + """ + obj = self.browse(cr, uid, ids)[0] for workcenter_line in obj.workcenter_lines: - tmp=self.pool.get('mrp.production.workcenter.line').action_cancel(cr,uid,[workcenter_line.id]) + tmp = self.pool.get('mrp.production.workcenter.line').action_cancel(cr, uid, [workcenter_line.id]) return super(mrp_production,self).action_cancel(cr,uid,ids) def _compute_planned_workcenter(self, cr, uid, ids, context={}, mini=False): + """ Computes planned and finished dates for work order. + @return: Calculated date + """ dt_end = DateTime.now() for po in self.browse(cr, uid, ids, context=context): dt_end = DateTime.strptime(po.date_start or po.date_planned, '%Y-%m-%d %H:%M:%S') @@ -241,6 +285,9 @@ class mrp_production(osv.osv): return dt_end def _move_pass(self, cr, uid, ids, context={}): + """ Calculates start date for stock moves finding interval from resource calendar. + @return: True + """ for po in self.browse(cr, uid, ids, context): if po.allow_reorder: continue @@ -251,7 +298,7 @@ class mrp_production(osv.osv): if l.state in ('done','cancel','draft'): continue todo += l.move_dest_id_lines - if l.production_id and (l.production_id.date_finnished>dt): + if l.production_id and (l.production_id.date_finnished > dt): if l.production_id.state not in ('done','cancel'): for wc in l.production_id.workcenter_lines: i = self.pool.get('resource.calendar').interval_min_get( @@ -261,11 +308,14 @@ class mrp_production(osv.osv): dt, wc.hour or 0.0 ) dt = i[0][0] - if l.production_id.date_start>dt.strftime('%Y-%m-%d %H:%M:%S'): + if l.production_id.date_start > dt.strftime('%Y-%m-%d %H:%M:%S'): self.write(cr, uid, [l.production_id.id], {'date_start':dt.strftime('%Y-%m-%d %H:%M:%S')}, mini=True) return True def _move_futur(self, cr, uid, ids, context={}): + """ Calculates start date for stock moves. + @return: True + """ for po in self.browse(cr, uid, ids, context): if po.allow_reorder: continue @@ -277,8 +327,8 @@ class mrp_production(osv.osv): break if l.production_id.state in ('done','cancel'): break - if l.production_id and (l.production_id.date_start @@ -132,7 +132,7 @@ - + @@ -206,7 +206,7 @@ - + @@ -474,12 +474,12 @@ - + - + @@ -497,7 +497,7 @@ name="Reporting" parent="stock.menu_stock_root" groups="base.group_user"/> - + diff --git a/addons/point_of_sale/posrule_data2.xml b/addons/point_of_sale/posrule_data2.xml index 927584e92ce..7ac787db54c 100644 --- a/addons/point_of_sale/posrule_data2.xml +++ b/addons/point_of_sale/posrule_data2.xml @@ -177,7 +177,7 @@ ref('stock.menu_action_picking_tree7'), ref('stock.menu_action_picking_tree8'), ref('stock.menu_action_picking_tree9'), - ref('mrp_procurement.menu_mrp_procurement_action3'), + ref('procurement.menu_mrp_procurement_action3'), ref('point_of_sale.menu_point_root')])]" name="menu_access"/> @@ -214,7 +214,7 @@ - + @@ -557,12 +557,12 @@ - + - + diff --git a/addons/point_of_sale/statement_data.xml b/addons/point_of_sale/statement_data.xml index 67c94170666..5172e0e70d4 100644 --- a/addons/point_of_sale/statement_data.xml +++ b/addons/point_of_sale/statement_data.xml @@ -33,7 +33,7 @@ - + diff --git a/addons/mrp_procurement/__init__.py b/addons/procurement/__init__.py similarity index 96% rename from addons/mrp_procurement/__init__.py rename to addons/procurement/__init__.py index 6cb8ad4027b..3420ef1f75e 100644 --- a/addons/mrp_procurement/__init__.py +++ b/addons/procurement/__init__.py @@ -19,7 +19,7 @@ # ############################################################################## -import mrp_procurement +import procurement import wizard import schedulers import company \ No newline at end of file diff --git a/addons/mrp_procurement/__openerp__.py b/addons/procurement/__openerp__.py similarity index 90% rename from addons/mrp_procurement/__openerp__.py rename to addons/procurement/__openerp__.py index 82c611c6c78..8bd8d05c685 100644 --- a/addons/mrp_procurement/__openerp__.py +++ b/addons/procurement/__openerp__.py @@ -33,18 +33,18 @@ 'init_xml': [], 'update_xml': [ 'security/ir.model.access.csv', - 'security/mrp_procurement_security.xml', - 'mrp_procurement_data.xml', + 'security/procurement_security.xml', + 'procurement_data.xml', 'wizard/make_procurement_view.xml', 'wizard/mrp_procurement_view.xml', 'wizard/orderpoint_procurement_view.xml', - 'mrp_procurement_view.xml', + 'procurement_view.xml', 'wizard/schedulers_all_view.xml', - 'mrp_procurement_workflow.xml', + 'procurement_workflow.xml', 'process/procurement_process.xml', "company_view.xml", ], -# 'demo_xml': [], + 'demo_xml': ['stock_orderpoint.xml'], 'installable': True, 'active': False, 'certificate': '', diff --git a/addons/mrp_procurement/company.py b/addons/procurement/company.py similarity index 100% rename from addons/mrp_procurement/company.py rename to addons/procurement/company.py diff --git a/addons/mrp_procurement/company_view.xml b/addons/procurement/company_view.xml similarity index 100% rename from addons/mrp_procurement/company_view.xml rename to addons/procurement/company_view.xml diff --git a/addons/mrp_procurement/process/procurement_process.xml b/addons/procurement/process/procurement_process.xml similarity index 83% rename from addons/mrp_procurement/process/procurement_process.xml rename to addons/procurement/process/procurement_process.xml index 21f953c6a6f..e5b94bb225d 100644 --- a/addons/mrp_procurement/process/procurement_process.xml +++ b/addons/procurement/process/procurement_process.xml @@ -8,7 +8,7 @@ - + diff --git a/addons/mrp_procurement/mrp_procurement.py b/addons/procurement/procurement.py similarity index 93% rename from addons/mrp_procurement/mrp_procurement.py rename to addons/procurement/procurement.py index ceaefb4c4db..a65ea449046 100644 --- a/addons/mrp_procurement/mrp_procurement.py +++ b/addons/procurement/procurement.py @@ -62,11 +62,11 @@ mrp_property() # Produce, Buy or Find products and place a move # then wizard for picking lists & move # -class mrp_procurement(osv.osv): +class procurement_order(osv.osv): """ Procurement Orders """ - _name = "mrp.procurement" + _name = "procurement.order" _description = "Procurement" _order = 'priority,date_planned desc' _log_create = False @@ -92,7 +92,7 @@ class mrp_procurement(osv.osv): 'note': fields.text('Note'), - 'property_ids': fields.many2many('mrp.property', 'mrp_procurement_property_rel', 'procurement_id','property_id', 'Properties'), + 'property_ids': fields.many2many('mrp.property', 'procurement_property_rel', 'procurement_id','property_id', 'Properties'), 'message': fields.char('Latest error', size=64, help="Exception occurred while computing procurement orders."), 'state': fields.selection([ @@ -115,7 +115,7 @@ class mrp_procurement(osv.osv): 'date_planned': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), 'close_move': lambda *a: 0, 'procure_method': lambda *a: 'make_to_order', - 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.procurement', context=c) + 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'procurement.order', context=c) } def unlink(self, cr, uid, ids, context=None): @@ -176,7 +176,7 @@ class mrp_procurement(osv.osv): return res # - # This method may be overrided by objects that override mrp.procurment + # This method may be overrided by objects that override procurement.order # for computing their own purpose # def _quantity_compute_get(self, cr, uid, proc, context={}): @@ -286,7 +286,7 @@ class mrp_procurement(osv.osv): if procurement.product_id.product_tmpl_id.supply_method <> 'buy': return False if not procurement.product_id.seller_ids: - cr.execute('update mrp_procurement set message=%s where id=%s', (_('No supplier defined for this product !'), procurement.id)) + cr.execute('update procurement_order set message=%s where id=%s', (_('No supplier defined for this product !'), procurement.id)) return False partner = procurement.product_id.seller_ids[0].name if user.company_id and user.company_id.partner_id: @@ -294,7 +294,7 @@ class mrp_procurement(osv.osv): return False address_id = partner_obj.address_get(cr, uid, [partner.id], ['delivery'])['delivery'] if not address_id: - cr.execute('update mrp_procurement set message=%s where id=%s', (_('No address defined for the supplier'), procurement.id)) + cr.execute('update procurement_order set message=%s where id=%s', (_('No address defined for the supplier'), procurement.id)) return False return True @@ -358,7 +358,7 @@ class mrp_procurement(osv.osv): ok = ok and self.pool.get('stock.move').action_assign(cr, uid, [id]) cr.execute('select count(id) from stock_warehouse_orderpoint where product_id=%s', (procurement.product_id.id,)) if not cr.fetchone()[0]: - cr.execute('update mrp_procurement set message=%s where id=%s', (_('Stock is not enough and No minimum orderpoint rule defined'), procurement.id)) + cr.execute('update procurement_order set message=%s where id=%s', (_('Stock is not enough and No minimum orderpoint rule defined'), procurement.id)) return ok def action_produce_assign_service(self, cr, uid, ids, context={}): @@ -403,7 +403,7 @@ class mrp_procurement(osv.osv): self.write(cr, uid, ids, {'state': 'cancel'}) wf_service = netsvc.LocalService("workflow") for id in ids: - wf_service.trg_trigger(uid, 'mrp.procurement', id, cr) + wf_service.trg_trigger(uid, 'procurement.order', id, cr) return True def action_check_finnished(self, cr, uid, ids): @@ -439,7 +439,7 @@ class mrp_procurement(osv.osv): res = self.write(cr, uid, ids, {'state': 'done', 'date_close': time.strftime('%Y-%m-%d')}) wf_service = netsvc.LocalService("workflow") for id in ids: - wf_service.trg_trigger(uid, 'mrp.procurement', id, cr) + wf_service.trg_trigger(uid, 'procurement.order', id, cr) return res def run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, context=None): @@ -452,7 +452,7 @@ class mrp_procurement(osv.osv): self._procure_orderpoint_confirm(cr, uid, automatic=automatic,\ use_new_cursor=use_new_cursor, context=context) -mrp_procurement() +procurement_order() class stock_warehouse_orderpoint(osv.osv): @@ -460,16 +460,16 @@ class stock_warehouse_orderpoint(osv.osv): Defines Minimum stock rules. """ _name = "stock.warehouse.orderpoint" - _description = "Orderpoint minimum rule" - + _description = "Minimum Inventory Rule" + _columns = { 'name': fields.char('Name', size=32, required=True), 'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the orderpoint without removing it."), 'logic': fields.selection([('max','Order to Max'),('price','Best price (not yet active!)')], 'Reordering Mode', required=True), - 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True), - 'location_id': fields.many2one('stock.location', 'Location', required=True), + 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True, ondelete="cascade"), + 'location_id': fields.many2one('stock.location', 'Location', required=True, ondelete="cascade"), 'product_id': fields.many2one('product.product', 'Product', required=True, ondelete='cascade', domain=[('type','=','product')]), - 'product_uom': fields.many2one('product.uom', 'Product UOM', required=True ), + 'product_uom': fields.many2one('product.uom', 'Product UOM', required=True), 'product_min_qty': fields.float('Min Quantity', required=True, help="When the virtual stock goes belong the Min Quantity, Open ERP generates "\ "a procurement to bring the virtual stock to the Max Quantity."), @@ -478,18 +478,21 @@ class stock_warehouse_orderpoint(osv.osv): "a procurement to bring the virtual stock to the Max Quantity."), 'qty_multiple': fields.integer('Qty Multiple', required=True, help="The procurement quantity will by rounded up to this multiple."), - 'procurement_id': fields.many2one('mrp.procurement', 'Latest procurement'), + 'procurement_id': fields.many2one('procurement.order', 'Latest procurement', ondelete="set null"), 'company_id': fields.many2one('res.company','Company',required=True), } _defaults = { 'active': lambda *a: 1, 'logic': lambda *a: 'max', 'qty_multiple': lambda *a: 1, - 'name': lambda x,y,z,c: x.pool.get('ir.sequence').get(y,z,'mrp.warehouse.orderpoint') or '', + 'name': lambda x,y,z,c: x.pool.get('ir.sequence').get(y,z,'stock.orderpoint') or '', 'product_uom': lambda sel, cr, uid, context: context.get('product_uom', False), 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.warehouse.orderpoint', context=c) } - + _sql_constraints = [ + ('qty_multiple_check', 'CHECK( qty_multiple > 0 )', _('Qty Multiple must be greater than zero.')), + ] + def onchange_warehouse_id(self, cr, uid, ids, warehouse_id, context={}): """ Finds location id for changed warehouse. @param warehouse_id: Changed id of warehouse. @@ -500,7 +503,7 @@ class stock_warehouse_orderpoint(osv.osv): v = {'location_id': w.lot_stock_id.id} return {'value': v} return {} - + def onchange_product_id(self, cr, uid, ids, product_id, context={}): """ Finds UoM for changed product. @param product_id: Changed id of product. @@ -511,14 +514,14 @@ class stock_warehouse_orderpoint(osv.osv): v = {'product_uom': prod.uom_id.id} return {'value': v} return {} - + def copy(self, cr, uid, id, default=None,context={}): if not default: default = {} default.update({ - 'name': self.pool.get('ir.sequence').get(cr, uid, 'mrp.warehouse.orderpoint') or '', + 'name': self.pool.get('ir.sequence').get(cr, uid, 'stock.orderpoint') or '', }) return super(stock_warehouse_orderpoint, self).copy(cr, uid, id, default, context) - + stock_warehouse_orderpoint() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp_procurement/mrp_procurement_data.xml b/addons/procurement/procurement_data.xml similarity index 50% rename from addons/mrp_procurement/mrp_procurement_data.xml rename to addons/procurement/procurement_data.xml index 256472bd2fd..6a83d525c68 100644 --- a/addons/mrp_procurement/mrp_procurement_data.xml +++ b/addons/procurement/procurement_data.xml @@ -10,10 +10,23 @@ days -1 - + + + Stock orderpoint + stock.orderpoint + + + + Stock orderpoint + stock.orderpoint + OP/ + 5 + 1 + 1 + \ No newline at end of file diff --git a/addons/mrp_procurement/mrp_procurement_view.xml b/addons/procurement/procurement_view.xml similarity index 89% rename from addons/mrp_procurement/mrp_procurement_view.xml rename to addons/procurement/procurement_view.xml index 1defa214754..b97caf6e630 100644 --- a/addons/mrp_procurement/mrp_procurement_view.xml +++ b/addons/procurement/procurement_view.xml @@ -5,9 +5,9 @@ Procurement --> - - mrp.procurement.tree - mrp.procurement + + procurement.order.tree + procurement.order tree @@ -22,9 +22,9 @@ - - mrp.procurement.form - mrp.procurement + + procurement.order.form + procurement.order form @@ -79,9 +79,9 @@ - - mrp.procurement.select - mrp.procurement + + procurement.order.select + procurement.order search @@ -109,51 +109,51 @@ - + Procurement Orders ir.actions.act_window - mrp.procurement + procurement.order form {'search_default_current':1} - + {'search_default_Current':1} - + Procurements ir.actions.act_window - mrp.procurement + procurement.order form tree,form - + [] {} - + Procurement Exceptions ir.actions.act_window - mrp.procurement + procurement.order form tree,form [('state','=','exception')] - + Procurement Exceptions to Fix ir.actions.act_window - mrp.procurement + procurement.order form tree,form [('state','=','exception'), ('message', '<>', '')] - + Temporary Procurement Exceptions ir.actions.act_window - mrp.procurement + procurement.order form tree,form [('state','=','exception'), ('message', '=', '')] @@ -255,17 +255,17 @@ + src_model="procurement.order"/> + src_model="procurement.order"/> diff --git a/addons/mrp_procurement/mrp_procurement_workflow.xml b/addons/procurement/procurement_workflow.xml similarity index 98% rename from addons/mrp_procurement/mrp_procurement_workflow.xml rename to addons/procurement/procurement_workflow.xml index 599d11cfe01..17979868a03 100644 --- a/addons/mrp_procurement/mrp_procurement_workflow.xml +++ b/addons/procurement/procurement_workflow.xml @@ -3,8 +3,8 @@ - mrp.procurement.basic - mrp.procurement + procurement.order.basic + procurement.order True diff --git a/addons/mrp_procurement/schedulers.py b/addons/procurement/schedulers.py similarity index 89% rename from addons/mrp_procurement/schedulers.py rename to addons/procurement/schedulers.py index 6ebc0f61fad..4251acf1d28 100644 --- a/addons/mrp_procurement/schedulers.py +++ b/addons/procurement/schedulers.py @@ -26,8 +26,8 @@ from mx import DateTime import time -class mrp_procurement(osv.osv): - _inherit = 'mrp.procurement' +class procurement_order(osv.osv): + _inherit = 'procurement.order' def _procure_confirm(self, cr, uid, ids=None, use_new_cursor=False, context=None): ''' @@ -40,11 +40,11 @@ class mrp_procurement(osv.osv): cr = pooler.get_db(use_new_cursor).cursor() wf_service = netsvc.LocalService("workflow") - procurement_obj = self.pool.get('mrp.procurement') + procurement_obj = self.pool.get('procurement.order') if not ids: ids = procurement_obj.search(cr, uid, [], order="date_planned") for id in ids: - wf_service.trg_validate(uid, 'mrp.procurement', id, 'button_restart', cr) + wf_service.trg_validate(uid, 'procurement.order', id, 'button_restart', cr) if use_new_cursor: cr.commit() @@ -57,11 +57,11 @@ class mrp_procurement(osv.osv): report_except = 0 report_later = 0 while True: - cr.execute('select id from mrp_procurement where state=%s and procure_method=%s order by priority,date_planned limit 500 offset %s', ('confirmed', 'make_to_order', offset)) + cr.execute('select id from procurement_order where state=%s and procure_method=%s order by priority,date_planned limit 500 offset %s', ('confirmed', 'make_to_order', offset)) ids = map(lambda x: x[0], cr.fetchall()) for proc in procurement_obj.browse(cr, uid, ids): if (maxdate.strftime('%Y-%m-%d') >= proc.date_planned): - wf_service.trg_validate(uid, 'mrp.procurement', proc.id, 'button_check', cr) + wf_service.trg_validate(uid, 'procurement.order', proc.id, 'button_check', cr) else: offset += 1 report_later += 1 @@ -84,7 +84,7 @@ class mrp_procurement(osv.osv): ids = procurement_obj.search(cr, uid, [('state', '=', 'confirmed'), ('procure_method', '=', 'make_to_stock')], offset=offset) for proc in procurement_obj.browse(cr, uid, ids): if ((maxdate).strftime('%Y-%m-%d') >= proc.date_planned) : - wf_service.trg_validate(uid, 'mrp.procurement', proc.id, 'button_check', cr) + wf_service.trg_validate(uid, 'procurement.order', proc.id, 'button_check', cr) report_ids.append(proc.id) else: report_later += 1 @@ -129,7 +129,7 @@ class mrp_procurement(osv.osv): if not context: context = {} product_obj = self.pool.get('product.product') - proc_obj = self.pool.get('mrp.procurement') + proc_obj = self.pool.get('procurement.order') warehouse_obj = self.pool.get('stock.warehouse') wf_service = netsvc.LocalService("workflow") @@ -161,8 +161,8 @@ class mrp_procurement(osv.osv): 'location_id': location_id, 'procure_method': 'make_to_order', }) - wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr) - wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_check', cr) + wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) + wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) def _procure_orderpoint_confirm(self, cr, uid, automatic=False,\ use_new_cursor=False, context=None, user_id=False): @@ -175,7 +175,7 @@ class mrp_procurement(osv.osv): cr = pooler.get_db(use_new_cursor).cursor() orderpoint_obj = self.pool.get('stock.warehouse.orderpoint') location_obj = self.pool.get('stock.location') - procurement_obj = self.pool.get('mrp.procurement') + procurement_obj = self.pool.get('procurement.order') request_obj = self.pool.get('res.request') wf_service = netsvc.LocalService("workflow") report = [] @@ -217,9 +217,9 @@ class mrp_procurement(osv.osv): 'procure_method': 'make_to_order', 'origin': op.name }) - wf_service.trg_validate(uid, 'mrp.procurement', proc_id, + wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) - wf_service.trg_validate(uid, 'mrp.procurement', proc_id, + wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) orderpoint_obj.write(cr, uid, [op.id], {'procurement_id': proc_id}) @@ -237,6 +237,6 @@ class mrp_procurement(osv.osv): cr.commit() cr.close() return {} -mrp_procurement() +procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp_procurement/scripts/scheduler.py b/addons/procurement/scripts/scheduler.py similarity index 94% rename from addons/mrp_procurement/scripts/scheduler.py rename to addons/procurement/scripts/scheduler.py index d95e8246c70..648da5cdddc 100644 --- a/addons/mrp_procurement/scripts/scheduler.py +++ b/addons/procurement/scripts/scheduler.py @@ -22,7 +22,7 @@ import xmlrpclib sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/wizard') -wiz_id = sock.create('trunk', 1, 'admin', 'mrp.procurement.compute.all') +wiz_id = sock.create('trunk', 1, 'admin', 'procurement.order.compute.all') sock.execute('trunk', 1, 'admin', wiz_id, {'form': {'po_cycle': 1.0, 'po_lead': 1.0, 'user_id': 3, 'schedule_cycle': 1.0, 'picking_lead': 1.0, 'security_lead': 50.0, 'automatic': False}, 'ids': [], 'report_type': 'pdf', 'model': 'ir.ui.menu', 'id': False}, 'compute', {}) diff --git a/addons/mrp_procurement/security/ir.model.access.csv b/addons/procurement/security/ir.model.access.csv similarity index 51% rename from addons/mrp_procurement/security/ir.model.access.csv rename to addons/procurement/security/ir.model.access.csv index ce022a730b0..f13decfa9f2 100644 --- a/addons/mrp_procurement/security/ir.model.access.csv +++ b/addons/procurement/security/ir.model.access.csv @@ -1,9 +1,9 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" "access_mrp_property_group","mrp.property.group","model_mrp_property_group",,1,0,0,0 "access_mrp_property","mrp.property","model_mrp_property",,1,0,0,0 -"access_mrp_procurement","mrp.procurement","model_mrp_procurement",,1,0,0,0 +"access_procurement","procurement.order","model_procurement_order",,1,0,0,0 "access_stock_warehouse_orderpoint","stock.warehouse.orderpoint","model_stock_warehouse_orderpoint",,1,0,0,0 -"access_mrp_procurement_compute_all","mrp.procurement.compute.all","model_mrp_procurement_compute_all",,1,0,0,0 -"access_mrp_procurement_orderpoint_compute","mrp.procurement.orderpoint.compute","model_mrp_procurement_orderpoint_compute",,1,0,0,0 +"access_procurement_compute_all","procurement.order.compute.all","model_procurement_order_compute_all",,1,0,0,0 +"access_procurement_orderpoint_compute","procurement.orderpoint.compute","model_procurement_orderpoint_compute",,1,0,0,0 "access_mrp_make_procurement","make.procurement","model_make_procurement",,1,0,0,0 -"access_mrp_make_procurement","mrp.procurement.compute","model_mrp_procurement_compute",,1,0,0,0 +"access_mrp_make_procurement","procurement.order.compute","model_procurement_order_compute",,1,0,0,0 diff --git a/addons/mrp_procurement/security/mrp_procurement_security.xml b/addons/procurement/security/procurement_security.xml similarity index 75% rename from addons/mrp_procurement/security/mrp_procurement_security.xml rename to addons/procurement/security/procurement_security.xml index a0f2ef431bf..cf32286fd2f 100644 --- a/addons/mrp_procurement/security/mrp_procurement_security.xml +++ b/addons/procurement/security/procurement_security.xml @@ -2,9 +2,9 @@ - - mrp_procurement multi-company - + + procurement multi-company + ['|',('company_id','child_of',[user.company_id.id]),('company_id','=',False)] diff --git a/addons/mrp/mrp_order_point.xml b/addons/procurement/stock_orderpoint.xml similarity index 100% rename from addons/mrp/mrp_order_point.xml rename to addons/procurement/stock_orderpoint.xml diff --git a/addons/mrp_procurement/wizard/__init__.py b/addons/procurement/wizard/__init__.py similarity index 100% rename from addons/mrp_procurement/wizard/__init__.py rename to addons/procurement/wizard/__init__.py diff --git a/addons/mrp_procurement/wizard/make_procurement_product.py b/addons/procurement/wizard/make_procurement_product.py similarity index 92% rename from addons/mrp_procurement/wizard/make_procurement_product.py rename to addons/procurement/wizard/make_procurement_product.py index 96f00b89eb4..a7bea3b247a 100644 --- a/addons/mrp_procurement/wizard/make_procurement_product.py +++ b/addons/procurement/wizard/make_procurement_product.py @@ -64,7 +64,7 @@ class make_procurement(osv.osv_memory): """ user = self.pool.get('res.users').browse(cr, uid, uid, context).login wh_obj = self.pool.get('stock.warehouse') - procurement_obj = self.pool.get('mrp.procurement') + procurement_obj = self.pool.get('procurement.order') wf_service = netsvc.LocalService("workflow") data_obj = self.pool.get('ir.model.data') @@ -80,11 +80,11 @@ class make_procurement(osv.osv_memory): 'procure_method':'make_to_order', }) - wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr) + wf_service.trg_validate(uid, 'procurement.order', procure_id, 'button_confirm', cr) - id2 = data_obj._get_id(cr, uid, 'mrp_procurement', 'mrp_procurement_tree_view') - id3 = data_obj._get_id(cr, uid, 'mrp_procurement', 'mrp_procurement_form_view') + id2 = data_obj._get_id(cr, uid, 'procurement', 'procurement_tree_view') + id3 = data_obj._get_id(cr, uid, 'procurement', 'procurement_form_view') if id2: id2 = data_obj.browse(cr, uid, id2, context=context).res_id @@ -94,7 +94,7 @@ class make_procurement(osv.osv_memory): return { 'view_type': 'form', 'view_mode': 'tree,form', - 'res_model': 'mrp.procurement', + 'res_model': 'procurement.order', 'res_id' : procure_id, 'views': [(id3,'form'),(id2,'tree')], 'type': 'ir.actions.act_window', diff --git a/addons/mrp_procurement/wizard/make_procurement_view.xml b/addons/procurement/wizard/make_procurement_view.xml similarity index 100% rename from addons/mrp_procurement/wizard/make_procurement_view.xml rename to addons/procurement/wizard/make_procurement_view.xml diff --git a/addons/mrp_procurement/wizard/mrp_procurement.py b/addons/procurement/wizard/mrp_procurement.py similarity index 95% rename from addons/mrp_procurement/wizard/mrp_procurement.py rename to addons/procurement/wizard/mrp_procurement.py index 1c3f3dd5c8a..466a462a55d 100644 --- a/addons/mrp_procurement/wizard/mrp_procurement.py +++ b/addons/procurement/wizard/mrp_procurement.py @@ -23,12 +23,12 @@ import threading from osv import osv, fields class procurement_compute(osv.osv_memory): - _name = 'mrp.procurement.compute' + _name = 'procurement.order.compute' _description = 'Compute Procurement' def _procure_calculation_procure(self, cr, uid, ids, context): try: - proc_obj = self.pool.get('mrp.procurement') + proc_obj = self.pool.get('procurement.order') proc_obj._procure_confirm(cr, uid, use_new_cursor=cr.dbname, context=context) finally: cr.close() diff --git a/addons/mrp_procurement/wizard/mrp_procurement_view.xml b/addons/procurement/wizard/mrp_procurement_view.xml similarity index 87% rename from addons/mrp_procurement/wizard/mrp_procurement_view.xml rename to addons/procurement/wizard/mrp_procurement_view.xml index 817f7011e0c..c1cf71b1abb 100644 --- a/addons/mrp_procurement/wizard/mrp_procurement_view.xml +++ b/addons/procurement/wizard/mrp_procurement_view.xml @@ -6,7 +6,7 @@ Compute Procurements - mrp.procurement.compute + procurement.order.compute form
@@ -23,8 +23,8 @@ - - + + diff --git a/addons/mrp_procurement/wizard/orderpoint_procurement.py b/addons/procurement/wizard/orderpoint_procurement.py similarity index 96% rename from addons/mrp_procurement/wizard/orderpoint_procurement.py rename to addons/procurement/wizard/orderpoint_procurement.py index 56302660939..ee3207833d3 100644 --- a/addons/mrp_procurement/wizard/orderpoint_procurement.py +++ b/addons/procurement/wizard/orderpoint_procurement.py @@ -28,7 +28,7 @@ import threading from osv import fields,osv class procurement_compute(osv.osv_memory): - _name = 'mrp.procurement.orderpoint.compute' + _name = 'procurement.orderpoint.compute' _description = 'Automatic Order Point' _columns = { @@ -47,7 +47,7 @@ class procurement_compute(osv.osv_memory): @param ids: List of IDs selected @param context: A standard dictionary """ - proc_obj = self.pool.get('mrp.procurement') + proc_obj = self.pool.get('procurement.order') for proc in self.browse(cr, uid, ids): proc_obj._procure_orderpoint_confirm(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname, context=context) diff --git a/addons/mrp_procurement/wizard/orderpoint_procurement_view.xml b/addons/procurement/wizard/orderpoint_procurement_view.xml similarity index 86% rename from addons/mrp_procurement/wizard/orderpoint_procurement_view.xml rename to addons/procurement/wizard/orderpoint_procurement_view.xml index c17bedae84f..a56c46bd299 100644 --- a/addons/mrp_procurement/wizard/orderpoint_procurement_view.xml +++ b/addons/procurement/wizard/orderpoint_procurement_view.xml @@ -6,7 +6,7 @@ Compute Stock Minimum Rules Only - mrp.procurement.orderpoint.compute + procurement.orderpoint.compute form @@ -23,8 +23,8 @@ Compute Schedulers - mrp.procurement.compute.all + procurement.order.compute.all form @@ -23,8 +23,8 @@ - - - + + + subflow.done diff --git a/addons/project_mrp/security/ir.model.access.csv b/addons/project_mrp/security/ir.model.access.csv index 407ab3716a0..7c6e2a7a30c 100644 --- a/addons/project_mrp/security/ir.model.access.csv +++ b/addons/project_mrp/security/ir.model.access.csv @@ -1,3 +1,3 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" -"access_mrp_procurement_project_user","mrp.procurement project_user","model_mrp_procurement","project.group_project_user",1,1,1,1 -"access_mrp_procurement_project_manager","mrp.procurement project_manager","model_mrp_procurement","project.group_project_manager",1,1,1,1 +"access_procurement_project_user","procurement.order project_user","model_procurement_order","project.group_project_user",1,1,1,1 +"access_procurement_project_manager","procurement.order project_manager","model_procurement_order","project.group_project_manager",1,1,1,1 diff --git a/addons/project_mrp/test/project_task_procurement.yml b/addons/project_mrp/test/project_task_procurement.yml index dda382a128a..50bc74f82ae 100644 --- a/addons/project_mrp/test/project_task_procurement.yml +++ b/addons/project_mrp/test/project_task_procurement.yml @@ -48,7 +48,7 @@ - I check the procurements. - - !python {model: mrp.procurement}: | + !python {model: procurement.order}: | from tools.translate import _ orderline_obj = self.pool.get('sale.order.line') line_ids = orderline_obj.search(cr, uid, [('order_id','=', ref('sale_order_so0'))]) @@ -58,8 +58,8 @@ - The scheduler runs. - - !function {model: mrp.procurement, name: run_scheduler}: - - model: mrp.procurement + !function {model: procurement.order, name: run_scheduler}: + - model: procurement.order search: "[('state','=','confirmed')]" - Now I check the tasks. diff --git a/addons/purchase/__openerp__.py b/addons/purchase/__openerp__.py index 46d7c3296b9..5b3830fbcb5 100644 --- a/addons/purchase/__openerp__.py +++ b/addons/purchase/__openerp__.py @@ -31,7 +31,7 @@ """, 'author': 'Tiny', 'website': 'http://www.openerp.com', - 'depends': ['base', 'account', 'stock', 'process', 'mrp_procurement'], + 'depends': ['base', 'account', 'stock', 'process', 'procurement'], 'init_xml': [], 'update_xml': [ diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 849e586335c..3fa1d3eb5c5 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -697,8 +697,8 @@ class purchase_order_line(osv.osv): return True purchase_order_line() -class mrp_procurement(osv.osv): - _inherit = 'mrp.procurement' +class procurement_order(osv.osv): + _inherit = 'procurement.order' _columns = { 'purchase_id': fields.many2one('purchase.order', 'Latest Requisition'), } @@ -776,7 +776,7 @@ class mrp_procurement(osv.osv): res[procurement.id] = purchase_id self.write(cr, uid, [procurement.id], {'state': 'running', 'purchase_id': purchase_id}) return res -mrp_procurement() +procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 8aa643d1c43..7d7ae53ab0e 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -329,9 +329,9 @@ --> - mrp.procurement.form.inherit - mrp.procurement - + procurement.order.form.inherit + procurement.order + form diff --git a/addons/purchase/purchase_workflow.xml b/addons/purchase/purchase_workflow.xml index d7684be1875..d14530e5f48 100644 --- a/addons/purchase/purchase_workflow.xml +++ b/addons/purchase/purchase_workflow.xml @@ -180,7 +180,7 @@ - + buy subflow @@ -188,20 +188,20 @@ - + check_buy() - + subflow.delivery_done - + subflow.cancel diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index 85c35b277c5..5aaf3a995e2 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -136,11 +136,11 @@ class product_product(osv.osv): product_product() -class mrp_procurement(osv.osv): - _inherit = 'mrp.procurement' +class procurement_order(osv.osv): + _inherit = 'procurement.order' def make_po(self, cr, uid, ids, context={}): sequence_obj=self.pool.get('ir.sequence') - res = super(mrp_procurement, self).make_po(cr, uid, ids, context) + res = super(procurement_order, self).make_po(cr, uid, ids, context) for proc_id,po_id in res.items(): procurement = self.browse(cr, uid, proc_id) if procurement.product_id.purchase_requisition: @@ -157,4 +157,4 @@ class mrp_procurement(osv.osv): 'purchase_ids': [(6,0,[po_id])] }) return res -mrp_procurement() +procurement_order() diff --git a/addons/purchase_requisition/test/purchase_requisition.yml b/addons/purchase_requisition/test/purchase_requisition.yml index 8983d238e0e..0ace2312034 100644 --- a/addons/purchase_requisition/test/purchase_requisition.yml +++ b/addons/purchase_requisition/test/purchase_requisition.yml @@ -59,8 +59,8 @@ - I launch he scheduler to compute all procurements, and specify all requisitions orders. - - !python {model: mrp.procurement.compute.all}: | - proc_obj = self.pool.get('mrp.procurement') + !python {model: procurement.order.compute.all}: | + proc_obj = self.pool.get('procurement.order') proc_obj._procure_confirm(cr,uid) - On the purchase tender, I create a new purchase order for the supplier 'DistriPC' by clicking on diff --git a/addons/purchase_requisition/test/purchase_requisition_exclusive.yml b/addons/purchase_requisition/test/purchase_requisition_exclusive.yml index e2cba67fca9..641fd740de3 100644 --- a/addons/purchase_requisition/test/purchase_requisition_exclusive.yml +++ b/addons/purchase_requisition/test/purchase_requisition_exclusive.yml @@ -52,8 +52,8 @@ - I launch he scheduler to compute all procurements, and planify all requisitions orders. - - !python {model: mrp.procurement.compute.all}: | - proc_obj = self.pool.get('mrp.procurement') + !python {model: procurement.order.compute.all}: | + proc_obj = self.pool.get('procurement.order') proc_obj._procure_confirm(cr,uid) - I should find a purchase requisition with the origin 'TEST/TENDER/0002', that includes a request for diff --git a/addons/sale/__init__.py b/addons/sale/__init__.py index 71f33623c55..3ad30a6233e 100644 --- a/addons/sale/__init__.py +++ b/addons/sale/__init__.py @@ -26,7 +26,6 @@ import sale import stock import product -#import mrp import wizard import report import company diff --git a/addons/sale/__openerp__.py b/addons/sale/__openerp__.py index d43278381f5..2f265b3d6f7 100644 --- a/addons/sale/__openerp__.py +++ b/addons/sale/__openerp__.py @@ -42,7 +42,7 @@ """, 'author': 'Tiny', 'website': 'http://www.openerp.com', - 'depends': ['product', 'stock', 'mrp_procurement', 'process'], + 'depends': ['product', 'stock', 'procurement', 'process'], 'init_xml': [], 'update_xml': [ 'wizard/sale_make_invoice_advance.xml', diff --git a/addons/sale/process/sale_process.xml b/addons/sale/process/sale_process.xml index 58e4be14d84..1ebbc267de7 100644 --- a/addons/sale/process/sale_process.xml +++ b/addons/sale/process/sale_process.xml @@ -35,7 +35,7 @@ - + @@ -63,12 +63,12 @@ - - + + - + @@ -202,7 +202,7 @@ - + diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 43d8d6768cc..779e13cfc33 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -113,7 +113,7 @@ class sale_order(osv.osv): LEFT JOIN stock_picking p on (p.id=m.picking_id) LEFT JOIN - mrp_procurement mp on (mp.move_id=m.id) + procurement_order mp on (mp.move_id=m.id) WHERE p.sale_id = ANY(%s) GROUP BY mp.state, p.sale_id''',(ids,)) for oid, nbr, mp_state in cr.fetchall(): @@ -659,7 +659,7 @@ class sale_order(osv.osv): 'note': line.notes, 'company_id': order.company_id.id, }) - proc_id = self.pool.get('mrp.procurement').create(cr, uid, { + proc_id = self.pool.get('procurement.order').create(cr, uid, { 'name': order.name, 'origin': order.name, 'date_planned': date_planned, @@ -677,10 +677,10 @@ class sale_order(osv.osv): 'company_id': order.company_id.id, }) wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr) + wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id}) elif line.product_id and line.product_id.product_tmpl_id.type == 'service': - proc_id = self.pool.get('mrp.procurement').create(cr, uid, { + proc_id = self.pool.get('procurement.order').create(cr, uid, { 'name': line.name, 'origin': order.name, 'date_planned': date_planned, @@ -694,7 +694,7 @@ class sale_order(osv.osv): }) self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id}) wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr) + wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) else: # # No procurement because no product in the sale.order.line. @@ -815,7 +815,7 @@ class sale_order_line(osv.osv): 'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], change_default=True), 'invoice_lines': fields.many2many('account.invoice.line', 'sale_order_line_invoice_rel', 'order_line_id', 'invoice_id', 'Invoice Lines', readonly=True), 'invoiced': fields.boolean('Invoiced', readonly=True), - 'procurement_id': fields.many2one('mrp.procurement', 'Procurement'), + 'procurement_id': fields.many2one('procurement.order', 'Procurement'), 'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Sale Price'), readonly=True, states={'draft':[('readonly',False)]}), 'price_net': fields.function(_amount_line_net, method=True, string='Net Price', digits_compute= dp.get_precision('Sale Price')), 'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal', digits_compute= dp.get_precision('Sale Price')), @@ -865,7 +865,7 @@ class sale_order_line(osv.osv): return line.product_uos_qty or 0.0 return line.product_uom_qty else: - return self.pool.get('mrp.procurement').quantity_get(cr, uid, + return self.pool.get('procurement.order').quantity_get(cr, uid, line.procurement_id.id, context=context) def _get_line_uom(line): @@ -874,7 +874,7 @@ class sale_order_line(osv.osv): return line.product_uos.id return line.product_uom.id else: - return self.pool.get('mrp.procurement').uom_get(cr, uid, + return self.pool.get('procurement.order').uom_get(cr, uid, line.procurement_id.id, context=context) create_ids = [] diff --git a/addons/sale/sale_demo.xml b/addons/sale/sale_demo.xml index d6ab6a7bc0c..0920cdeebb2 100644 --- a/addons/sale/sale_demo.xml +++ b/addons/sale/sale_demo.xml @@ -206,7 +206,7 @@ - + diff --git a/addons/sale/sale_unit_test.xml b/addons/sale/sale_unit_test.xml index dc507edb4a0..95a23024412 100644 --- a/addons/sale/sale_unit_test.xml +++ b/addons/sale/sale_unit_test.xml @@ -112,7 +112,7 @@ - + done diff --git a/addons/sale/sale_workflow.xml b/addons/sale/sale_workflow.xml index 213605929ba..effe7cb6fff 100644 --- a/addons/sale/sale_workflow.xml +++ b/addons/sale/sale_workflow.xml @@ -218,7 +218,7 @@ - mrp.procurement + procurement.order procurement_lines_get() test_state('finished') @@ -226,7 +226,7 @@ test_state('canceled') diff --git a/addons/sale/security/ir.model.access.csv b/addons/sale/security/ir.model.access.csv index 7af8c1e74a7..de0f55b80b1 100644 --- a/addons/sale/security/ir.model.access.csv +++ b/addons/sale/security/ir.model.access.csv @@ -11,7 +11,7 @@ "access_account_analytic_account_salesman","account_analytic_account salesman","analytic.model_account_analytic_account","group_sale_user",1,1,1,1 "access_stock_picking_salesman","stock_picking salesman","stock.model_stock_picking","group_sale_user",1,1,1,1 "access_stock_move_salesman","stock_move salesman","stock.model_stock_move","group_sale_user",1,1,1,0 -"access_mrp_procurement_salesman","mrp.procurement salesman","mrp_procurement.model_mrp_procurement","group_sale_user",1,1,1,1 +"access_procurement_salesman","procurement.order salesman","procurement.model_procurement_order","group_sale_user",1,1,1,1 "access_sale_order_stock_worker","sale.order stock worker","model_sale_order","stock.group_stock_user",1,1,0,0 "access_sale_order_line_stock_worker","sale.order.line stock worker","model_sale_order_line","stock.group_stock_user",1,1,0,0 "access_sale_order_manager","sale.order.manager","model_sale_order","group_sale_manager",1,1,1,1 diff --git a/addons/sale/test/sale_procurement.yml b/addons/sale/test/sale_procurement.yml index a5e78117674..33ba22667ec 100644 --- a/addons/sale/test/sale_procurement.yml +++ b/addons/sale/test/sale_procurement.yml @@ -72,21 +72,21 @@ - I check that one procurement is generated. - - !python {model: mrp.procurement}: | + !python {model: procurement.order}: | from tools.translate import _ proc_ids = self.search(cr, uid, [('state','=','confirmed')]) assert proc_ids, _('No Procurements!') - The scheduler runs. - - !function {model: mrp.procurement, name: run_scheduler}: - - model: mrp.procurement + !function {model: procurement.order, name: run_scheduler}: + - model: procurement.order search: "[('state','=','confirmed')]" - I check that the procurement for the product table is in exception state. As my product's supply method is produce and mrp module is yet not installed. - - !python {model: mrp.procurement}: | + !python {model: procurement.order}: | from tools.translate import _ proc_ids = self.search(cr, uid, [('state','=','exception')]) assert proc_ids, _('No Procurements are in exception state!') diff --git a/addons/sale_mrp/__init__.py b/addons/sale_mrp/__init__.py new file mode 100644 index 00000000000..c47eb12b3f3 --- /dev/null +++ b/addons/sale_mrp/__init__.py @@ -0,0 +1,24 @@ +# -*- 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 sale_mrp + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale_mrp/__openerp__.py b/addons/sale_mrp/__openerp__.py new file mode 100644 index 00000000000..9ac55911983 --- /dev/null +++ b/addons/sale_mrp/__openerp__.py @@ -0,0 +1,44 @@ +# -*- 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 . +# +############################################################################## + + +{ + 'name': 'Sales and MRP Management', + 'version': '1.0', + 'category': 'Generic Modules/Sales & MRP', + 'description': """ + This module provides facility to the user to install mrp and sale modules + at a time. It is basically used when we want to keep track of production + orders generated from sale orders. + """, + 'author': 'Tiny', + 'website': 'http://www.openerp.com', + 'depends': ['mrp', 'sale'], + 'init_xml': [], + 'update_xml': [ + 'sale_mrp_view.xml', + ], + 'demo_xml': [], + 'installable': True, + 'active': False, + 'certificate': '', +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale/mrp.py b/addons/sale_mrp/sale_mrp.py similarity index 81% rename from addons/sale/mrp.py rename to addons/sale_mrp/sale_mrp.py index bb16a65425a..4f52cb7dd9b 100644 --- a/addons/sale/mrp.py +++ b/addons/sale_mrp/sale_mrp.py @@ -23,10 +23,14 @@ from osv import osv, fields class mrp_production(osv.osv): - _inherit = 'mrp.production' def _ref_calc(self, cr, uid, ids, field_names=None, arg=False, context={}): + """ Finds reference of sale order for production order. + @param field_names: Names of fields. + @param arg: User defined arguments + @return: Dictionary of values. + """ if not field_names: field_names=[] res = {} @@ -65,4 +69,11 @@ class mrp_production(osv.osv): res[production['id']] = move.sale_line_id and move.sale_line_id.order_id.client_order_ref or False return res -mrp_production() \ No newline at end of file + _columns = { + 'sale_name': fields.function(_ref_calc, method=True, multi='sale_name', type='char', string='Sale Name', help='Indicate the name of sale order.'), + 'sale_ref': fields.function(_ref_calc, method=True, multi='sale_ref', type='char', string='Sale Reference', help='Indicate the Customer Reference from sale order.'), + } + +mrp_production() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale_mrp/sale_mrp_view.xml b/addons/sale_mrp/sale_mrp_view.xml new file mode 100644 index 00000000000..a595e9471be --- /dev/null +++ b/addons/sale_mrp/sale_mrp_view.xml @@ -0,0 +1,18 @@ + + + + + + mrp.production.form + mrp.production + + form + + + + + + + + + diff --git a/addons/stock/product.py b/addons/stock/product.py index bac29d57673..5336143befb 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -52,13 +52,10 @@ class product_product(osv.osv): return res def do_change_standard_price(self, cr, uid, ids, datas, context={}): - """ - Changes the Standard Price of Product and creates an account move accordingly. - - @param datas : dict. contain default datas like new_price, stock_output_account, stock_input_account, stock_journal - @param context: A standard dictionary - - @return: + """ Changes the Standard Price of Product and creates an account move accordingly. + @param datas : dict. contain default datas like new_price, stock_output_account, stock_input_account, stock_journal + @param context: A standard dictionary + @return: """ location_obj = self.pool.get('stock.location') @@ -175,7 +172,10 @@ class product_product(osv.osv): return _('Products: ')+self.pool.get('stock.location').browse(cr, user, context['location'], context).name return res - def get_product_available(self,cr,uid,ids,context=None): + def get_product_available(self, cr, uid, ids, context=None): + """ Finds whether product is available or not in particular warehouse. + @return: Dictionary of values + """ if context is None: context = {} states = context.get('states',[]) @@ -280,22 +280,25 @@ class product_product(osv.osv): return res def _product_available(self, cr, uid, ids, field_names=None, arg=False, context={}): + """ Finds the incoming and outgoing quantity of product. + @return: Dictionary of values + """ if not field_names: - field_names=[] + field_names = [] res = {} for id in ids: res[id] = {}.fromkeys(field_names, 0.0) for f in field_names: c = context.copy() - if f=='qty_available': - c.update({ 'states':('done',), 'what':('in', 'out') }) - if f=='virtual_available': - c.update({ 'states':('confirmed','waiting','assigned','done'), 'what':('in', 'out') }) - if f=='incoming_qty': - c.update({ 'states':('confirmed','waiting','assigned'), 'what':('in',) }) - if f=='outgoing_qty': - c.update({ 'states':('confirmed','waiting','assigned'), 'what':('out',) }) - stock=self.get_product_available(cr,uid,ids,context=c) + if f == 'qty_available': + c.update({ 'states': ('done',), 'what': ('in', 'out') }) + if f == 'virtual_available': + c.update({ 'states': ('confirmed','waiting','assigned','done'), 'what': ('in', 'out') }) + if f == 'incoming_qty': + c.update({ 'states': ('confirmed','waiting','assigned'), 'what': ('in',) }) + if f == 'outgoing_qty': + c.update({ 'states': ('confirmed','waiting','assigned'), 'what': ('out',) }) + stock = self.get_product_available(cr, uid, ids, context=c) for id in ids: res[id][f] = stock.get(id, 0.0) return res diff --git a/addons/stock/stock.py b/addons/stock/stock.py index cfb3a7d674d..dcdbe079a8e 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -78,6 +78,9 @@ class stock_location(osv.osv): return res def _complete_name(self, cr, uid, ids, name, args, context): + """ Forms complete name of location from parent location to child location. + @return: Dictionary of values + """ def _get_one_full_name(location, level=4): if location.location_id: parent_path = _get_one_full_name(location.location_id, level-1) + "/" @@ -90,6 +93,9 @@ class stock_location(osv.osv): return res def _product_qty_available(self, cr, uid, ids, field_names, arg, context={}): + """ Finds real and virtual quantity for product available at particular location. + @return: Dictionary of values + """ res = {} for id in ids: res[id] = {}.fromkeys(field_names, 0.0) @@ -106,6 +112,10 @@ class stock_location(osv.osv): return res def product_detail(self, cr, uid, id, field, context={}): + """ Finds detail of product like price type, currency and then calculates its price. + @param field: Field name + @return: Calculated price + """ res = {} res[id] = {} final_value = 0.0 @@ -117,21 +127,25 @@ class stock_location(osv.osv): if result: # Choose the right filed standard_price to read # Take the user company - price_type_id=self.pool.get('res.users').browse(cr,uid,uid).company_id.property_valuation_price_type.id - pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id) + price_type_id = self.pool.get('res.users').browse(cr,uid,uid).company_id.property_valuation_price_type.id + pricetype = self.pool.get('product.price.type').browse(cr, uid, price_type_id) for r in result: c = (context or {}).copy() c['location'] = id product = self.pool.get('product.product').read(cr, uid, r['product_id'], [field_to_read], context=c) # Compute the amount_unit in right currency - context['currency_id']=self.pool.get('res.users').browse(cr,uid,uid).company_id.currency_id.id - amount_unit=self.pool.get('product.product').browse(cr,uid,r['product_id']).price_get(pricetype.field, context)[r['product_id']] + context['currency_id'] = self.pool.get('res.users').browse(cr,uid,uid).company_id.currency_id.id + amount_unit = self.pool.get('product.product').browse(cr,uid,r['product_id']).price_get(pricetype.field, context)[r['product_id']] final_value += (product[field_to_read] * amount_unit) return final_value def _product_value(self, cr, uid, ids, field_names, arg, context={}): + """ Calculates real and virtual stock value of a product. + @param field_names: Name of field + @return: Dictionary of values + """ result = {} for id in ids: result[id] = {}.fromkeys(field_names, 0.0) @@ -199,6 +213,12 @@ class stock_location(osv.osv): } def chained_location_get(self, cr, uid, location, partner=None, product=None, context={}): + """ Finds chained location + @param location: Location id + @param partner: Partner id + @param product: Product id + @return: List of values + """ result = None if location.chained_location_type == 'customer': if partner: @@ -210,6 +230,11 @@ class stock_location(osv.osv): return result def picking_type_get(self, cr, uid, from_location, to_location, context={}): + """ Gets type of picking. + @param from_location: Source location + @param to_location: Destination location + @return: Location type + """ result = 'internal' if (from_location.usage=='internal') and (to_location and to_location.usage in ('customer', 'supplier')): result = 'delivery' @@ -224,13 +249,18 @@ class stock_location(osv.osv): def _product_get_report(self, cr, uid, ids, product_ids=False, context=None, recursive=False): + """ Finds the product quantity and price for particular location. + @param product_ids: Ids of product + @param recursive: True or False + @return: Dictionary of values + """ if context is None: context = {} product_obj = self.pool.get('product.product') # Take the user company and pricetype - price_type_id=self.pool.get('res.users').browse(cr,uid,uid).company_id.property_valuation_price_type.id - pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id) - context['currency_id']=self.pool.get('res.users').browse(cr,uid,uid).company_id.currency_id.id + price_type_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.property_valuation_price_type.id + pricetype = self.pool.get('product.price.type').browse(cr, uid, price_type_id) + context['currency_id'] = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id if not product_ids: product_ids = product_obj.search(cr, uid, []) @@ -265,7 +295,7 @@ class stock_location(osv.osv): # Compute based on pricetype # Choose the right filed standard_price to read - amount_unit=product.price_get(pricetype.field, context)[product.id] + amount_unit = product.price_get(pricetype.field, context)[product.id] price = qty[product_id] * amount_unit # price = qty[product_id] * product.standard_price @@ -283,7 +313,14 @@ class stock_location(osv.osv): result['total_price'] = total_price return result - def _product_get_multi_location(self, cr, uid, ids, product_ids=False, context={}, states=['done'], what=('in', 'out')): + def _product_get_multi_location(self, cr, uid, ids, product_ids=False, context={}, + states=['done'], what=('in', 'out')): + """ + @param product_ids: Ids of product + @param states: List of states + @param what: Tuple of + @return: + """ product_obj = self.pool.get('product.product') context.update({ 'states': states, @@ -293,6 +330,11 @@ class stock_location(osv.osv): return product_obj.get_product_available(cr, uid, product_ids, context=context) def _product_get(self, cr, uid, id, product_ids=False, context={}, states=['done']): + """ + @param product_ids: + @param states: + @return: + """ ids = id and [id] or [] return self._product_get_multi_location(cr, uid, ids, product_ids, context, states) @@ -313,6 +355,11 @@ class stock_location(osv.osv): # [ (tracking_id, product_qty, location_id) ] # def _product_reserve(self, cr, uid, ids, product_id, product_qty, context={}): + """ + @param product_id: Id of product + @param product_qty: Quantity of product + @return: List of Values or False + """ result = [] amount = 0.0 for id in self.search(cr, uid, [('location_id', 'child_of', ids)]): @@ -352,6 +399,10 @@ class stock_tracking(osv.osv): _description = "Stock Tracking Lots" def get_create_tracking_lot(self, cr, uid, ids, tracking_lot): + """ + @param tracking_lot: Name of tracking lot + @return: + """ tracking_lot_list = self.search(cr, uid, [('name', '=', tracking_lot)], limit=1) if tracking_lot_list: @@ -382,6 +433,7 @@ class stock_tracking(osv.osv): 'move_ids': fields.one2many('stock.move', 'tracking_id', 'Moves Tracked'), 'date': fields.datetime('Created Date', required=True), } + _defaults = { 'active': lambda *a: 1, 'name': make_sscc, @@ -417,6 +469,12 @@ class stock_picking(osv.osv): _description = "Picking List" def _set_maximum_date(self, cr, uid, ids, name, value, arg, context): + """ Calculates planned date if it is greater than 'value'. + @param name: Name of field + @param value: Value of field + @param arg: User defined argument + @return: True or False + """ if not value: return False if isinstance(ids, (int, long)): @@ -433,6 +491,12 @@ class stock_picking(osv.osv): return True def _set_minimum_date(self, cr, uid, ids, name, value, arg, context): + """ Calculates planned date if it is less than 'value'. + @param name: Name of field + @param value: Value of field + @param arg: User defined argument + @return: True or False + """ if not value: return False if isinstance(ids, (int, long)): @@ -448,6 +512,9 @@ class stock_picking(osv.osv): return True def get_min_max_date(self, cr, uid, ids, field_name, arg, context={}): + """ Finds minimum and maximum dates for picking. + @return: Dictionary of values + """ res = {} for id in ids: res[id] = {'min_date': False, 'max_date': False} @@ -553,6 +620,9 @@ class stock_picking(osv.osv): return moves def action_confirm(self, cr, uid, ids, context={}): + """ Confirms picking. + @return: True + """ self.write(cr, uid, ids, {'state': 'confirmed'}) todo = [] for picking in self.browse(cr, uid, ids, context=context): @@ -576,6 +646,9 @@ class stock_picking(osv.osv): # return True def action_assign(self, cr, uid, ids, *args): + """ Changes state of picking to available if all moves are confirmed. + @return: True + """ for pick in self.browse(cr, uid, ids): move_ids = [x.id for x in pick.move_lines if x.state == 'confirmed'] if not move_ids: @@ -584,6 +657,9 @@ class stock_picking(osv.osv): return True def force_assign(self, cr, uid, ids, *args): + """ Changes state of picking to available if moves are confirmed or waiting. + @return: True + """ wf_service = netsvc.LocalService("workflow") for pick in self.browse(cr, uid, ids): move_ids = [x.id for x in pick.move_lines if x.state in ['confirmed','waiting']] @@ -593,6 +669,9 @@ class stock_picking(osv.osv): return True def draft_force_assign(self, cr, uid, ids, *args): + """ Confirms picking directly from draft state. + @return: True + """ wf_service = netsvc.LocalService("workflow") for pick in self.browse(cr, uid, ids): wf_service.trg_validate(uid, 'stock.picking', pick.id, @@ -603,6 +682,9 @@ class stock_picking(osv.osv): return True def draft_validate(self, cr, uid, ids, *args): + """ Validates picking directly from draft state. + @return: True + """ wf_service = netsvc.LocalService("workflow") self.draft_force_assign(cr, uid, ids) for pick in self.browse(cr, uid, ids): @@ -615,6 +697,9 @@ class stock_picking(osv.osv): return True def cancel_assign(self, cr, uid, ids, *args): + """ Cancels picking and moves. + @return: True + """ wf_service = netsvc.LocalService("workflow") for pick in self.browse(cr, uid, ids): move_ids = [x.id for x in pick.move_lines] @@ -623,6 +708,9 @@ class stock_picking(osv.osv): return True def action_assign_wkf(self, cr, uid, ids, context=None): + """ Changes picking state to assigned. + @return: True + """ for pick in self.browse(cr, uid, ids, context=context): type_list = { 'out':'Packing List', @@ -636,6 +724,9 @@ class stock_picking(osv.osv): return True def test_finnished(self, cr, uid, ids): + """ Tests whether the move is in done or cancel state or not. + @return: True or False + """ move_ids = self.pool.get('stock.move').search(cr, uid, [('picking_id', 'in', ids)]) for move in self.pool.get('stock.move').browse(cr, uid, move_ids): if move.state not in ('done', 'cancel'): @@ -646,18 +737,24 @@ class stock_picking(osv.osv): return True def test_assigned(self, cr, uid, ids): + """ Tests whether the move is in assigned state or not. + @return: True or False + """ ok = True for pick in self.browse(cr, uid, ids): mt = pick.move_type for move in pick.move_lines: - if (move.state in ('confirmed', 'draft')) and (mt=='one'): + if (move.state in ('confirmed', 'draft')) and (mt == 'one'): return False - if (mt=='direct') and (move.state=='assigned') and (move.product_qty): + if (mt == 'direct') and (move.state == 'assigned') and (move.product_qty): return True ok = ok and (move.state in ('cancel', 'done', 'assigned')) return ok def action_cancel(self, cr, uid, ids, context={}): + """ Changes picking state to cancel. + @return: True + """ for pick in self.browse(cr, uid, ids): ids2 = [move.id for move in pick.move_lines] self.pool.get('stock.move').action_cancel(cr, uid, ids2, context) @@ -668,10 +765,16 @@ class stock_picking(osv.osv): # TODO: change and create a move if not parents # def action_done(self, cr, uid, ids, context=None): + """ Changes picking state to done. + @return: True + """ self.write(cr, uid, ids, {'state': 'done', 'date_done': time.strftime('%Y-%m-%d %H:%M:%S')}) return True def action_move(self, cr, uid, ids, context={}): + """ Changes move state to assigned. + @return: True + """ for pick in self.browse(cr, uid, ids): todo = [] for move in pick.move_lines: @@ -687,13 +790,17 @@ class stock_picking(osv.osv): return False def _get_payment_term(self, cr, uid, picking): - '''Return {'contact': address, 'invoice': address} for invoice''' + """ Gets payment term from partner. + @return: Payment term + """ partner_obj = self.pool.get('res.partner') partner = picking.address_id.partner_id return partner.property_payment_term and partner.property_payment_term.id or False def _get_address_invoice(self, cr, uid, picking): - '''Return {'contact': address, 'invoice': address} for invoice''' + """ Gets invoice address of a partner + @return {'contact': address, 'invoice': address} for invoice + """ partner_obj = self.pool.get('res.partner') partner = picking.address_id.partner_id @@ -701,11 +808,17 @@ class stock_picking(osv.osv): ['contact', 'invoice']) def _get_comment_invoice(self, cr, uid, picking): - '''Return comment string for invoice''' + """ + @return: comment string for invoice + """ return picking.note or '' def _get_price_unit_invoice(self, cr, uid, move_line, type, context=None): - '''Return the price unit for the move line''' + """ Gets price unit for invoice + @param move_line: Stock move lines + @param type: Type of invoice + @return: The price unit for the move line + """ if context is None: context = {} @@ -725,7 +838,11 @@ class stock_picking(osv.osv): return 0.0 def _get_taxes_invoice(self, cr, uid, move_line, type): - '''Return taxes ids for the move line''' + """ Gets taxes on invoice + @param move_line: Stock move lines + @param type: Type of invoice + @return: Taxes Ids for the move line + """ if type in ('in_invoice', 'in_refund'): taxes = move_line.product_id.supplier_taxes_id else: @@ -754,7 +871,12 @@ class stock_picking(osv.osv): def action_invoice_create(self, cr, uid, ids, journal_id=False, group=False, type='out_invoice', context=None): - '''Return ids of created invoices for the pickings''' + """ Creates invoice based on the invoice state selected for picking. + @param journal_id: Id of journal + @param group: Whether to create a group invoice or not + @param type: Type invoice to be created + @return: Ids of created invoices for the pickings + """ if context is None: context = {} @@ -884,6 +1006,9 @@ class stock_picking(osv.osv): return res def test_cancel(self, cr, uid, ids, context={}): + """ Test whether the move lines are canceled or not. + @return: True or False + """ for pick in self.browse(cr, uid, ids, context=context): if not pick.move_lines: return False @@ -913,9 +1038,11 @@ class stock_picking(osv.osv): return super(stock_picking, self).unlink(cr, uid, ids, context=context) def do_partial(self, cr, uid, ids, partial_datas, context={}): - """ - @ partial_datas : dict. contain details of partial picking - like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom + """ Makes partial picking and moves done. + @param partial_datas : Dictionary containing details of partial picking + like partner_id, address_id, delivery_date, + delivery moves with product_id, product_qty, uom + @return: Dictionary of values """ res = {} @@ -1080,6 +1207,9 @@ class stock_production_lot(osv.osv): _description = 'Production lot' def _get_stock(self, cr, uid, ids, field_name, arg, context={}): + """ Gets stock of products for locations + @return: Dictionary of values + """ if 'location_id' not in context: locations = self.pool.get('stock.location').search(cr, uid, [('usage', '=', 'internal')], context=context) else: @@ -1101,6 +1231,9 @@ class stock_production_lot(osv.osv): return res def _stock_search(self, cr, uid, obj, name, args, context): + """ Searches Ids of products + @return: Ids of locations + """ locations = self.pool.get('stock.location').search(cr, uid, [('usage', '=', 'internal')]) cr.execute('''select prodlot_id, @@ -1124,6 +1257,7 @@ class stock_production_lot(osv.osv): 'revisions': fields.one2many('stock.production.lot.revision', 'lot_id', 'Revisions'), 'company_id': fields.many2one('res.company','Company',select=1), } + _defaults = { 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), 'name': lambda x, y, z, c: x.pool.get('ir.sequence').get(y, z, 'stock.lot.serial'), @@ -1138,6 +1272,7 @@ stock_production_lot() class stock_production_lot_revision(osv.osv): _name = 'stock.production.lot.revision' _description = 'Production lot revisions' + _columns = { 'name': fields.char('Revision Name', size=64, required=True), 'description': fields.text('Description'), @@ -1157,10 +1292,11 @@ stock_production_lot_revision() class stock_delivery(osv.osv): - """ Tracability of partialdeliveries """ + """ Traceability of partial deliveries """ _name = "stock.delivery" _description = "Delivery" + _columns = { 'name': fields.char('Name', size=60, required=True), 'date': fields.datetime('Date', required=True), @@ -1195,6 +1331,9 @@ class stock_move(osv.osv): return res def _check_tracking(self, cr, uid, ids): + """ Checks if production lot is assigned to stock move or not. + @return: True or False + """ for move in self.browse(cr, uid, ids): if not move.prodlot_id and \ (move.state == 'done' and \ @@ -1208,6 +1347,9 @@ class stock_move(osv.osv): return True def _check_product_lot(self, cr, uid, ids): + """ Checks whether move is done or not and production lot is assigned to that move. + @return: True or False + """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False @@ -1267,6 +1409,9 @@ class stock_move(osv.osv): ['prodlot_id'])] def _default_location_destination(self, cr, uid, context={}): + """ Gets default address of partner for destination location + @return: Address id or False + """ if context.get('move_line', []): if context['move_line'][0]: if isinstance(context['move_line'][0], (tuple, list)): @@ -1279,6 +1424,9 @@ class stock_move(osv.osv): return False def _default_location_source(self, cr, uid, context={}): + """ Gets default address of partner for source location + @return: Address id or False + """ if context.get('move_line', []): try: return context['move_line'][0][2]['location_id'] @@ -1329,7 +1477,15 @@ class stock_move(osv.osv): cursor.commit() return res - def onchange_lot_id(self, cr, uid, ids, prodlot_id=False, product_qty=False, loc_id=False, product_id=False, context=None): + def onchange_lot_id(self, cr, uid, ids, prodlot_id=False, product_qty=False, + loc_id=False, product_id=False, context=None): + """ On change of production lot gives a warning message. + @param prodlot_id: Changed production lot id + @param product_qty: Quantity of product + @param loc_id: Location id + @param product_id: Product id + @return: Warning message + """ if not prodlot_id or not loc_id: return {} ctx = context and context.copy() or {} @@ -1344,7 +1500,15 @@ class stock_move(osv.osv): } return {'warning': warning} - def onchange_quantity(self, cr, uid, ids, product_id, product_qty, product_uom, product_uos): + def onchange_quantity(self, cr, uid, ids, product_id, product_qty, + product_uom, product_uos): + """ On change of product quantity finds UoM and UoS quantities + @param product_id: Product id + @param product_qty: Changed Quantity of product + @param product_uom: Unit of measure of product + @param product_uos: Unit of sale of product + @return: Dictionary of values + """ result = { 'product_uos_qty': 0.00 } @@ -1362,7 +1526,15 @@ class stock_move(osv.osv): return {'value': result} - def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False, loc_dest_id=False, address_id=False): + def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False, + loc_dest_id=False, address_id=False): + """ On change of product id, if finds UoM, UoS, quantity and UoS quantity. + @param prod_id: Changed Product id + @param loc_id: Source location id + @param loc_id: Destination location id + @param address_id: Address id of partner + @return: Dictionary of values + """ if not prod_id: return {} lang = False @@ -1389,6 +1561,10 @@ class stock_move(osv.osv): return {'value': result} def _chain_compute(self, cr, uid, moves, context={}): + """ Finds whether the location has chained location type or not. + @param moves: Stock moves + @return: Dictionary containing destination location with chained location type. + """ result = {} for m in moves: dest = self.pool.get('stock.location').chained_location_get( @@ -1411,6 +1587,9 @@ class stock_move(osv.osv): return result def action_confirm(self, cr, uid, ids, context={}): + """ Confirms stock move. + @return: List of ids. + """ # ids = map(lambda m: m.id, moves) moves = self.browse(cr, uid, ids) self.write(cr, uid, ids, {'state': 'confirmed'}) @@ -1458,6 +1637,9 @@ class stock_move(osv.osv): return [] def action_assign(self, cr, uid, ids, *args): + """ Changes state to confirmed or waiting. + @return: List of values + """ todo = [] for move in self.browse(cr, uid, ids): if move.state in ('confirmed', 'waiting'): @@ -1466,10 +1648,16 @@ class stock_move(osv.osv): return res def force_assign(self, cr, uid, ids, context={}): + """ Changes the state to assigned. + @return: True + """ self.write(cr, uid, ids, {'state': 'assigned'}) return True def cancel_assign(self, cr, uid, ids, context={}): + """ Changes the state to confirmed. + @return: True + """ self.write(cr, uid, ids, {'state': 'confirmed'}) return True @@ -1477,6 +1665,9 @@ class stock_move(osv.osv): # Duplicate stock.move # def check_assign(self, cr, uid, ids, context={}): + """ Checks the product type and accordingly writes the state. + @return: No. of moves done + """ done = [] count = 0 pickings = {} @@ -1518,6 +1709,9 @@ class stock_move(osv.osv): # Cancel move => cancel others move and pickings # def action_cancel(self, cr, uid, ids, context={}): + """ Cancels the moves and if all moves are cancelled it cancels the picking. + @return: True + """ if not len(ids): return True pickings = {} @@ -1543,6 +1737,9 @@ class stock_move(osv.osv): return True def action_done(self, cr, uid, ids, context={}): + """ Makes the move done and if all moves are done, it will finish the picking. + @return: + """ track_flag = False picking_ids = [] product_uom_obj = self.pool.get('product.uom') @@ -1680,6 +1877,9 @@ class stock_move(osv.osv): cr, uid, ids, context=context) def _create_lot(self, cr, uid, ids, product_id, prefix=False): + """ Creates production lot + @return: Production lot id + """ prodlot_obj = self.pool.get('stock.production.lot') ir_sequence_obj = self.pool.get('ir.sequence') sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial') @@ -1695,18 +1895,15 @@ class stock_move(osv.osv): def action_scrap(self, cr, uid, ids, quantity, location_id, context=None): - ''' - Move the scrap/damaged product into scrap location - - @ param cr: the database cursor - @ param uid: the user id - @ param ids: ids of stock move object to be scraped - @ param quantity : specify scrap qty - @ param location_id : specify scrap location - @ param context: context arguments - - @ return: Scraped lines - ''' + """ Move the scrap/damaged product into scrap location + @param cr: the database cursor + @param uid: the user id + @param ids: ids of stock move object to be scraped + @param quantity : specify scrap qty + @param location_id : specify scrap location + @param context: context arguments + @return: Scraped lines + """ if quantity <= 0: raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !')) res = [] @@ -1727,19 +1924,16 @@ class stock_move(osv.osv): return res def action_split(self, cr, uid, ids, quantity, split_by_qty=1, prefix=False, with_lot=True, context=None): - ''' - Split Stock Move lines into production lot which specified split by quantity. - - @ param cr: the database cursor - @ param uid: the user id - @ param ids: ids of stock move object to be splited - @ param split_by_qty : specify split by qty - @ param prefix : specify prefix of production lot - @ param with_lot : if true, prodcution lot will assign for split line otherwise not. - @ param context: context arguments - - @ return: splited move lines - ''' + """ Split Stock Move lines into production lot which specified split by quantity. + @param cr: the database cursor + @param uid: the user id + @param ids: ids of stock move object to be splited + @param split_by_qty : specify split by qty + @param prefix : specify prefix of production lot + @param with_lot : if true, prodcution lot will assign for split line otherwise not. + @param context: context arguments + @return: Splited move lines + """ if quantity <= 0: raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !')) @@ -1790,18 +1984,15 @@ class stock_move(osv.osv): return res def action_consume(self, cr, uid, ids, quantity, location_id=False, context=None): - ''' - Consumed product with specific quatity from specific source location - - @ param cr: the database cursor - @ param uid: the user id - @ param ids: ids of stock move object to be consumed - @ param quantity : specify consume quantity - @ param location_id : specify source location - @ param context: context arguments - - @ return: Consumed lines - ''' + """ Consumed product with specific quatity from specific source location + @param cr: the database cursor + @param uid: the user id + @param ids: ids of stock move object to be consumed + @param quantity : specify consume quantity + @param location_id : specify source location + @param context: context arguments + @return: Consumed lines + """ if context is None: context = {} @@ -1861,9 +2052,10 @@ class stock_move(osv.osv): return res def do_partial(self, cr, uid, ids, partial_datas, context={}): - """ - @ partial_datas : dict. contain details of partial picking - like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom + """ Makes partial pickings and moves done. + @param partial_datas: Dictionary containing details of partial picking + like partner_id, address_id, delivery_date, delivery + moves with product_id, product_qty, uom """ res = {} picking_obj = self.pool.get('stock.picking') @@ -2017,10 +2209,17 @@ class stock_inventory(osv.osv): def _inventory_line_hook(self, cr, uid, inventory_line, move_vals): - '''Creates a stock move from an inventory line''' + """ Creates a stock move from an inventory line + @param inventory_line: + @param move_vals: + @return: + """ return self.pool.get('stock.move').create(cr, uid, move_vals) def action_done(self, cr, uid, ids, context=None): + """ Finishes the inventory and writes its finished date + @return: True + """ for inv in self.browse(cr, uid, ids): move_ids = [] move_line = [] @@ -2067,12 +2266,18 @@ class stock_inventory(osv.osv): return True def action_cancel(self, cr, uid, ids, context={}): + """ Cancels the stock move and change inventory state to draft. + @return: True + """ for inv in self.browse(cr, uid, ids): self.pool.get('stock.move').action_cancel(cr, uid, [x.id for x in inv.move_ids], context) self.write(cr, uid, [inv.id], {'state': 'draft'}) return True def action_cancel_inventary(self, cr, uid, ids, context={}): + """ Cancels both stock move and inventory + @return: True + """ for inv in self.browse(cr,uid,ids): self.pool.get('stock.move').action_cancel(cr, uid, [x.id for x in inv.move_ids], context) self.write(cr, uid, [inv.id], {'state':'cancel'}) @@ -2096,6 +2301,12 @@ class stock_inventory_line(osv.osv): } def on_change_product_id(self, cr, uid, ids, location_id, product, uom=False): + """ Changes UoM and name if product_id changes. + @param location_id: Location id + @param product: Changed product_id + @param uom: UoM product + @return: Dictionary of changed values + """ if not product: return {} if not uom: diff --git a/addons/stock/wizard/stock_change_standard_price.py b/addons/stock/wizard/stock_change_standard_price.py index d83b2c1d140..149b0b04e84 100644 --- a/addons/stock/wizard/stock_change_standard_price.py +++ b/addons/stock/wizard/stock_change_standard_price.py @@ -34,17 +34,13 @@ class change_standard_price(osv.osv_memory): } def default_get(self, cr, uid, fields, context): - """ - To get default values for the object. - + """ To get default values for the object. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param fields: List of fields for which we want default values @param context: A standard dictionary - @return: A dictionary which of fields with values. - """ product_pool = self.pool.get('product.product') product_obj = product_pool.browse(cr, uid, context.get('active_id', False)) @@ -68,6 +64,16 @@ class change_standard_price(osv.osv_memory): return res def onchange_price(self, cr, uid, ids, new_price, context = {}): + """ Sets stock input and output account according to the difference + of old price and new price. + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: List of IDs selected + @param new_price: Changed price + @param context: A standard dictionary + @return: Dictionary of values + """ product_obj = self.pool.get('product.product').browse(cr, uid, context.get('active_id', False)) price = product_obj.standard_price diff = price - new_price @@ -77,18 +83,14 @@ class change_standard_price(osv.osv_memory): return {'value' : {'enable_stock_in_out_acc':False}} def change_price(self, cr, uid, ids, context): - """ - Changes the Standard Price of Product. - And creates an account move accordingly. - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: List of IDs selected - @param context: A standard dictionary - - @return: - + """ Changes the Standard Price of Product. + And creates an account move accordingly. + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: List of IDs selected + @param context: A standard dictionary + @return: """ rec_id = context and context.get('active_id', False) assert rec_id, _('Active ID is not set in Context') diff --git a/addons/stock/wizard/stock_fill_inventory.py b/addons/stock/wizard/stock_fill_inventory.py index 3247628657a..3742349425c 100644 --- a/addons/stock/wizard/stock_fill_inventory.py +++ b/addons/stock/wizard/stock_fill_inventory.py @@ -34,21 +34,17 @@ class stock_fill_inventory(osv.osv_memory): _description = "Fill Inventory" _columns = { 'location_id': fields.many2one('stock.location', 'Location', required=True), - 'recursive': fields.boolean("Include all childs for the location"), - } + 'recursive': fields.boolean("Include all children for the location"), + } def fill_inventory(self, cr, uid, ids, context): - """ - To fill stock inventory according to products available in the selected locations.. - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: the ID or list of IDs if we want more than one - @param context: A standard dictionary - - @return: - + """ To fill stock inventory according to products available in the selected locations. + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: the ID or list of IDs if we want more than one + @param context: A standard dictionary + @return: """ inventory_line_obj = self.pool.get('stock.inventory.line') location_obj = self.pool.get('stock.location') diff --git a/addons/stock/wizard/stock_inventory_line_split.py b/addons/stock/wizard/stock_inventory_line_split.py index 9fe71582c7f..9f91a47c9a5 100644 --- a/addons/stock/wizard/stock_inventory_line_split.py +++ b/addons/stock/wizard/stock_inventory_line_split.py @@ -35,17 +35,13 @@ class stock_inventory_line_split(osv.osv_memory): def default_get(self, cr, uid, fields, context): - """ - To check the availability of production lot. - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param fields: List of fields for which we want default values - @param context: A standard dictionary - - @return: A dictionary which of fields with values. - + """ To check the availability of production lot. + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param fields: List of fields for which we want default values + @param context: A standard dictionary + @return: A dictionary which of fields with values. """ record_id = context and context.get('active_id',False) res = super(stock_inventory_line_split, self).default_get(cr, uid, fields, context=context) @@ -55,18 +51,14 @@ class stock_inventory_line_split(osv.osv_memory): return res def split(self, cr, uid, ids, line_ids, context=None): - """ - To split stock inventory lines according to production lot - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: the ID or list of IDs if we want more than one - @param line_ids: the ID or list of IDs of inventory lines we want to split - @param context: A standard dictionary - - @return: - + """ To split stock inventory lines according to production lot. + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: the ID or list of IDs if we want more than one + @param line_ids: the ID or list of IDs of inventory lines we want to split + @param context: A standard dictionary + @return: """ prodlot_obj = self.pool.get('stock.production.lot') ir_sequence_obj = self.pool.get('ir.sequence') diff --git a/addons/stock/wizard/stock_inventory_merge.py b/addons/stock/wizard/stock_inventory_merge.py index 1c11ad8e2ad..30450e4d253 100644 --- a/addons/stock/wizard/stock_inventory_merge.py +++ b/addons/stock/wizard/stock_inventory_merge.py @@ -31,22 +31,15 @@ import wizard class stock_inventory_merge(osv.osv_memory): _name = "stock.inventory.merge" _description = "Merge Inventory" - _columns = { - - } def do_merge(self, cr, uid, ids, context): - """ - To merge selected Inventories. - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: List of IDs selected - @param context: A standard dictionary - - @return: - + """ To merge selected Inventories. + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: List of IDs selected + @param context: A standard dictionary + @return: """ invent_obj = self.pool.get('stock.inventory') invent_line_obj = self.pool.get('stock.inventory.line') diff --git a/addons/stock/wizard/stock_inventory_set_stock_zero.py b/addons/stock/wizard/stock_inventory_set_stock_zero.py index 63296b69875..f72e4f088b0 100644 --- a/addons/stock/wizard/stock_inventory_set_stock_zero.py +++ b/addons/stock/wizard/stock_inventory_set_stock_zero.py @@ -32,22 +32,19 @@ import wizard class inventory_set_stock_zero(osv.osv_memory): _name = "stock.inventory.set.stock.zero" _description = "Set Stock to 0" + _columns = { 'location_id': fields.many2one('stock.location', 'Location', required=True), - } + } def do_merge(self, cr, uid, ids, context): - """ - To set stock to Zero - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: the ID or list of IDs if we want more than one - @param context: A standard dictionary - - @return: - + """ To set stock to Zero + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: the ID or list of IDs if we want more than one + @param context: A standard dictionary + @return: """ invent_obj = pooler.get_pool(cr.dbname).get('stock.inventory') invent_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line') diff --git a/addons/stock/wizard/stock_invoice_onshipping.py b/addons/stock/wizard/stock_invoice_onshipping.py index d2b671e9571..377a40f3cb9 100644 --- a/addons/stock/wizard/stock_invoice_onshipping.py +++ b/addons/stock/wizard/stock_invoice_onshipping.py @@ -39,20 +39,16 @@ class stock_invoice_onshipping(osv.osv_memory): ('out_refund', 'Customer Refund'), ('in_refund', 'Supplier Refund')] , 'Type', required=True), 'invoice_date': fields.date('Invoiced date'), - } + } def _get_type(self, cr, uid, context=None): - """ - To get invoice type - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: the ID or list of IDs if we want more than one - @param context: A standard dictionary - - @return: invoice type - + """ To get invoice type. + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: The ID or list of IDs if we want more than one + @param context: A standard dictionary + @return: Invoice type """ if context is None: context = {} @@ -80,20 +76,16 @@ class stock_invoice_onshipping(osv.osv_memory): _defaults = { 'type': _get_type, - } + } def create_invoice(self, cr, uid, ids, context): - """ - To create invoice - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: the ID or list of IDs if we want more than one - @param context: A standard dictionary - - @return: invoice ids - + """ To create invoice + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: the ID or list of IDs if we want more than one + @param context: A standard dictionary + @return: Invoice ids """ result = [] picking_obj = self.pool.get('stock.picking') diff --git a/addons/stock/wizard/stock_location_product.py b/addons/stock/wizard/stock_location_product.py index b41809b67bd..9fe800bb0fe 100644 --- a/addons/stock/wizard/stock_location_product.py +++ b/addons/stock/wizard/stock_location_product.py @@ -30,16 +30,13 @@ class stock_location_product(osv.osv_memory): } def action_open_window(self, cr, uid, ids, context): - """ - To open location wise product information specific to given duration - + """ To open location wise product information specific to given duration @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in - @param ids: the ID or list of IDs if we want more than one + @param ids: An ID or list of IDs if we want more than one @param context: A standard dictionary - - @return: invoice type + @return: Invoice type """ mod_obj = self.pool.get('ir.model.data') for location_obj in self.read(cr, uid, ids, ['from_date', 'to_date']): diff --git a/addons/stock/wizard/stock_move.py b/addons/stock/wizard/stock_move.py index 00b7b616aa5..f4429ad408a 100644 --- a/addons/stock/wizard/stock_move.py +++ b/addons/stock/wizard/stock_move.py @@ -29,24 +29,20 @@ class stock_move_track(osv.osv_memory): _columns = { 'tracking_prefix': fields.char('Tracking prefix', size=64), 'quantity': fields.float("Quantity per lot") - } + } _defaults = { 'quantity': lambda *x: 1 - } + } def track_lines(self, cr, uid, ids, context={}): - """ - To track stock moves lines - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: the ID or list of IDs if we want more than one - @param context: A standard dictionary - - @return: - + """ To track stock moves lines + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: An ID or list of IDs if we want more than one + @param context: A standard dictionary + @return: """ datas = self.read(cr, uid, ids)[0] move_obj = self.pool.get('stock.move') @@ -67,17 +63,13 @@ class stock_move_consume(osv.osv_memory): } def default_get(self, cr, uid, fields, context=None): - """ - Get default values - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param fields: List of fields for default value - @param context: A standard dictionary - - @return: default values of fields - + """ Get default values + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param fields: List of fields for default value + @param context: A standard dictionary + @return: default values of fields """ res = super(stock_move_consume, self).default_get(cr, uid, fields, context=context) move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context) @@ -93,17 +85,13 @@ class stock_move_consume(osv.osv_memory): return res def do_move_consume(self, cr, uid, ids, context={}): - """ - To move consumed products - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: the ID or list of IDs if we want more than one - @param context: A standard dictionary - - @return: - + """ To move consumed products + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: the ID or list of IDs if we want more than one + @param context: A standard dictionary + @return: """ move_obj = self.pool.get('stock.move') move_ids = context['active_ids'] @@ -126,17 +114,13 @@ class stock_move_scrap(osv.osv_memory): } def default_get(self, cr, uid, fields, context=None): - """ - Get default values - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param fields: List of fields for default value - @param context: A standard dictionary - - @return: default values of fields - + """ Get default values + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param fields: List of fields for default value + @param context: A standard dictionary + @return: default values of fields """ res = super(stock_move_consume, self).default_get(cr, uid, fields, context=context) move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context) @@ -158,17 +142,13 @@ class stock_move_scrap(osv.osv_memory): return res def move_scrap(self, cr, uid, ids, context={}): - """ - To move scraped products - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: the ID or list of IDs if we want more than one - @param context: A standard dictionary - - @return: - + """ To move scraped products + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: the ID or list of IDs if we want more than one + @param context: A standard dictionary + @return: """ move_obj = self.pool.get('stock.move') move_ids = context['active_ids'] @@ -186,17 +166,13 @@ class split_in_production_lot(osv.osv_memory): _description = "Split in Production lots" def default_get(self, cr, uid, fields, context=None): - """ - Get default values - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param fields: List of fields for default value - @param context: A standard dictionary - - @return: default values of fields - + """ Get default values + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param fields: List of fields for default value + @param context: A standard dictionary + @return: Default values of fields """ res = super(split_in_production_lot, self).default_get(cr, uid, fields, context=context) @@ -209,35 +185,28 @@ class split_in_production_lot(osv.osv_memory): 'product_id': fields.many2one('product.product', 'Product', required=True, select=True), 'line_ids': fields.one2many('stock.move.split.lines', 'lot_id', 'Lots Number') } + def split_lot(self, cr, uid, ids, context=None): - """ - To split a lot - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: the ID or list of IDs if we want more than one - @param context: A standard dictionary - - @return: - + """ To split a lot + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: An ID or list of IDs if we want more than one + @param context: A standard dictionary + @return: """ self.split(cr, uid, ids, context.get('active_ids'), context=context) return {} def split(self, cr, uid, ids, move_ids, context=None): - """ - To split stock moves into production lot - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: the ID or list of IDs if we want more than one - @param move_ids: the ID or list of IDs of stock move we want to split - @param context: A standard dictionary - - @return: - + """ To split stock moves into production lot + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: the ID or list of IDs if we want more than one + @param move_ids: the ID or list of IDs of stock move we want to split + @param context: A standard dictionary + @return: """ prodlot_obj = self.pool.get('stock.production.lot') ir_sequence_obj = self.pool.get('ir.sequence') @@ -303,6 +272,7 @@ class stock_move_split_lines(osv.osv_memory): 'lot_id': fields.many2one('stock.move.split', 'Lot'), 'action': fields.selection([('split','Split'),('keepinone','Keep in one lot')],'Action'), } + _defaults = { 'quantity': lambda *x: 1, 'action' : lambda *x: 'split', diff --git a/addons/stock/wizard/stock_partial_move.py b/addons/stock/wizard/stock_partial_move.py index 4a5206d1ef0..e8849b3d1a9 100644 --- a/addons/stock/wizard/stock_partial_move.py +++ b/addons/stock/wizard/stock_partial_move.py @@ -30,10 +30,9 @@ class stock_partial_move(osv.osv_memory): _name = "stock.partial.move" _description = "Partial Move" _columns = { - 'date': fields.datetime('Date', required=True), - 'partner_id': fields.many2one('res.partner',string="Partner", required=True), - 'address_id': fields.many2one('res.partner.address', 'Delivery Address', help="Address where goods are to be delivered", required=True), - + 'date': fields.datetime('Date', required=True), + 'partner_id': fields.many2one('res.partner',string="Partner", required=True), + 'address_id': fields.many2one('res.partner.address', 'Delivery Address', help="Address where goods are to be delivered", required=True), } def view_init(self, cr, uid, fields_list, context=None): @@ -140,17 +139,13 @@ class stock_partial_move(osv.osv_memory): return result def default_get(self, cr, uid, fields, context=None): - """ - To get default values for the object. - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param fields: List of fields for which we want default values - @param context: A standard dictionary - - @return: A dictionary which of fields with values. - + """ To get default values for the object. + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param fields: List of fields for which we want default values + @param context: A standard dictionary + @return: A dictionary which of fields with values. """ res = super(stock_partial_move, self).default_get(cr, uid, fields, context=context) @@ -185,7 +180,16 @@ class stock_partial_move(osv.osv_memory): res['move%s_product_currency'%(m.id)] = currency return res - def do_partial(self, cr, uid, ids, context): + def do_partial(self, cr, uid, ids, context): + """ Makes partial moves and pickings done. + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param fields: List of fields for which we want default values + @param context: A standard dictionary + @return: A dictionary which of fields with values. + """ + rec_id = context and context.get('active_id', False) tracking_lot = context.get('tracking_lot', False) if tracking_lot: @@ -218,5 +222,6 @@ class stock_partial_move(osv.osv_memory): return {} stock_partial_move() + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py index 022488cfc43..1e6b98633b0 100644 --- a/addons/stock/wizard/stock_partial_picking.py +++ b/addons/stock/wizard/stock_partial_picking.py @@ -29,10 +29,9 @@ class stock_partial_picking(osv.osv_memory): _name = "stock.partial.picking" _description = "Partial Picking" _columns = { - 'date': fields.datetime('Date', required=True), - 'partner_id': fields.many2one('res.partner',string="Partner", required=True), - 'address_id': fields.many2one('res.partner.address', 'Delivery Address', help="Address where goods are to be delivered", required=True), - + 'date': fields.datetime('Date', required=True), + 'partner_id': fields.many2one('res.partner',string="Partner", required=True), + 'address_id': fields.many2one('res.partner.address', 'Delivery Address', help="Address where goods are to be delivered", required=True), } def view_init(self, cr, uid, fields_list, context=None): @@ -141,17 +140,13 @@ class stock_partial_picking(osv.osv_memory): return result def default_get(self, cr, uid, fields, context=None): - """ - To get default values for the object. - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param fields: List of fields for which we want default values - @param context: A standard dictionary - - @return: A dictionary which of fields with values. - + """ To get default values for the object. + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param fields: List of fields for which we want default values + @param context: A standard dictionary + @return: A dictionary which of fields with values. """ res = super(stock_partial_picking, self).default_get(cr, uid, fields, context=context) @@ -191,7 +186,15 @@ class stock_partial_picking(osv.osv_memory): res['move%s_product_currency'%(m.id)] = currency return res - def do_partial(self, cr, uid, ids, context): + def do_partial(self, cr, uid, ids, context): + """ Makes partial moves and pickings done. + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param fields: List of fields for which we want default values + @param context: A standard dictionary + @return: A dictionary which of fields with values. + """ pick_obj = self.pool.get('stock.picking') picking_ids = context.get('active_ids', False) partial = self.browse(cr, uid, ids[0], context) diff --git a/addons/stock/wizard/stock_replacement.py b/addons/stock/wizard/stock_replacement.py index a6f39212ef8..8b6c36f0f21 100644 --- a/addons/stock/wizard/stock_replacement.py +++ b/addons/stock/wizard/stock_replacement.py @@ -38,20 +38,17 @@ class stock_replacement(osv.osv_memory): return {} def replace_composant(self, cr, uid, ids, context = {}): - """ - to open a new wizard that acknowledge, a replacement task - - @return: it returns the replacement acknowledgement form - + """ To open a new wizard that acknowledge, a replacement task + @return: It returns the replacement acknowledgement form """ return { - 'name': False, - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'stock.replacement.result', - 'type': 'ir.actions.act_window', - 'target':'new', - } + 'name': False, + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'stock.replacement.result', + 'type': 'ir.actions.act_window', + 'target':'new', + } stock_replacement() diff --git a/addons/stock/wizard/stock_split_move.py b/addons/stock/wizard/stock_split_move.py index c1354e21578..f3e72bfdc11 100644 --- a/addons/stock/wizard/stock_split_move.py +++ b/addons/stock/wizard/stock_split_move.py @@ -26,8 +26,7 @@ class stock_split_move_line(osv.osv_memory): _description = "Split Moves" def default_get(self, cr, uid, fields, context): - """ - To get default values for the object. + """ To get default values for the object. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @@ -44,8 +43,7 @@ class stock_split_move_line(osv.osv_memory): return res def view_init(self, cr, uid, fields_list, context=None): - """ - Creates view dynamically and adding fields at runtime. + """ Creates view dynamically and adding fields at runtime. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @@ -67,8 +65,7 @@ class stock_split_move_line(osv.osv_memory): def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): - """ - Changes the view dynamically + """ Changes the view dynamically @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @@ -94,8 +91,7 @@ class stock_split_move_line(osv.osv_memory): return res def split_lines(self, cr, uid, ids, context): - """ - Splits moves in quantity given in the wizard. + """ Splits moves in quantity given in the wizard. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in diff --git a/addons/stock/wizard/stock_traceability.py b/addons/stock/wizard/stock_traceability.py index 120fa658b1c..d2fadb1d89c 100644 --- a/addons/stock/wizard/stock_traceability.py +++ b/addons/stock/wizard/stock_traceability.py @@ -34,18 +34,15 @@ class action_traceability(osv.osv_memory): _description = "Action traceability " def action_traceability(self, cr, uid, ids, context={}): - """ - It traces the information of a product - - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: List of IDs selected - @param context: A standard dictionary - - @return: A dictionary of values - + """ It traces the information of a product + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: List of IDs selected + @param context: A standard dictionary + @return: A dictionary of values """ + type1 = context['type'] or 'move_history_ids' field = context['field'] or 'tracking_id' obj = self.pool.get('stock.move') diff --git a/addons/stock/wizard/stock_ups.py b/addons/stock/wizard/stock_ups.py index 5bde686402f..aeefcd0d106 100644 --- a/addons/stock/wizard/stock_ups.py +++ b/addons/stock/wizard/stock_ups.py @@ -31,25 +31,25 @@ class stock_ups(osv.osv_memory): _description = "Stock ups" def ups_save(self, cr, uid, ids, context = {}): - return { - 'name': False, - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'stock.ups.final', - 'type': 'ir.actions.act_window', - 'target':'new', - } + '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 = {}): - return { - 'name': False, - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'stock.ups.upload', - 'type': 'ir.actions.act_window', - 'target':'new', - } + '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), } @@ -64,6 +64,9 @@ class stock_ups_final(osv.osv_memory): _description = "Stock ups final" def create_xmlfile(self, cr, uid, ids, context = {}): + """ Creates xml report file. + @return: xml file + """ report = netsvc._group['report']['report.stock.move.lot.ups_xml'] data['report_type'] = 'raw' return {'xmlfile' : report.create(uid, context['active_id'], ids, {})} @@ -79,6 +82,9 @@ class stock_ups_upload(osv.osv_memory): _description = "Stock ups upload" def upload_xmlfile(self, cr, uid, ids, context = {}): + """ Uploads xml report file. + @return: + """ report = netsvc._group['report']['report.stock.move.lot.ups_xml'] data['report_type'] = 'raw' #FIXME: this seems unfinished diff --git a/addons/stock_planning/stock_planning.py b/addons/stock_planning/stock_planning.py index 3bdc14bce82..d4d7337bbb0 100644 --- a/addons/stock_planning/stock_planning.py +++ b/addons/stock_planning/stock_planning.py @@ -899,7 +899,7 @@ class stock_planning(osv.osv): raise osv.except_osv(_('Error !'), _('Incoming Left must be greater than 0 !')) uom_qty, uom, uos_qty, uos = self._qty_to_standard(cr, uid, obj, context) user = self.pool.get('res.users').browse(cr, uid, uid, context) - proc_id = self.pool.get('mrp.procurement').create(cr, uid, { + proc_id = self.pool.get('procurement.order').create(cr, uid, { 'company_id' : obj.company_id.id, 'name': _('Manual planning for ') + obj.period_id.name, 'origin': _('MPS(') + str(user.login) +') '+ obj.period_id.name, @@ -926,7 +926,7 @@ class stock_planning(osv.osv): }, context=context) wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr) + wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) self.calculate_planning(cr, uid, ids, context) prev_text = obj.history or "" self.write(cr, uid, ids, {