From f09a07529dd2dfad1f1e1546206591cbebc963ac Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 26 Jan 2010 20:44:40 +0100 Subject: [PATCH] merge bzr revid: fp@tinyerp.com-20100126194440-qngp7q3ve058jowl --- addons/document/document_directory.py | 10 + addons/document_change/__terp__.py | 24 +- addons/document_change/cat_demo.xml | 10 + addons/document_change/document_change.py | 134 +++-- .../document_change/document_change_data.xml | 45 +- .../document_change/document_change_view.xml | 486 +++++++++--------- 6 files changed, 356 insertions(+), 353 deletions(-) create mode 100644 addons/document_change/cat_demo.xml diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index 2623c1f3852..8aa513af581 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -32,6 +32,7 @@ from tools.translate import _ class document_directory(osv.osv): _name = 'document.directory' _description = 'Document directory' + _order = 'name desc' _columns = { 'name': fields.char('Name', size=64, required=True, select=1), 'write_date': fields.datetime('Date Modified', readonly=True), @@ -98,6 +99,15 @@ class document_directory(osv.osv): ('dirname_uniq', 'unique (name,parent_id,ressource_id,ressource_parent_type_id)', 'The directory name must be unique !'), ('no_selfparent', 'check(parent_id <> id)', 'Directory cannot be parent of itself!') ] + def name_get(self, cr, uid, ids, context={}): + res = {} + for d in self.browse(cr, uid, ids, context=context): + s = d.name + while d: + s = d.name + (s and ('/' + s) or '') + d = d.parent_id + res[d] = s + return res def ol_get_resource_path(self,cr,uid,dir_id,res_model,res_id): # this method will be used in process module diff --git a/addons/document_change/__terp__.py b/addons/document_change/__terp__.py index 3e6107367f8..bb2c24d89e0 100644 --- a/addons/document_change/__terp__.py +++ b/addons/document_change/__terp__.py @@ -24,22 +24,24 @@ 'name': 'Integrated Document Management System', 'version': '1.99', 'category': 'Generic Modules/Others', - 'description': """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. + 'description': """ +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. """, 'author': 'Tiny', 'website': 'http://www.openerp.com', 'depends': ['base', 'document_ftp','mail_gateway'], 'init_xml': ['document_change_data.xml'], - 'update_xml': [ - 'security/document_process_security.xml', - 'document_change_view.xml', - 'document_change_sequence.xml', - 'document_change_workflow.xml', - 'document_phase_workflow.xml', - 'document_process_workflow.xml', - + 'update_xml': [ + 'security/document_process_security.xml', + 'document_change_view.xml', + 'document_change_sequence.xml', + 'document_change_workflow.xml', + 'document_phase_workflow.xml', + 'document_process_workflow.xml', + 'cat_demo.xml' ], 'demo_xml': [ ], 'installable': True, diff --git a/addons/document_change/cat_demo.xml b/addons/document_change/cat_demo.xml new file mode 100644 index 00000000000..ea582680e03 --- /dev/null +++ b/addons/document_change/cat_demo.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/addons/document_change/document_change.py b/addons/document_change/document_change.py index 8be097bed4f..5b49c3d85d7 100644 --- a/addons/document_change/document_change.py +++ b/addons/document_change/document_change.py @@ -26,6 +26,7 @@ import netsvc from tools.translate import _ import time import datetime + class doucment_change_process_phase_type(osv.osv): _name = "document.change.process.phase.type" doucment_change_process_phase_type() @@ -33,11 +34,10 @@ doucment_change_process_phase_type() class document_change_type(osv.osv): _name = "document.change.type" _description = "Document Change Type" - _columns = { 'name': fields.char("Document Change Type", size=64,required=True), 'phase_type_ids': fields.many2many('document.change.process.phase.type','document_type_phase_type_rel','document_type_id','phase_type_id','Phase Type'), - 'directory_id' :fields.many2one('document.directory','Pending Directory'), + 'directory_id' :fields.many2one('document.directory','Pending Directory'), 'template_document_id':fields.many2one('ir.attachment','Document') } document_change_type() @@ -45,38 +45,36 @@ document_change_type() class doucment_change_process_phase_type(osv.osv): _name = "document.change.process.phase.type" _description = "Document Change Process Phase Type" - _columns = { 'name': fields.char("Document Changed Process Type", size=64), 'sequence': fields.integer('Sequence'), 'active': fields.boolean('Active'), 'document_type_ids': fields.many2many('document.change.type','document_type_phase_type_rel','phase_type_id','document_type_id','Document Type'), } - _defaults = { - 'active': lambda *a:1, + _defaults = { + 'active': lambda *a:1, } doucment_change_process_phase_type() -class doucment_change_process(osv.osv): +class doucment_change_process(osv.osv): _name = "document.change.process" doucment_change_process() class doucment_change_process_phase(osv.osv): _name = "document.change.process.phase" _description = "Document Change Process Phase" - _columns = { 'name': fields.char("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), + 'update_document': fields.selection([('at_endPhase', 'End Phase'),('at_endprocess', 'End Process')], 'Update Document', required=True), 'type': fields.selection([('control_required', 'Control Required'),('no_control', 'No Control')], 'Type'), - 'date_control': fields.date('Control Date', select=True), + 'date_control': fields.date('Control Date', select=True), 'phase_type_id':fields.many2one('document.change.process.phase.type','Phase Type'), 'state': fields.selection([('draft', 'Draft'),('in_process', 'Started'),('to_validate', 'To Validate'),('done', 'Done')], 'State',readonly=True), 'phase_document_ids':fields.one2many('ir.attachment','process_phase_id','Documents'), } - _defaults = { + _defaults = { 'state': lambda *a: 'draft', 'update_document': lambda *a:'at_endPhase', 'type':lambda *a: 'no_control', @@ -91,11 +89,11 @@ class doucment_change_process_phase(osv.osv): def do_start(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state':'in_process'}) - return True + return True def do_done(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state':'done'}) - return True + return True def test_control_request(self, cr, uid, ids, context=None): return all(bool(process.type) =='control_required' for process in self.browse(cr, uid, ids, context=context)) @@ -107,7 +105,7 @@ doucment_change_process_phase() class document_change_process_model(osv.osv): _name = "document.change.process.model" _description = "Document Change Process model" - + _columns = { 'name': fields.char("Changed Process Model", size=64,required=True), 'sequence': fields.integer('Sequence'), @@ -117,8 +115,8 @@ document_change_process_model() class document_change_process_type(osv.osv): _name = "document.change.process.type" - _description = "Document Change Process Type" - + _description = "Document Change Process Type" + _columns = { 'name': fields.char("Changed Process Type", size=64), } @@ -126,20 +124,20 @@ document_change_process_type() class document_change_process_email(osv.osv): _name = "document.change.process.mail" - _description = "Document Change Process Email Notification" - + _description = "Document Change Process Email Notification" + _columns = { 'name': fields.char("Email", size=64), 'type':fields.selection([('start_end', 'Start/End Process '),('change_all', 'Change in All Document')], 'Notification Type'), - 'process_id':fields.many2one('document.change.process','Process Change'), + 'process_id':fields.many2one('document.change.process','Process Change'), } document_change_process_email() class doucment_change_process(osv.osv): - + _name = "document.change.process" _description = "Document Change Process" - + def _latestmodification(self, cr, uid, ids, field_name, arg, context={}): res = {} #TODOto calculate latest modified date from all related documents @@ -148,16 +146,16 @@ class doucment_change_process(osv.osv): if not ids: return {} res = {} - attach = self.pool.get('ir.attachment') - directory_obj = self.pool.get('document.directory') + attach = self.pool.get('ir.attachment') + directory_obj = self.pool.get('document.directory') for process_change in self.browse(cr, uid, ids): - res1 = [] + res1 = [] for phase_id in process_change.process_phase_ids: - res1 += map(lambda x:x.id, phase_id.phase_document_ids or []) - res[process_change.id] = res1 + res1 += map(lambda x:x.id, phase_id.phase_document_ids or []) + res[process_change.id] = res1 return res - + def _get_progress(self, cr, uid, ids, field_name, arg, context={}): result = {} progress = 0.0 @@ -170,7 +168,7 @@ class doucment_change_process(osv.osv): progress = (float(len(update_docs))/float(len(proc_change.process_document_ids)))*100 result[proc_change.id] = progress return result - + def _get_current_phase(self, cr, uid, ids, field_name, arg, context={}): result = {} for proc in self.browse(cr, uid, ids): @@ -178,8 +176,8 @@ class doucment_change_process(osv.osv): for phase in proc.process_phase_ids: if phase.state in ('in_process','to_validate'): result[proc.id] = phase.id - return result - + return result + _columns = { 'name': fields.char("Process Change", size=64, required=True, select=True), 'process_type_id' :fields.many2one('document.change.process.type','Type Change'), @@ -190,43 +188,43 @@ class doucment_change_process(osv.osv): 'user_id':fields.many2one('res.users','Change Owner'), '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'), + '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), - 'process_phase_ids':fields.one2many('document.change.process.phase','process_id','Phase'), + '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'), + 'date_control': fields.related('current_phase_id','date_control', type='date', string='Control Date'), 'progress': fields.function(_get_progress, method=True, type='float', string='Progress'), 'process_document_ids': fields.many2many('ir.attachment','document_changed_process_rel','process_id','change_id','Document To Change'), 'pending_directory_id' :fields.many2one('document.directory','Pending Directory'), } - _defaults = { + _defaults = { 'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'document.change.process'), 'state': lambda *a: 'draft', } def do_start(self, cr, uid, ids, context={}): - self.write(cr, uid, ids, {'state':'in_progress'},context=context) + self.write(cr, uid, ids, {'state':'in_progress'},context=context) return True def do_pending(self, cr, uid, ids, context={}): - self.write(cr, uid, ids, {'state':'pending'},context=context) - return True - + self.write(cr, uid, ids, {'state':'pending'},context=context) + return True + def do_confirm(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state':'to_validate'},context=context) - return True + return True def do_done(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state':'done'},context=context) - return True - + return True + def do_cancel(self, cr, uid, ids, context={}): - return self.write(cr, uid, ids, {'state':'cancel'},context=context) + return self.write(cr, uid, ids, {'state':'cancel'},context=context) def generate_phases(self, cr, uid, ids, *args): phase_obj = self.pool.get('document.change.process.phase') - directory_obj = self.pool.get('document.directory') + directory_obj = self.pool.get('document.directory') document_obj = self.pool.get('ir.attachment') - new_doc_ids = [] + new_doc_ids = [] for process in self.browse(cr, uid, ids): if process.process_model_id: directory_ids = directory_obj.search(cr, uid, [('parent_id','child_of',process.structure_id and process.structure_id.id)]) @@ -235,27 +233,27 @@ class doucment_change_process(osv.osv): document_ids = document_obj.search(cr, uid, [ ('parent_id','in',directory_ids), ('change_type_id','=',document_type_id.id)]) - new_doc_ids = [] - for document_id in document_ids: - vals = {} + new_doc_ids = [] + for document_id in document_ids: + vals = {} if process.pending_directory_id: vals.update({'parent_id':process.pending_directory_id.id}) - new_doc_ids.append(document_obj.copy(cr, uid, document_id, vals)) + new_doc_ids.append(document_obj.copy(cr, uid, document_id, vals)) phase_value = { 'name' : '%s-%s' %(phase_type_id.name, process.name), 'phase_type_id': phase_type_id.id, 'process_id': process.id, - 'phase_document_ids': [(6,0,new_doc_ids)] - } - phase_obj.create(cr, uid, phase_value) - + 'phase_document_ids': [(6,0,new_doc_ids)] + } + phase_obj.create(cr, uid, phase_value) + return True doucment_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 Request'),('change_propose', 'Change Proposed'), ('to_update', 'To Update'), ('cancel', 'Cancel')], 'State'), @@ -265,10 +263,10 @@ class document_file(osv.osv): 'progress': fields.float('Progress'), #TODO : functio field: calculate progress 'change_process_id': fields.related('process_phase_id', 'process_id', type='many2one', relation='document.change.process', string='Change Process'), } - _defaults = { + _defaults = { 'state': lambda *a: 'in_production', - } - + } + def _check_duplication(self, cr, uid, vals, ids=[], op='create'): name=vals.get('name',False) parent_id=vals.get('parent_id',False) @@ -293,15 +291,15 @@ class document_file(osv.osv): if len(res): return False return True - + def do_change_request(self, cr, uid, ids, context={}): - self.write(cr, uid, ids, {'state':'change_request'},context=context) + self.write(cr, uid, ids, {'state':'change_request'},context=context) return True def do_change_propose(self, cr, uid, ids, context={}): - self.write(cr, uid, ids, {'state':'change_propose'},context=context) - return True - + self.write(cr, uid, ids, {'state':'change_propose'},context=context) + return True + def do_to_update(self, cr, uid, ids, context={}): for attach in self.browse(cr, uid, ids, context=context): if attach.change_type_id.directory_id.id: @@ -314,21 +312,21 @@ class document_file(osv.osv): file_name=data['datas_fname'].split('.') new_name=str(file_name[0]+'.old'+time.strftime("%y%m%d")+'.'+file_name[1]) res['name']=attach.name - res['datas']=data['datas'] + res['datas']=data['datas'] res['datas_fname']=new_name res['parent_id']=attach.change_type_id.directory_id.id old_id = self.create(cr, uid, res) - self.write(cr, uid, ids, {'state':'to_update'},context=context) - return True + self.write(cr, uid, ids, {'state':'to_update'},context=context) + return True def do_production(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state':'in_production'},context=context) - return True - + return True + def do_cancel(self, cr, uid, ids, context={}): - return self.write(cr, uid, ids, {'state':'cancel'},context=context) - + return self.write(cr, uid, ids, {'state':'cancel'},context=context) + def test_change_request(self, cr, uid, ids, context=None): return all(bool(attch.target_document_id) != False for attch in self.browse(cr, uid, ids, context=context)) - + document_file() diff --git a/addons/document_change/document_change_data.xml b/addons/document_change/document_change_data.xml index f43b36a7361..ce90be34770 100644 --- a/addons/document_change/document_change_data.xml +++ b/addons/document_change/document_change_data.xml @@ -1,18 +1,19 @@ - - - + + + Gosselies + Bat E - + Bat Z - + @@ -68,8 +69,8 @@ - - + + FIE_template FIE_template.xls @@ -89,16 +90,16 @@ TaktTime_template.xls - - - + + + Project Charter VSM - + Takt Time @@ -111,8 +112,8 @@ - - + + FIE_05466_001 FIE_05466_001.xls @@ -137,8 +138,8 @@ - - + + Concept 1 @@ -154,8 +155,8 @@ - - + + NPI @@ -164,18 +165,18 @@ - + - Quality Alert + Quality Alert - New Product + New Product - Red Risk + Red Risk - CI Card + CI Card diff --git a/addons/document_change/document_change_view.xml b/addons/document_change/document_change_view.xml index 536f173ba39..6b56c25d38b 100644 --- a/addons/document_change/document_change_view.xml +++ b/addons/document_change/document_change_view.xml @@ -2,40 +2,37 @@ - - - - - - - - + + + + + + + document.directory document.directory form -
- - - +
+ + +
- + document.directory document.directory tree - - - - + + + + - + ir.actions.act_window document.directory @@ -57,27 +54,27 @@ - - - - - + + + + + document.change.type.form document.change.type form
- - + + - +
@@ -88,9 +85,9 @@ tree - - - + + +
@@ -104,9 +101,9 @@ - - document.change.process.phase.type.form @@ -114,11 +111,11 @@ form
- - - - - + + + + + @@ -131,7 +128,7 @@ tree - + @@ -145,10 +142,10 @@ form tree,form
- + - + document.change.process.type.form @@ -156,7 +153,7 @@ form
- +
@@ -179,11 +176,11 @@ form tree,form - + - - document.change.process.model.form @@ -193,7 +190,7 @@
- + @@ -204,9 +201,9 @@ document.change.process.model tree - - - + + +
@@ -219,10 +216,10 @@ tree,form - - + + ir.attachment.form ir.attachment @@ -240,16 +237,16 @@ - -