From 855d51f0efadddff5edeba38f2d59de14972e8cb Mon Sep 17 00:00:00 2001 From: Rucha Patel Date: Thu, 18 Sep 2008 16:21:54 +0530 Subject: [PATCH] Added new fields sale_name,sale_ref in mrp.production ,Created new Report : Production Order bzr revid: ruchakpatel@gmail.com-20080918105154-nt96sye11jurls3i --- addons/mrp/mrp.py | 31 +++++++- addons/mrp/mrp_report.xml | 9 +++ addons/mrp/mrp_view.xml | 3 +- addons/mrp/report/__init__.py | 1 + addons/mrp/report/order.py | 42 +++++++++++ addons/mrp/report/order.rml | 135 ++++++++++++++++++++++++++++++++++ 6 files changed, 219 insertions(+), 2 deletions(-) create mode 100644 addons/mrp/report/order.py create mode 100644 addons/mrp/report/order.rml diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 121ebbe6e1d..bb6684ca04f 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -304,6 +304,33 @@ class mrp_production(osv.osv): _name = 'mrp.production' _description = 'Production' _date_name = 'date_planned' + + def _get_sale_order(self,cr,uid,ids,field_name=False): + move_obj=self.pool.get('stock.move') + def get_parent_move(move_id): + move = move_obj.browse(cr,uid,move_id) + if move.move_dest_id: + return get_parent_move(move.move_dest_id.id) + return move_id + productions=self.read(cr,uid,ids,['id','move_prod_id']) + res={} + for production in productions: + if production.get('move_prod_id',False): + parent_move_line=get_parent_move(production['move_prod_id'][0]) + if parent_move_line: + move = move_obj.browse(cr,uid,parent_move_line) + if field_name=='name': + res[production['id']]=move.sale_line_id and move.sale_line_id.order_id.name or False + if field_name=='client_order_ref': + res[production['id']]=move.sale_line_id and move.sale_line_id.order_id.client_order_ref or False + return res + + def _sale_name_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict): + return self._get_sale_order(cr,uid,ids,field_name='name') + + def _sale_ref_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict): + return self._get_sale_order(cr,uid,ids,field_name='client_order_ref') + _columns = { 'name': fields.char('Reference', size=64, required=True), 'origin': fields.char('Origin', size=64), @@ -332,7 +359,9 @@ class mrp_production(osv.osv): 'product_lines': fields.one2many('mrp.production.product.line', 'production_id', 'Scheduled goods'), 'workcenter_lines': fields.one2many('mrp.production.workcenter.line', 'production_id', 'Workcenters Utilisation'), - 'state': fields.selection([('draft','Draft'),('picking_except', 'Packing Exception'),('confirmed','Waiting Goods'),('ready','Ready to Produce'),('in_production','In Production'),('cancel','Canceled'),('done','Done')],'Status', readonly=True) + 'state': fields.selection([('draft','Draft'),('picking_except', 'Packing Exception'),('confirmed','Waiting Goods'),('ready','Ready to Produce'),('in_production','In Production'),('cancel','Canceled'),('done','Done')],'Status', readonly=True), + 'sale_name': fields.function(_sale_name_calc, method=True, type='char', string='Sale Name'), + 'sale_ref': fields.function(_sale_ref_calc, method=True, type='char', string='Sale Ref'), } _defaults = { 'priority': lambda *a: '1', diff --git a/addons/mrp/mrp_report.xml b/addons/mrp/mrp_report.xml index f6eca4722e8..eb97477f687 100644 --- a/addons/mrp/mrp_report.xml +++ b/addons/mrp/mrp_report.xml @@ -4,5 +4,14 @@ + + diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 55986cd260c..3776668cb8c 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -406,7 +406,6 @@ - @@ -448,6 +447,8 @@ + + diff --git a/addons/mrp/report/__init__.py b/addons/mrp/report/__init__.py index f55a94f166e..32bb00568ff 100644 --- a/addons/mrp/report/__init__.py +++ b/addons/mrp/report/__init__.py @@ -28,6 +28,7 @@ ############################################################################### import price import workcenter_load +import order # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp/report/order.py b/addons/mrp/report/order.py new file mode 100644 index 00000000000..1d801b3aa2e --- /dev/null +++ b/addons/mrp/report/order.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import time +from report import report_sxw +from osv import osv +import pooler + +class order(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): + super(order, self).__init__(cr, uid, name, context) + self.localcontext.update({ + 'time': time, + }) + + +report_sxw.report_sxw('report.mrp.production.order','mrp.production','addons/mrp/report/order.rml',parser=order) diff --git a/addons/mrp/report/order.rml b/addons/mrp/report/order.rml new file mode 100644 index 00000000000..cc1b0bf34b3 --- /dev/null +++ b/addons/mrp/report/order.rml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[ repeatIn(objects,'o') ]] + + + + + + + Production Order N° : [[ o.name ]] + + + + Printing date : [[ time.strftime('%d/%m/%Y') ]] + Partner Order reference : [[ o.sale_ref or ' ' ]] + SO number : [[ o.sale_name or '' ]] + + + + + + + Product Name + + + Product Description + + + Qty + + + +
+ + + + [[ '['+ o.product_id.code +']' ]] [[ o.product_id.name ]] + + + [[ o.product_id.description ]] + + + [[ '%.2f' % o.product_qty ]] [[ o.product_uom.name ]] + + + +
+ + + + + ......... + ......... + + + + + Planned Date + + + : + + + [[ time.strftime('%d/%m/%Y', time.strptime(o.date_planned, '%Y-%m-%d %H:%M:%S')) ]] + + + + + + + + + +
+