From 4871e75aec62678e76ed8c68bebede201e0cf857 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 15 Jul 2008 00:47:40 +0200 Subject: [PATCH] Printable processus bzr revid: fp@tinyerp.com-20080714224740-7yvfzguf5jwucnw3 --- addons/processus/__init__.py | 1 + addons/processus/__terp__.py | 3 +- addons/processus/processus.py | 4 +- addons/processus/processus_data.xml | 92 +++++++++++ addons/processus/processus_report.xml | 10 ++ addons/processus/report/__init__.py | 28 ++++ addons/processus/report/img.py | 154 ------------------ addons/processus/report/processus_print.py | 165 ++++++++++++++++++++ addons/processus/report/report_processus.py | 102 ++++++++++++ addons/sale/__terp__.py | 2 +- 10 files changed, 403 insertions(+), 158 deletions(-) create mode 100644 addons/processus/processus_data.xml create mode 100644 addons/processus/processus_report.xml create mode 100644 addons/processus/report/__init__.py delete mode 100644 addons/processus/report/img.py create mode 100644 addons/processus/report/processus_print.py create mode 100644 addons/processus/report/report_processus.py diff --git a/addons/processus/__init__.py b/addons/processus/__init__.py index 4a83fecd890..c7dc7e8e91e 100644 --- a/addons/processus/__init__.py +++ b/addons/processus/__init__.py @@ -27,3 +27,4 @@ ############################################################################## import processus +import report diff --git a/addons/processus/__terp__.py b/addons/processus/__terp__.py index d30ff08d2c0..2c526f4fdad 100644 --- a/addons/processus/__terp__.py +++ b/addons/processus/__terp__.py @@ -12,7 +12,8 @@ This module allows you to manage your processus for the end-users. "demo_xml" : [], "update_xml" : [ 'processus_view.xml', - 'ir.model.access.csv'], + 'ir.model.access.csv', + "processus_report.xml"], "active": False, "installable": True } diff --git a/addons/processus/processus.py b/addons/processus/processus.py index e736c8c1c2c..77c7b4d0191 100644 --- a/addons/processus/processus.py +++ b/addons/processus/processus.py @@ -55,8 +55,8 @@ class processus_node(osv.osv): 'model_id': fields.many2one('ir.model', 'Model', ondelete='set null'), 'model_states': fields.char('States Expression', size=128), 'flow_start': fields.boolean('Starting Flow'), - 'transition_in': fields.one2many('processus.transition', 'node_from_id', 'Starting Transitions'), - 'transition_out': fields.one2many('processus.transition', 'node_to_id', 'Ending Transitions'), + 'transition_in': fields.one2many('processus.transition', 'node_to_id', 'Starting Transitions'), + 'transition_out': fields.one2many('processus.transition', 'node_from_id', 'Ending Transitions'), } _defaults = { 'kind': lambda *args: 'state', diff --git a/addons/processus/processus_data.xml b/addons/processus/processus_data.xml new file mode 100644 index 00000000000..42e26231de6 --- /dev/null +++ b/addons/processus/processus_data.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/addons/processus/processus_report.xml b/addons/processus/processus_report.xml new file mode 100644 index 00000000000..99e75456b2e --- /dev/null +++ b/addons/processus/processus_report.xml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/addons/processus/report/__init__.py b/addons/processus/report/__init__.py new file mode 100644 index 00000000000..6c1fc00e187 --- /dev/null +++ b/addons/processus/report/__init__.py @@ -0,0 +1,28 @@ +############################################################################## +# +# Copyright (c) 2005-TODAY 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 report_processus diff --git a/addons/processus/report/img.py b/addons/processus/report/img.py deleted file mode 100644 index eec3e10263e..00000000000 --- a/addons/processus/report/img.py +++ /dev/null @@ -1,154 +0,0 @@ -import Image -import ImageDraw -import ImageFont -import math - -ROUNDED = 30 -BGCOLOR = (228,233,237) -TITLECOLOR = (150,70,70) -FONT = 'sb.ttf' -BOXSIZE = (160,120) - -size = 800,600 -img = Image.new('RGB',size,'#ffffff') - -class draw(object): - def _rounding_box(self, x, y, width, height, title=None, bgcolor=BGCOLOR): - d = ImageDraw.Draw(self.img) - DR = ROUNDED/2 - d.polygon( (x+DR,y,x+width-DR,y,x+width,y+DR,x+width,y+height-DR,x+width-DR,y+height,x+DR,y+height,x,y+height-DR,x,y+DR), fill=bgcolor) - d.pieslice((x,y,x+ROUNDED,y+ROUNDED),180,270,fill=bgcolor) - d.pieslice((x+width-ROUNDED,y,x+width,y+ROUNDED),270,0,fill=title and TITLECOLOR or bgcolor) - d.pieslice((x+width-ROUNDED,y+height-ROUNDED,x+width,y+height),0,90,fill=bgcolor) - d.pieslice((x,y+height-ROUNDED,x+ROUNDED,y+height),90,180,fill=bgcolor) - if title: - d.polygon( (x+width/5, y, x+width-DR, y, x+width, y+DR, x+width, y+20, x+width/5+15, y+20), fill=TITLECOLOR) - self.draw_text(x+width/5+13, y+4, 10, title, (255,255,255), width*4/5-14) - - def node(self, x, y, width, height, title=None, start_color=BGCOLOR): - self._rounding_box(x,y,BOXSIZE[0]-16,BOXSIZE[1], bgcolor=start_color) - self._rounding_box(x+12,y,BOXSIZE[0]-16,BOXSIZE[1], bgcolor=(255,255,255)) - self._rounding_box(x+16,y,BOXSIZE[0]-16,BOXSIZE[1], title) - - def angle(self, arrow): - if not arrow[1]-arrow[3]: - angle = 270 - else: - angle = math.atan(-(arrow[2]-arrow[0]) / (arrow[1]-arrow[3])) * 180 / math.pi - angle = 270 - angle - return int(angle) - - def arrow(self, arrow): - d = ImageDraw.Draw(self.img) - d.line(arrow, width=1, fill=(0,0,0)) - angle = self.angle(arrow) - d.pieslice((arrow[2]-14,arrow[3]-14,arrow[2]+14,arrow[3]+14),angle-18,angle+18,fill=(0,0,0)) - - def draw_text(self, x, y, size, title, color=(155,255,255), maxlength=None, font_name=FONT, center=False): - d = ImageDraw.Draw(self.img) - font = ImageFont.truetype(font_name, size) - d.setfont(font) - size2 = d.textsize(title) - if maxlength: - fontsize = min(size, size * maxlength / size2[0]) - font = ImageFont.truetype(font_name, fontsize) - d.setfont(font) - size = d.textsize(title) - if center: - x = x-size[0]/2 - d.text( (x, y+(size2[1]-size[1])/2), title, color) - - def arrow_role(self, node_from, node_to, role='Hello'): - d = ImageDraw.Draw(self.img) - x = (node_from[0] + node_to[0]) /2 - y = (node_from[1] + node_to[1]) /2 - angle = self.angle(node_from+node_to) + 105 - d.pieslice((x-40,y-40,x+40,y+40),angle-5,angle+5,fill=(100,0,0)) - d.pieslice((x-6,y-6,x+6,y+6),angle-7,angle+7,fill=(255,255,255)) - - print -180 + angle - 90 - x = x + math.cos(angle * math.pi / 180) * 40 - y = y + math.sin(angle * math.pi / 180) * 40 - a,b = x,y - angle -= 120 - - x = x + math.cos(angle * math.pi / 180) * 20 - y = y + math.sin(angle * math.pi / 180) * 20 - - d.line((a,b,x,y), width=5, fill=(100,0,0)) - angle += 125 - d.pieslice((x-30,y-30,x+30,y+30),angle-7,angle+7,fill=(100,0,0)) - - x = x + math.cos(angle * math.pi / 180) * 50 - y = y + math.sin(angle * math.pi / 180) * 50 - return (x,y) - - def picture(self, x, y, fname): - img = Image.open(fname) - img2 = img.convert('RGBA') - self.img.paste(img2, (max(0,x-img.size[0]/2), max(0,y-img.size[1])), mask=img2) - - def __init__(self, img): - self.img = img - -class graph(object): - def __init__(self, img): - self.draw = draw(img) - - def intersect_one(self, start, stop): - if start[0] < stop[0]: - x1 = start[0] + BOXSIZE[0]/2 + 3 - else: - x1 = start[0] - BOXSIZE[0]/2 - 3 - y1 = start[1] - (start[1] - stop[1]) * (start[0]-x1) / (start[0] - stop[0]) - - if start[1] < stop[1]: - y2 = start[1] + BOXSIZE[1]/2 + 3 - else: - y2 = start[1] - BOXSIZE[1]/2 - 3 - x2 = start[0] - (start[0] - stop[0]) * (start[1]-y2) / (start[1] - stop[1]) - - if abs(start[0]-x1)+abs(start[1]-y1)