[IMP] document_change: view, button for generate phase
bzr revid: hmo@tinyerp.com-20100123135729-ovznhe0bomnhueaw
This commit is contained in:
@@ -35,7 +35,7 @@ class document_change_type(osv.osv):
|
||||
|
||||
_columns = {
|
||||
'name': fields.char("Document Change Type", size=64,required=True),
|
||||
'phase_type_ids': fields.many2many('document.change.process.phase.type','document_process__rel','type_id','change_id','Phase Type'),
|
||||
'phase_type_ids': fields.many2many('document.change.process.phase.type','document_type_phase_type_rel','document_type_id','phase_type_id','Phase Type'),
|
||||
'template_document_id':fields.many2one('ir.attachment','Document')
|
||||
}
|
||||
document_change_type()
|
||||
@@ -48,7 +48,7 @@ class doucment_change_process_phase_type(osv.osv):
|
||||
'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_phase_process__rel','phase_id','document_id','Document'),
|
||||
'document_type_ids': fields.many2many('document.change.type','phase_type_document_type_rel','phase_type_id','document_type_id','Document Type'),
|
||||
}
|
||||
doucment_change_process_phase_type()
|
||||
|
||||
@@ -67,7 +67,7 @@ class doucment_change_process_phase(osv.osv):
|
||||
'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),
|
||||
'phase_ids':fields.many2one('document.change.process.phase','Phase Type'),
|
||||
'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.many2many('ir.attachment','phase_document_rel','phase_id','document_id','Document'),
|
||||
}
|
||||
@@ -101,7 +101,7 @@ class document_change_process_model(osv.osv):
|
||||
_columns = {
|
||||
'name': fields.char("Changed Process Model", size=64,required=True),
|
||||
'sequence': fields.integer('Sequence'),
|
||||
'phase_type_ids':fields.many2many('document.change.process.phase.type','phase_type_rel','phase_id','phase_model_id','Process Type'),
|
||||
'phase_type_ids':fields.many2many('document.change.process.phase.type','process_model_phase_type_rel','process_model_id','phase_type_id','Phase Type'),
|
||||
}
|
||||
document_change_process_model()
|
||||
|
||||
@@ -124,6 +124,7 @@ class document_change_process_email(osv.osv):
|
||||
'process_id':fields.many2one('document.change.process','Process Change'),
|
||||
}
|
||||
document_change_process_email()
|
||||
|
||||
class doucment_change_process(osv.osv):
|
||||
|
||||
_name = "document.change.process"
|
||||
@@ -146,12 +147,12 @@ class doucment_change_process(osv.osv):
|
||||
'latest_modified_date':fields.function(_latestmodification, method=True, type='date', 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),
|
||||
'process_phase_ids':fields.one2many('document.change.process.phase','process_id','Phase'),
|
||||
'process_document_ids': fields.many2many('ir.attachment','document_changed_process_rel','process_id','change_id','Document To Change'),
|
||||
'process_phase_ids':fields.one2many('document.change.process.phase','process_id','Phase'),
|
||||
'pending_directory_id' :fields.many2one('document.directory','Pending Directory ID'),
|
||||
'date_control': fields.date('Control Date'),
|
||||
'progress': fields.float('Progress'),
|
||||
'current_phase_id': fields.many2one('document.change.process.phase','Current Phase'),
|
||||
'date_control': fields.date('Control Date'), #TODO: make relate field with current_phase_id.date_control
|
||||
'progress': fields.float('Progress'), #TODO : functio field: calculate progress
|
||||
'current_phase_id': fields.many2one('document.change.process.phase','Current Phase'), # TODO: function field. find out in process phase
|
||||
'process_document_ids': fields.many2many('ir.attachment','document_changed_process_rel','process_id','change_id','Document To Change'),
|
||||
}
|
||||
_defaults = {
|
||||
'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'document.change.process'),
|
||||
@@ -175,6 +176,33 @@ class doucment_change_process(osv.osv):
|
||||
|
||||
def do_cancel(self, cr, uid, ids, 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')
|
||||
phase_type_obj = self.pool.get('document.change.process.phase.type')
|
||||
document_type_obj = self.pool.get('document.change.type')
|
||||
document_obj = self.pool.get('ir.attachment')
|
||||
for process in self.browse(cr, uid, ids):
|
||||
if process.process_model_id:
|
||||
for phase_type_id in process.process_model_id.phase_type_ids:
|
||||
phase_type = phase_type_obj.browse(cr, uid, phase_type_id)
|
||||
phase_value = {
|
||||
'name' : '%s-%s' %(phase_type, process.name),
|
||||
'phase_type_id': phase_type_id,
|
||||
'process_id': process.id
|
||||
}
|
||||
phase_id = phase_obj.create(cr, uid, phase_value)
|
||||
cr.execute('select document_type_id from document_type_phase_type_rel where phase_type_id = %s' ,phase_type_id)
|
||||
document_type_ids = map(lambda x: x[0], cr.fetchall())
|
||||
document_ids = document_obj.search(cr, uid, [
|
||||
('parent_id','=',process.structure_id and process.structure_id.id),
|
||||
('change_type_id','in',document_type_ids)])
|
||||
for document_id in document_ids:
|
||||
vals = {'process_phase_id':phase_id}
|
||||
if process.pending_directory_id:
|
||||
vals.update({'parent_id':process.pending_directory_id.id})
|
||||
document_obj.copy(cr, uid, document_id, vals)
|
||||
|
||||
|
||||
doucment_change_process()
|
||||
|
||||
@@ -182,14 +210,16 @@ class document_file(osv.osv):
|
||||
_inherit = 'ir.attachment'
|
||||
|
||||
_columns = {
|
||||
'type_id':fields.many2one('document.change.type','Document Type'),
|
||||
'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'),
|
||||
'target_directory_id': fields.many2one('document.directory', 'Target Document'),
|
||||
'target_document_id':fields.binary('Target'),
|
||||
'change_process_id' :fields.many2one('document.change.process','Process Change'),
|
||||
'process_phase_id' :fields.many2one('document.change.process.phase','Process Phase'),
|
||||
'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 = {
|
||||
'state': lambda *a: 'in_production',
|
||||
'state': lambda *a: 'in_production',
|
||||
}
|
||||
def do_change_request(self, cr, uid, ids, context={}):
|
||||
self.write(cr, uid, ids, {'state':'change_request'},context=context)
|
||||
|
||||
@@ -74,7 +74,8 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Document Types">
|
||||
<field name="name" select="1"/>
|
||||
<field name="phase_type_ids" colspan="4"/>
|
||||
<separator string="Associated Phase Types" colspan="4"/>
|
||||
<field name="phase_type_ids" colspan="4" nolabel="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
@@ -85,8 +86,7 @@
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Document Types">
|
||||
<field name="name"/>
|
||||
<field name="phase_type_ids"/>
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@@ -189,7 +189,8 @@
|
||||
<form string="Model of Changes">
|
||||
<field name="name" select="1"/>
|
||||
<field name="sequence"/>
|
||||
<field name="phase_type_ids" colspan="4"/>
|
||||
<separator string="Phase Type" colspan="4"/>
|
||||
<field name="phase_type_ids" colspan="4" nolabel="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
@@ -199,10 +200,9 @@
|
||||
<field name="model">document.change.process.model</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Model of Changes">
|
||||
<field name="name"/>
|
||||
<tree string="Model of Changes">
|
||||
<field name="sequence"/>
|
||||
<field name="phase_type_ids"/>
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@@ -232,7 +232,7 @@
|
||||
<newline/>
|
||||
<field name="datas_fname"/>
|
||||
<field name="datas" filename="datas_fname" string="Content"/>
|
||||
<field name="type_id"/>
|
||||
<field name="change_type_id"/>
|
||||
</group>
|
||||
<separator string="Change Control" colspan="4"/>
|
||||
<group col="7" colspan="4">
|
||||
@@ -285,7 +285,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Documents">
|
||||
<field name="parent_id" string="Directory"/>
|
||||
<field name="type_id" string="Type"/>
|
||||
<field name="change_type_id" string="Type"/>
|
||||
<field name="state"/>
|
||||
<field name="change_process_id" string="Proc Chg #"/>
|
||||
<field name="user_id" string="Owner"/>
|
||||
@@ -298,7 +298,7 @@
|
||||
<field name="type">graph</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Documents by type" type="bar" orientation="vertical">
|
||||
<field name="type_id"/>
|
||||
<field name="change_type_id"/>
|
||||
<field name="name" operator="+"/>
|
||||
</graph>
|
||||
</field>
|
||||
@@ -313,7 +313,7 @@
|
||||
<group col="7" colspan="4">
|
||||
<filter domain="[('state','=','change_request')]" string="To Change" icon="gtk-apply"/>
|
||||
<filter domain="[('state','=','to_update')]" string="To Validate" icon="gtk-execute"/>
|
||||
<field name="type_id" string="Type of Documents" select="1"/>
|
||||
<field name="change_type_id" string="Type of Documents" select="1"/>
|
||||
<field name="parent_id" select="1"/>
|
||||
<field name="create_uid" string="Owner" select="1"/>
|
||||
</group>
|
||||
@@ -373,7 +373,7 @@
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_document_tree"/>
|
||||
<field name="domain">[('state','=','proposed')]</field>
|
||||
<field name="domain">[('state','=','to_update')]</field>
|
||||
</record>
|
||||
<menuitem action="action_document_to_update_form" id="menu_documents_to_update_form" parent="menu_change_control"/>
|
||||
|
||||
@@ -394,7 +394,7 @@
|
||||
<field name="update_document" string="Update documents"/>
|
||||
<field name="type" string="Type"/>
|
||||
<field name="date_control" string="Control date" attrs="{'required':[('type','=','control_required')], 'invisible': [('type','!=','control_required')]}"/>
|
||||
<field name="phase_ids" string="Phase Type"/>
|
||||
<field name="phase_type_id" string="Phase Type"/>
|
||||
</group>
|
||||
<separator colspan="4" string="Documents"/>
|
||||
<field name="phase_document_ids" colspan="4" nolabel="1"/>
|
||||
@@ -461,7 +461,10 @@
|
||||
<field name="structure_id" select="1"/>
|
||||
<newline/>
|
||||
<field name="description"/>
|
||||
<field name="process_model_id" widget="selection"/>
|
||||
<group colspan="2" col="3">
|
||||
<field name="process_model_id" widget="selection"/>
|
||||
<button name="generate_phases" string="Generate Phases" type="object" icon="gtk-convert"/>
|
||||
</group>
|
||||
<field name="pending_directory_id"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
@@ -503,19 +506,12 @@
|
||||
<field name="state"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Documents">
|
||||
<field name="process_document_ids" mode="tree,form" colspan="4" nolabel="1">
|
||||
<tree string="Documents">
|
||||
<field name="name" string="Document Name"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
<form string="Documents">
|
||||
<field name="name" string="Document Name"/>
|
||||
<field name="state"/>
|
||||
</form>
|
||||
</page>
|
||||
<page string="Documents">
|
||||
<field name="process_document_ids">
|
||||
</field>
|
||||
</page>
|
||||
</page>
|
||||
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
@@ -534,8 +530,8 @@
|
||||
<field name="current_phase_id" string="Current Phase"/>
|
||||
<field name="date_control" string="Date Control Point"/>
|
||||
<field name="process_model_id"/>
|
||||
<field name="progress" string="Progress"/>
|
||||
<field name="process_document_ids" string="# Doc Required"/>
|
||||
<field name="progress" string="Progress"/>
|
||||
<field name="process_document_ids" string="# Documents"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@@ -549,7 +545,7 @@
|
||||
<field name="process_document_ids" operator="+"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_process_serach">
|
||||
<field name="name">document.change.process.search</field>
|
||||
<field name="model">document.change.process</field>
|
||||
|
||||
Reference in New Issue
Block a user