From e6d46870fd519d935c587bb5a811e486bcfb14f7 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Wed, 27 Jan 2010 01:33:18 +0100 Subject: [PATCH] [IMP] improve document change bzr revid: fp@tinyerp.com-20100127003318-1oqkk4f8cyd685kg --- addons/document/document_directory.py | 2 +- addons/document/document_view.xml | 11 +++--- addons/document_change/__init__.py | 2 +- addons/document_change/__terp__.py | 3 +- addons/document_change/document_change.py | 39 ++++++++++++++++--- .../document_change/document_change_data.xml | 8 ++-- .../document_change/document_change_view.xml | 20 +++++++--- 7 files changed, 61 insertions(+), 24 deletions(-) diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index cb96ef12a47..ad13ad925e1 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -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)) diff --git a/addons/document/document_view.xml b/addons/document/document_view.xml index f7df0b84a5b..ac14f372729 100644 --- a/addons/document/document_view.xml +++ b/addons/document/document_view.xml @@ -145,6 +145,7 @@ Directorie's Structure document.directory tree + [('ressource_parent_type_id','=',False),('parent_id','=',False)] ir.actions.act_window ir.attachment form - [('parent_id','=',active_id)] + [('parent_id','child_of',active_id)] {'parent_id':'active_id'} @@ -295,10 +296,10 @@ - + diff --git a/addons/document_change/__init__.py b/addons/document_change/__init__.py index 2cf5916bbfe..daf24e652b9 100644 --- a/addons/document_change/__init__.py +++ b/addons/document_change/__init__.py @@ -20,6 +20,6 @@ ############################################################################## import document_change +import document_change_report import document_change_mailgate -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document_change/__terp__.py b/addons/document_change/__terp__.py index bb2c24d89e0..218dc36ba9d 100644 --- a/addons/document_change/__terp__.py +++ b/addons/document_change/__terp__.py @@ -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' diff --git a/addons/document_change/document_change.py b/addons/document_change/document_change.py index 9179dbda01d..c4b7c1152fa 100644 --- a/addons/document_change/document_change.py +++ b/addons/document_change/document_change.py @@ -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) diff --git a/addons/document_change/document_change_data.xml b/addons/document_change/document_change_data.xml index 031d3f967d3..a0eb58ad56b 100644 --- a/addons/document_change/document_change_data.xml +++ b/addons/document_change/document_change_data.xml @@ -4,15 +4,15 @@ - Gosselies + Bat E - Bat E + Commodity A - Bat Z + Commodity B @@ -95,7 +95,7 @@ TaktTime_template.xls - + Project Charter diff --git a/addons/document_change/document_change_view.xml b/addons/document_change/document_change_view.xml index 7d5b8f1055c..dfd60ba7565 100644 --- a/addons/document_change/document_change_view.xml +++ b/addons/document_change/document_change_view.xml @@ -245,6 +245,7 @@ + @@ -302,6 +303,7 @@ + @@ -492,7 +494,8 @@ - + +