[IMP] improve document change

bzr revid: fp@tinyerp.com-20100127003318-1oqkk4f8cyd685kg
This commit is contained in:
Fabien Pinckaers 2010-01-27 01:33:18 +01:00
parent a132f2a625
commit e6d46870fd
7 changed files with 61 additions and 24 deletions

View File

@ -104,7 +104,7 @@ class document_directory(osv.osv):
for d in self.browse(cr, uid, ids, context=context):
s = ''
d2 = d
while d2:
while d2 and d2.parent_id:
s = d2.name + (s and ('/' + s) or '')
d2 = d2.parent_id
res.append((d.id, s))

View File

@ -145,6 +145,7 @@
<field name="name">Directorie's Structure</field>
<field name="res_model">document.directory</field>
<field name="view_type">tree</field>
<field name="view_id" ref="view_document_directory_tree"/>
<field name="domain">[('ressource_parent_type_id','=',False),('parent_id','=',False)]</field>
</record>
<menuitem
@ -245,7 +246,7 @@
<field name="type">ir.actions.act_window</field>
<field name="res_model">ir.attachment</field>
<field name="view_type">form</field>
<field name="domain">[('parent_id','=',active_id)]</field>
<field name="domain">[('parent_id','child_of',active_id)]</field>
<field name="context">{'parent_id':'active_id'}</field>
</record>
@ -295,10 +296,10 @@
</field>
</record>
<act_window domain="[('partner_id', '=', active_id)]"
id="act_res_partner_document" name="Related Documents"
res_model="ir.attachment"
src_model="res.partner"/>
<act_window domain="[('partner_id', '=', active_id)]"
id="act_res_partner_document" name="Related Documents"
res_model="ir.attachment"
src_model="res.partner"/>
</data>
</openerp>

View File

