From cbfed7bb039b7be9629903ab8a5d080d3a5657eb Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Wed, 24 Nov 2010 18:03:32 +0530 Subject: [PATCH] [IMP]:Task-1847 Add many2many function field bzr revid: ksa@tinyerp.co.in-20101124123332-6fet5o4g12yopr1z --- addons/procurement/procurement.py | 15 +++++++++++++++ addons/procurement/procurement_view.xml | 14 +++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index b3fa0bfeb99..f350e79205b 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -490,6 +490,19 @@ class stock_warehouse_orderpoint(osv.osv): _name = "stock.warehouse.orderpoint" _description = "Minimum Inventory Rule" + def procurement_draft(self, cr, uid, ids, field_name, arg, context=None): + if context is None: + context = {} + result = {} + procurement_obj = self.pool.get('procurement.order') + for data in self.browse(cr, uid, ids, context=context): + procurement_id = [] + result[data.id] = procurement_id + + procurement_ids = procurement_obj.search(cr, uid , [('state','=','draft'),('product_id','=',data.product_id.id),('location_id','=',data.location_id.id)]) + result[data.id] = procurement_ids + return result + _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."), @@ -508,6 +521,8 @@ class stock_warehouse_orderpoint(osv.osv): help="The procurement quantity will by rounded up to this multiple."), 'procurement_id': fields.many2one('procurement.order', 'Latest procurement', ondelete="set null"), 'company_id': fields.many2one('res.company','Company',required=True), + 'procurement_data_id': fields.function(procurement_draft, method=True, type='many2many', relation="procurement.order", \ + string="Related Procurement Orders",help="Draft procurement of the product and location of that orderpoint"), } _defaults = { 'active': lambda *a: 1, diff --git a/addons/procurement/procurement_view.xml b/addons/procurement/procurement_view.xml index 96b96f3af21..9ef921cc23a 100644 --- a/addons/procurement/procurement_view.xml +++ b/addons/procurement/procurement_view.xml @@ -4,7 +4,7 @@ - + procurement.order.tree @@ -145,7 +145,7 @@ Procurement Orders represent the need for a certain quantity of products, at a given time, in a given location. Sale Orders are one typical source of Procurement Orders (but these are distinct documents). Depending on the procurement parameters and the products configuration, the procurement engine will attempt to satisfy the need by reserving products from stock, or ordering products from a supplier, or passing a manufacturing order, etc. A Procurement Exception occurs when the system cannot find a way to fulfill a procurement. Some exceptions will resolve themselves automatically, but others require manual intervention (those are identified by a specific error message) - + Procurement Exceptions ir.actions.act_window @@ -224,6 +224,10 @@ + + + + @@ -238,11 +242,11 @@ You can define your minimum stock rules, so that OpenERP will trigger automatically the propositions of manufacturing or purchase orders according to the stock level. Once the virtual stock of a product (=stock on hand minus all confirmed orders and reservations) is bellow the minimum quantity, OpenERP will generate a procurement request in order to fullfil the stock up to the maximum quantity. -