diff options
| author | Rucha Patel <ruchakpatel@gmail.com> | 2008-09-18 16:21:54 +0530 |
|---|---|---|
| committer | Rucha Patel <ruchakpatel@gmail.com> | 2008-09-18 16:21:54 +0530 |
| commit | 855d51f0efadddff5edeba38f2d59de14972e8cb (patch) | |
| tree | bb291fccd8d867e827d8014aa671781598a024a3 | |
| parent | 4890f683d51a80d57b01edf0f3c2f2d307c02153 (diff) | |
Added new fields sale_name,sale_ref in mrp.production ,Created new Report : Production Order
bzr revid: ruchakpatel@gmail.com-20080918105154-nt96sye11jurls3i
| -rw-r--r-- | addons/mrp/mrp.py | 31 | ||||
| -rw-r--r-- | addons/mrp/mrp_report.xml | 9 | ||||
| -rw-r--r-- | addons/mrp/mrp_view.xml | 3 | ||||
| -rw-r--r-- | addons/mrp/report/__init__.py | 1 | ||||
| -rw-r--r-- | addons/mrp/report/order.py | 42 | ||||
| -rw-r--r-- | addons/mrp/report/order.rml | 135 |
6 files changed, 219 insertions, 2 deletions
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 @@ <report auto="True" header="False" id="report_bom_structure" model="mrp.bom" name="bom.structure" rml="mrp/report/bom_structure.rml" string="BOM Structure"/> + <report + id="report_mrp_production_report" + string="Production Order" + model="mrp.production" + name="mrp.production.order" + rml="mrp/report/order.rml" + auto="False" + /> + </data> </openerp> 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 @@ <field name="name" select="1"/> <field name="date_planned" select="1"/> <field name="priority"/> - <field name="product_id" on_change="product_id_change(product_id)" select="1"/> <field name="product_qty"/> <field name="product_uom"/> @@ -448,6 +447,8 @@ <field name="date_finnished"/> <field name="picking_id"/> <field name="move_prod_id"/> + <field name="sale_name"/> + <field name="sale_ref"/> </page> </notebook> </form> 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 @@ +<?xml version="1.0"?> +<document filename="test.pdf"> + <template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20"> + <pageTemplate id="first"> + <frame id="first" x1="34.0" y1="42.0" width="527" height="758"/> + </pageTemplate> + </template> + <stylesheet> + <blockTableStyle id="Standard_Outline"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + </blockTableStyle> + <blockTableStyle id="Table1"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/> + <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/> + <lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/> + </blockTableStyle> + <blockTableStyle id="Table2"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,-1" stop="0,-1"/> + <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/> + <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/> + </blockTableStyle> + <blockTableStyle id="Table3"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + </blockTableStyle> + <initialize> + <paraStyle name="all" alignment="justify"/> + </initialize> + <paraStyle name="P1" fontName="Helvetica-Bold" fontSize="16.0" leading="20"/> + <paraStyle name="P2" fontName="Helvetica" fontSize="16.0" leading="20"/> + <paraStyle name="P3" fontName="Helvetica"/> + <paraStyle name="P4" fontName="Helvetica-Bold" fontSize="11.0" leading="14"/> + <paraStyle name="P5" fontName="Helvetica-Bold" fontSize="11.0" leading="14" alignment="LEFT"/> + <paraStyle name="P6" fontName="Helvetica-Bold" fontSize="11.0" leading="14" alignment="RIGHT"/> + <paraStyle name="P7" fontName="Helvetica-Bold" fontSize="11.0" leading="14"/> + <paraStyle name="P8" fontName="Helvetica-Bold" fontSize="9.0" leading="11"/> + <paraStyle name="P9" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="LEFT"/> + <paraStyle name="P10" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT"/> + <paraStyle name="P11" fontName="Helvetica" fontSize="10.0" leading="13" alignment="RIGHT"/> + <paraStyle name="P12" fontName="Helvetica" alignment="LEFT"/> + <paraStyle name="P13" fontName="Helvetica-Oblique" fontSize="9.0" leading="11"/> + <paraStyle name="P14" fontName="Helvetica" fontSize="9.0" leading="11"/> + <paraStyle name="P15" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="LEFT"/> + <paraStyle name="P16" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="CENTER"/> + <paraStyle name="P17" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT"/> + <paraStyle name="P18" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="0.0" spaceAfter="3.0"/> + <paraStyle name="Standard" fontName="Times-Roman"/> + <paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/> + <paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/> + <paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/> + <paraStyle name="Table Contents" fontName="Times-Roman"/> + <paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER"/> + <paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/> + <paraStyle name="Index" fontName="Times-Roman"/> + </stylesheet> + <images/> + <story> + <para style="P14">[[ repeatIn(objects,'o') ]] </para> + <para style="P13"> + <font color="white"> </font> + </para> + <para style="P14"> + <font color="white"> </font> + </para> + <para style="P1">Production Order N° : [[ o.name ]]</para> + <para style="P2"> + <font color="white"> </font> + </para> + <para style="P18">Printing date : [[ time.strftime('%d/%m/%Y') ]]</para> + <para style="P18">Partner Order reference : [[ o.sale_ref or ' ' ]]</para> + <para style="P18">SO number : [[ o.sale_name or '' ]]</para> + <para style="P3"> + <font color="white"> </font> + </para> + <blockTable colWidths="130.0,313.0,85.0" repeatRows="1" style="Table1"> + <tr> + <td> + <para style="P4">Product Name</para> + </td> + <td> + <para style="P5">Product Description</para> + </td> + <td> + <para style="P6">Qty</para> + </td> + </tr> + </blockTable> + <section> + <blockTable colWidths="130.0,312.0,86.0" style="Table2"> + <tr> + <td> + <para style="P10">[[ '['+ o.product_id.code +']' ]] [[ o.product_id.name ]]</para> + </td> + <td> + <para style="P10">[[ o.product_id.description ]]</para> + </td> + <td> + <para style="P11">[[ '%.2f' % o.product_qty ]] [[ o.product_uom.name ]]</para> + </td> + </tr> + </blockTable> + </section> + <para style="P7"> + <font color="white"> </font> + </para> + <para style="P8"> + <font color="white"> .........</font> + <font color="white"> .........</font> + </para> + <blockTable colWidths="86.0,16.0,425.0" style="Table3"> + <tr> + <td> + <para style="P15">Planned Date </para> + </td> + <td> + <para style="P16">:</para> + </td> + <td> + <para style="P15">[[ time.strftime('%d/%m/%Y', time.strptime(o.date_planned, '%Y-%m-%d %H:%M:%S')) ]]</para> + <para style="P9"> + <font color="white"> </font> + </para> + </td> + </tr> + </blockTable> + <para style="P12"> + <font face="Times-Roman"/> + </para> + </story> +</document> |