@ -20,6 +20,6 @@
##############################################################################
import document_change
import document_change_report
import document_change_mailgate
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -28,7 +28,7 @@
The document_change module allows to track and manage process changes to
update documents in directories, and keep track of these updates. You
can define control points, phase of changes. This module has been
developed for Caterpilar Belgium.
developed for Caterpillar Belgium.
""",
'author': 'Tiny',
'website': 'http://www.openerp.com',
@ -39,6 +39,7 @@ developed for Caterpilar Belgium.
'document_change_view.xml',
'document_change_sequence.xml',
'document_change_workflow.xml',
'document_change_report_view.xml',
'document_phase_workflow.xml',
'document_process_workflow.xml',
'cat_demo.xml'

View File

@ -27,6 +27,23 @@ from tools.translate import _
import time
import datetime
class document_directory(osv.osv):
_inherit = 'document.directory'
def _level_compute(self, cr, uid, ids, field_name, arg, context):
result = {}
for d in self.browse(cr, uid, ids, context=context):
result[d.id] = 0
d2 = d
while d2:
d2 = d2.parent_id
result[d.id] += 1
return result
_columns = {
'level': fields.function(_level_compute, method=True,
string='level', type='integer', store=True),
}
document_directory()
class document_change_process_phase_type(osv.osv):
_name = "document.change.process.phase.type"
document_change_process_phase_type()
@ -64,7 +81,7 @@ class document_change_process_phase(osv.osv):
_name = "document.change.process.phase"
_description = "Process Phase"
_columns = {
'name': fields.char("Name", size=64, required=True),
'name': fields.char("Phase Name", size=64, required=True),
'process_id':fields.many2one('document.change.process','Process Change'),
'sequence': fields.integer('Sequence'),
'update_document': fields.selection([('at_endPhase', 'End Phase'),('at_endprocess', 'End Process')], 'Update Document', required=True),
@ -188,7 +205,7 @@ class document_change_process(osv.osv):
'create_date':fields.datetime('Creation',readonly=True),
'latest_modified_date':fields.function(_latestmodification, method=True, type='datetime', string="Lastest Modification"), #TODO no year!
'date_expected':fields.datetime('Expected Production'),
'state':fields.selection([('draft', 'Draft'),('in_progress', 'In Progress'),('to_validate', 'To Validate'), ('pending', 'Pending'), ('done', 'Done'),('cancel','Cancelled')], 'state', readonly=True),
'state':fields.selection([('draft', 'Draft'),('in_progress', 'In Progress'),('to_validate', 'To Validate'), ('pending', 'Pending'), ('done', 'Done'),('cancel','Cancelled')], 'State', readonly=True),
'process_phase_ids':fields.one2many('document.change.process.phase','process_id','Phase'),
'current_phase_id': fields.function(_get_current_phase, method=True, type='many2one', relation='document.change.process.phase', string='Current Phase'),
'date_control': fields.related('current_phase_id','date_control', type='date', string='Control Date'),
@ -250,10 +267,10 @@ document_change_process()
class document_file(osv.osv):
_inherit = 'ir.attachment'
_columns = {
'change_type_id':fields.many2one('document.change.type','Document Type'),
'state': fields.selection([('in_production', 'In Production'), ('change_request', 'Change Requested'),('change_propose', 'Change Proposed'), ('to_update', 'To Update'), ('cancel', 'Cancel')], 'State'),
'state': fields.selection([('draft','To Create'),('in_production', 'In Production'), ('change_request', 'Change Requested'),('change_propose', 'Change Proposed'), ('to_update', 'To Update'), ('cancel', 'Cancel')], 'State'),
'style': fields.selection([('run','Run'),('setup','Setup'),('pma','PMA'),('pmp','PMP')],'Document Style'),
'target_document_id': fields.many2one('ir.attachment', 'Target Document'),
'target':fields.binary('Target'),
'process_phase_id' :fields.many2one('document.change.process.phase','Process Phase'),
@ -262,7 +279,7 @@ class document_file(osv.osv):
}
_defaults = {
'state': lambda *a: 'in_production',
}
}
def _check_duplication(self, cr, uid, vals, ids=[], op='create'):
name=vals.get('name',False)
@ -317,9 +334,19 @@ class document_file(osv.osv):
return True
def do_production(self, cr, uid, ids, context={}):
self.write(cr, uid, ids, {'state':'in_production'},context=context)
return self.write(cr, uid, ids, {'state':'in_production'},context=context)
def write(self, cr, uid, ids, data, context={}):
for d in self.browse(cr, uid, ids, context=context):
if d.state=='draft' and d.datas:
super(document_file,self).write(cr,uid,[d.id],
{'state':'in_production'},context=context)
result = super(document_file,self).write(cr,uid,ids,data,context=context)
return True
def do_draft(self, cr, uid, ids, context={}):
return self.write(cr, uid, ids, {'state':'draft'},context=context)
def do_cancel(self, cr, uid, ids, context={}):
return self.write(cr, uid, ids, {'state':'cancel'},context=context)

View File

@ -4,15 +4,15 @@
<!-- Structure Data -->
<record model="document.directory" id="dir_root">
<field name="name">Gosselies</field>
<field name="name">Bat E</field>
<field name="parent_id" eval="False"/>
</record>
<record model="document.directory" id="dir_bat_e">
<field name="name">Bat E</field>
<field name="name">Commodity A</field>
<field name="parent_id" ref="dir_root"/>
</record>
<record model="document.directory" id="dir_bat_z">
<field name="name">Bat Z</field>
<field name="name">Commodity B</field>
<field name="parent_id" ref="dir_root"/>
</record>
@ -95,7 +95,7 @@
<field name="datas_fname">TaktTime_template.xls</field>
<field name="parent_id" ref="dir_template"/>
</record>
<!-- Document Change Types -->
<record model="document.change.type" id="type_project_charter">
<field name="name">Project Charter</field>

View File

@ -245,6 +245,7 @@
<field name="datas" filename="datas_fname" string="Content"/>
<field name="change_type_id" widget="selection"/>
<field name="datas_fname"/>
<field name="style"/>
<notebook colspan="4">
<page string="Information">
<group colspan="2" col="2">
@ -302,6 +303,7 @@
<field name="name" string="Document"/>
<field name="parent_id" string="Directory"/>
<field name="change_type_id"/>
<field name="style"/>
<field name="state"/>
<field name="change_process_id"/>
<field name="user_id" string="Owner"/>
@ -492,7 +494,8 @@
<field name="process_type_id" widget="selection"/>
<field name="name" readonly="1"/>
<newline/>
<field name="structure_id" colspan="4"/>
<!-- Big Hack For Demo Purpose Caterpillar -->
<field name="structure_id" colspan="4" domain="[('name','ilike','fam')]"/>
<field name="process_model_id" widget="selection"/>
<button name="generate_phases"
string="Generate Phases" type="object"
@ -552,15 +555,15 @@
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Process Change">
<field name="structure_id"/>
<field name="name"/>
<field name="description"/>
<field name="structure_id"/>
<field name="user_id"/>
<field name="current_phase_id"/>
<field name="date_control"/>
<field name="process_model_id"/>
<field name="progress"/>
<field name="progress" widget="progressbar"/>
<field name="process_document_ids" string="# Documents"/>
<field name="state"/>
</tree>
</field>
</record>
@ -585,12 +588,16 @@
<group col="14" colspan="4">
<filter domain="[('user_id','=',uid)]" string="My Process" icon="gtk-execute" help="My Process Changes"/>
<separator orientation="vertical"/>
<filter domain="[('state','in',('in_progress','draft','to_validate'))]"
string="In Progress" icon="gtk-execute"
default="1"
help="Process changes having the next Phase to validate that is late"/>
<filter domain="[('state','=','to_validate')]"
string="To Validate"
icon="gtk-apply"
help="Process Changes to be validated"/>
<filter domain="[('state','=','in_progress')]"
string="Late" icon="gtk-execute"
<filter domain="[('state','=','pending')]"
string="Pending" icon="gtk-execute"
help="Process changes having the next Phase to validate that is late"/>
<separator orientation="vertical"/>
@ -602,6 +609,7 @@
<group expand="1" string="Group By..." col="20" colspan="4">
<filter domain="[]" string="By Owner" icon="terp-hr" context="{'group_by':'user_id'}" help="Process Changes by owner"/>
<filter domain="[]" string="By Directory" icon="terp-hr" context="{'group_by':'structure_id'}" help="Process Changes by directory"/>
<filter domain="[]" string="By State" icon="terp-hr" context="{'group_by':'state'}" help="Process Changes by directory"/>
</group>
</search>
</field>