Printable processus
bzr revid: fp@tinyerp.com-20080714224740-7yvfzguf5jwucnw3
This commit is contained in:
parent
b99c3e808f
commit
4871e75aec
|
@ -27,3 +27,4 @@
|
|||
##############################################################################
|
||||
|
||||
import processus
|
||||
import report
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
<?xml version="1.0" ?>
|
||||
<terp>
|
||||
<data>
|
||||
<record id="processus_processus_salesworkflow0" model="processus.processus">
|
||||
<field eval="1" name="active"/>
|
||||
<field eval=""""Sales flow for services companies."""" name="note"/>
|
||||
<field eval=""""Sales Workflow"""" name="name"/>
|
||||
</record>
|
||||
</data>
|
||||
<data>
|
||||
<record id="processus_node_quotation0" model="processus.node">
|
||||
<field name="menu_id" ref="sale.menu_action_order_tree10"/>
|
||||
<field name="processus_id" ref="processus_processus_salesworkflow0"/>
|
||||
<field eval=""""state"""" name="kind"/>
|
||||
<field eval=""""Quotation"""" name="name"/>
|
||||
<field name="model_id" ref="sale.model_sale_order"/>
|
||||
<field eval="1" name="flow_start"/>
|
||||
</record>
|
||||
</data>
|
||||
<data>
|
||||
<record id="processus_node_saleorder0" model="processus.node">
|
||||
<field name="menu_id" ref="sale.menu_action_order_tree9"/>
|
||||
<field name="processus_id" ref="processus_processus_salesworkflow0"/>
|
||||
<field eval=""""state"""" name="kind"/>
|
||||
<field eval=""""Sale Order"""" name="name"/>
|
||||
<field name="model_id" ref="sale.model_sale_order"/>
|
||||
<field eval="0" name="flow_start"/>
|
||||
</record>
|
||||
</data>
|
||||
<data>
|
||||
<record id="processus_node_packinglist0" model="processus.node">
|
||||
<field name="menu_id" ref="stock.menu_picking_waiting"/>
|
||||
<field name="processus_id" ref="processus_processus_salesworkflow0"/>
|
||||
<field eval=""""state"""" name="kind"/>
|
||||
<field eval=""""Packing List"""" name="name"/>
|
||||
<field name="model_id" ref="stock.model_stock_picking"/>
|
||||
<field eval="0" name="flow_start"/>
|
||||
</record>
|
||||
</data>
|
||||
<data>
|
||||
<record id="processus_node_deliveryorder0" model="processus.node">
|
||||
<field name="menu_id" ref="stock.menu_picking_waiting_delivery"/>
|
||||
<field name="processus_id" ref="processus_processus_salesworkflow0"/>
|
||||
<field eval=""""state"""" name="kind"/>
|
||||
<field eval=""""Delivery Order"""" name="name"/>
|
||||
<field name="model_id" ref="stock.model_stock_picking"/>
|
||||
<field eval="0" name="flow_start"/>
|
||||
</record>
|
||||
</data>
|
||||
<data>
|
||||
<record id="processus_node_invoice0" model="processus.node">
|
||||
<field name="menu_id" ref="account.menu_invoice_draft"/>
|
||||
<field name="processus_id" ref="processus_processus_salesworkflow0"/>
|
||||
<field eval=""""state"""" name="kind"/>
|
||||
<field eval=""""Invoice"""" name="name"/>
|
||||
<field name="model_id" ref="account.model_account_invoice"/>
|
||||
<field eval="0" name="flow_start"/>
|
||||
</record>
|
||||
</data>
|
||||
<data>
|
||||
<record id="processus_transition_confirmquotation0" model="processus.transition">
|
||||
<field eval="[(6,0,[])]" name="transition_ids"/>
|
||||
<field eval=""""Confirm Quotation"""" name="name"/>
|
||||
<field name="node_from_id" ref="processus_node_quotation0"/>
|
||||
<field name="node_to_id" ref="processus_node_saleorder0"/>
|
||||
</record>
|
||||
</data>
|
||||
<data>
|
||||
<record id="processus_transition_packing0" model="processus.transition">
|
||||
<field eval="[(6,0,[])]" name="transition_ids"/>
|
||||
<field eval=""""Packing"""" name="name"/>
|
||||
<field name="node_from_id" ref="processus_node_saleorder0"/>
|
||||
<field name="node_to_id" ref="processus_node_packinglist0"/>
|
||||
</record>
|
||||
</data>
|
||||
<data>
|
||||
<record id="processus_transition_deliver0" model="processus.transition">
|
||||
<field eval="[(6,0,[])]" name="transition_ids"/>
|
||||
<field eval=""""Deliver"""" name="name"/>
|
||||
<field name="node_from_id" ref="processus_node_packinglist0"/>
|
||||
<field name="node_to_id" ref="processus_node_deliveryorder0"/>
|
||||
</record>
|
||||
</data>
|
||||
<data>
|
||||
<record id="processus_transition_invoice0" model="processus.transition">
|
||||
<field eval="[(6,0,[])]" name="transition_ids"/>
|
||||
<field eval=""""Invoice"""" name="name"/>
|
||||
<field name="node_from_id" ref="processus_node_saleorder0"/>
|
||||
<field name="node_to_id" ref="processus_node_invoice0"/>
|
||||
</record>
|
||||
</data>
|
||||
</terp>
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<terp>
|
||||
<data>
|
||||
<report id="report_processus"
|
||||
model="processus.processus"
|
||||
name="processus.processus.print"
|
||||
string="Print Processus"/>
|
||||
</data>
|
||||
</terp>
|
||||
|
|
@ -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
|
|
@ -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)<abs(start[0]-x2)+abs(y2-start[1]):
|
||||
return (x1,y1)
|
||||
return (x2,y2)
|
||||
|
||||
def intersect(self, start, stop):
|
||||
s = self.intersect_one(start,stop)
|
||||
s2 = self.intersect_one(stop,start)
|
||||
return s+s2
|
||||
|
||||
def node(self, x, y, data, start_color=BGCOLOR):
|
||||
self.draw.node(x,y,BOXSIZE[0], BOXSIZE[1], data.get('title','Unknown'), start_color)
|
||||
self.draw.picture(x+35, y+BOXSIZE[1]-5, 'gtk-open.png')
|
||||
self.draw.picture(x+65, y+BOXSIZE[1]-5, 'gtk-print.png')
|
||||
self.draw.picture(x+95, y+BOXSIZE[1]-5, 'gtk-help.png')
|
||||
y = y+25
|
||||
menus = data.get('menu','').split('/')
|
||||
while menus:
|
||||
menu = menus.pop(0)
|
||||
if menu:
|
||||
if menus: menu=menu+' /'
|
||||
self.draw.draw_text(x+23, y, 10, menu, color=(0,0,0), maxlength=BOXSIZE[0] - 25, font_name='ds.ttf')
|
||||
y+=15
|
||||
|
||||
def arrow_role(self, node_from, node_to, role='Hello'):
|
||||
start = (node_from[0]+BOXSIZE[0]/2, node_from[1]+BOXSIZE[1]/2)
|
||||
stop = (node_to[0]+BOXSIZE[0]/2, node_to[1]+BOXSIZE[1]/2)
|
||||
(x,y) = self.draw.arrow_role(start, stop, role)
|
||||
self.draw.picture(x, y-7, 'role.png')
|
||||
self.draw.draw_text(x,y-7, 15, 'Salesman', color=(0,0,0), center=True)
|
||||
|
||||
def arrow(self, node_from, node_to):
|
||||
start = (node_from[0]+BOXSIZE[0]/2, node_from[1]+BOXSIZE[1]/2)
|
||||
stop = (node_to[0]+BOXSIZE[0]/2, node_to[1]+BOXSIZE[1]/2)
|
||||
arrow = self.intersect(start,stop)
|
||||
self.draw.arrow(arrow)
|
||||
|
||||
g = graph(img)
|
||||
g.node(50,100,{'title':'SALE AZER ORDER', 'menu':'Sales Management/Sales Orders/My Sales Order/My Open Sales Order'}, start_color=(200,100,100))
|
||||
g.node(350,150,{'title':'SALE AZER AZE ORDER', 'menu':'Sales Management/Sales Orders/My Quotations'})
|
||||
g.arrow((50,100),(350,150))
|
||||
|
||||
g.arrow_role((50,100),(350,150))
|
||||
|
||||
img.show()
|
|
@ -0,0 +1,165 @@
|
|||
import Image
|
||||
import ImageDraw
|
||||
import ImageFont
|
||||
import math
|
||||
|
||||
ROUNDED = 30
|
||||
BGCOLOR = (228,233,237)
|
||||
TITLECOLOR = (150,70,70)
|
||||
FONT = 'addons/processus/report/sb.ttf'
|
||||
BOXSIZE = (160,120)
|
||||
|
||||
size = 800,600
|
||||
|
||||
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 = 180
|
||||
else:
|
||||
angle = math.atan(-(arrow[2]-arrow[0]) / (arrow[1]-arrow[3])) * 180 / math.pi
|
||||
angle = 270 - angle
|
||||
if arrow[3]<arrow[1]:
|
||||
angle = 180 + 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
|
||||
if not start[0]-stop[0]:
|
||||
y1 = 99999999999999
|
||||
else:
|
||||
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
|
||||
if not start[1]-stop[1]:
|
||||
x2 = 99999999999999
|
||||
else:
|
||||
x2 = start[0] - (start[0] - stop[0]) * (start[1]-y2) / (start[1] - stop[1])
|
||||
|
||||
if abs(start[0]-x1)+abs(start[1]-y1)<abs(start[0]-x2)+abs(y2-start[1]):
|
||||
return (x1,y1)
|
||||
return (x2,y2)
|
||||
|
||||
def intersect(self, start, stop):
|
||||
s = self.intersect_one(start,stop)
|
||||
s2 = self.intersect_one(stop,start)
|
||||
return s+s2
|
||||
|
||||
def node(self, x, y, data, start_color=False):
|
||||
self.draw.node(x,y,BOXSIZE[0], BOXSIZE[1], data.get('title','Unknown'), start_color and (255,125,125) or BGCOLOR)
|
||||
self.draw.picture(x+35, y+BOXSIZE[1]-5, 'addons/processus/report/gtk-help.png')
|
||||
if start_color:
|
||||
self.draw.picture(x+65, y+BOXSIZE[1]-5, 'addons/processus/report/gtk-open.png')
|
||||
self.draw.picture(x+95, y+BOXSIZE[1]-5, 'addons/processus/report/gtk-print.png')
|
||||
y = y+25
|
||||
menus = data.get('menu','').split('/')
|
||||
while menus:
|
||||
menu = menus.pop(0)
|
||||
if menu:
|
||||
if menus: menu=menu+' /'
|
||||
self.draw.draw_text(x+23, y, 10, menu, color=(0,0,0), maxlength=BOXSIZE[0] - 25, font_name='addons/processus/report/ds.ttf')
|
||||
y+=15
|
||||
|
||||
def arrow_role(self, node_from, node_to, role='Hello'):
|
||||
start = (node_from[0]+BOXSIZE[0]/2, node_from[1]+BOXSIZE[1]/2)
|
||||
stop = (node_to[0]+BOXSIZE[0]/2, node_to[1]+BOXSIZE[1]/2)
|
||||
(x,y) = self.draw.arrow_role(start, stop, role)
|
||||
self.draw.picture(x, y-3, 'addons/processus/report/role.png')
|
||||
self.draw.draw_text(x,y-3, 12, 'Salesman', color=(0,0,0), center=True)
|
||||
|
||||
def arrow(self, node_from, node_to):
|
||||
start = (node_from[0]+BOXSIZE[0]/2, node_from[1]+BOXSIZE[1]/2)
|
||||
stop = (node_to[0]+BOXSIZE[0]/2, node_to[1]+BOXSIZE[1]/2)
|
||||
arrow = self.intersect(start,stop)
|
||||
self.draw.arrow(arrow)
|
||||
|
||||
if __name__=='__main__':
|
||||
img = Image.new('RGB',size,'#ffffff')
|
||||
g = graph(img)
|
||||
g.node(50,100,{'title':'SALE AZER ORDER', 'menu':'Sales Management/Sales Orders/My Sales Order/My Open Sales Order'}, start_color=(200,100,100))
|
||||
g.node(350,150,{'title':'SALE AZER AZE ORDER', 'menu':'Sales Management/Sales Orders/My Quotations'})
|
||||
g.arrow((50,100),(350,150))
|
||||
|
||||
g.arrow_role((50,100),(350,150))
|
||||
|
||||
#img.show()
|
||||
img.save('a.pdf')
|
|
@ -0,0 +1,102 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# $Id: print_instance.py 8595 2008-06-16 13:00:21Z stw $
|
||||
#
|
||||
# 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, os
|
||||
|
||||
import netsvc
|
||||
import report,pooler,tools
|
||||
|
||||
import processus_print
|
||||
import Image
|
||||
|
||||
|
||||
class report_graph_instance(object):
|
||||
def __init__(self, cr, uid, ids, data):
|
||||
current_object = 'sale.order'
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
for processus in pool.get('processus.processus').browse(cr, uid, ids):
|
||||
nodes = {}
|
||||
start = []
|
||||
transitions = {}
|
||||
for node in processus.node_ids:
|
||||
print node.id, node.name, node.flow_start
|
||||
nodes[node.id] = node
|
||||
if node.flow_start:
|
||||
start.append(node.id)
|
||||
for tr in node.transition_out:
|
||||
transitions[tr.id] = tr
|
||||
g = tools.graph(nodes.keys(), map(lambda x: (x.node_from_id.id,x.node_to_id.id), transitions.values()))
|
||||
g.process(start)
|
||||
g.scale(200,250, 100, 10)
|
||||
|
||||
img = Image.new('RGB',(1024,768),'#ffffff')
|
||||
g2 = processus_print.graph(img)
|
||||
positions = g.result
|
||||
for name,node in positions.items():
|
||||
start_color = (nodes[name].model_id.model==current_object)
|
||||
g2.node(node['y'],node['x'], {
|
||||
'title': nodes[name].name,
|
||||
'menu': nodes[name].menu_id.complete_name
|
||||
}, start_color=start_color)
|
||||
for name,transition in transitions.items():
|
||||
if transition.transition_ids:
|
||||
g2.arrow_role((positions[transition.node_from_id.id]['y'], positions[transition.node_from_id.id]['x']),
|
||||
(positions[transition.node_to_id.id]['y'], positions[transition.node_to_id.id]['x']))
|
||||
g2.arrow((positions[transition.node_from_id.id]['y'], positions[transition.node_from_id.id]['x']),
|
||||
(positions[transition.node_to_id.id]['y'], positions[transition.node_to_id.id]['x']))
|
||||
img.save('/tmp/a.pdf')
|
||||
self.result = file('/tmp/a.pdf').read()
|
||||
self.done = True
|
||||
|
||||
def is_done(self):
|
||||
return self.done
|
||||
|
||||
def get(self):
|
||||
if self.done:
|
||||
return self.result
|
||||
else:
|
||||
return None
|
||||
|
||||
class report_graph(report.interface.report_int):
|
||||
def __init__(self, name, table):
|
||||
report.interface.report_int.__init__(self, name)
|
||||
self.table = table
|
||||
|
||||
def result(self):
|
||||
if self.obj.is_done():
|
||||
return (True, self.obj.get(), 'pdf')
|
||||
else:
|
||||
return (False, False, False)
|
||||
|
||||
def create(self, cr, uid, ids, data, context={}):
|
||||
self.obj = report_graph_instance(cr, uid, ids, data)
|
||||
return (self.obj.get(), 'pdf')
|
||||
|
||||
report_graph('report.processus.processus.print', 'processus.processus')
|
|
@ -33,7 +33,7 @@
|
|||
"depends" : ["product", "stock", "mrp"],
|
||||
"category" : "Generic Modules/Sales & Purchases",
|
||||
"init_xml" : [],
|
||||
"demo_xml" : ["sale_demo.xml", "sale_unit_test.xml"],
|
||||
"demo_xml" : ["sale_demo.xml"],
|
||||
"description": """
|
||||
The base module to manage quotations and sales orders.
|
||||
|
||||
|
|
Loading…
Reference in New Issue