Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Why is current workflow state not highlighted?

By
Ademola Oke
on 12/5/13, 8:18 AM 1,166 views

I'm developing a new module with a workflow. Everything works fine except that the current workflow state is not highlighted i.e. the blue highlight for the current state of the document in the form view.

Can anyone help identify where the problem is coming from? I have tried and tried but have not been able to figure it out.

Module:

_columns = {        
    'name': fields.char('Description', size=255, required=True),
    'file_no': fields.char('File Number', size=64, required=True),
    'form_no': fields.char('Form Number', size=64, required=True), 
    'tcc_no': fields.char('TCC Number', size=32, readonly=True), 
    'your_ref': fields.char('Your Ref', size=64),
    'our_ref': fields.char('Our Ref', size=64),     
    'partner_id': fields.many2one('res.partner', 'Tax Payer', required=True),  
    'note': fields.text('Notes'),                   
    'gitr_ids':fields.many2many('rirs.gitr', 'tcc_gitr_rel', 'gitr_id', 'tcc_id', 'Yearly Payments'),  
    'state': fields.selection([('draft', 'Draft'), ('hod_approved', 'HOD Approved'), ('audit_approved', 'Audited'), ('ar_approved', 'AR Approved'), ('ec_approved', 'EC Approved'), ('hod_rejected', 'HOD Rejected'), ('audit_rejected', 'Audit Rejected'), ('ar_rejected', 'AR Rejected'), ('ec_rejected', 'EC Rejected'),], 'Status', readonly=True),         
}
_defaults = {
    'state': 'draft', 
}
_sql_constraints = [ 
     ('form_no', 'unique(form_no)', 'The form number must be unique!'),
]
_order = "id desc" 

def create(self, cr, uid, vals, context=None):
    tcc_no = self.pool.get('ir.sequence').get(cr, uid, 'rirs.tcc')
    vals['tcc_no'] = tcc_no
    return super(rirs_tcc, self).create(cr, uid, vals, context=context)     

def draft(self, cr, uid, ids, context=None):
    self.write(cr, uid, ids, {'state': 'draft'}, context=context)   
    return {}  

def hod_approve(self, cr, uid, ids, context=None):
    self.write(cr, uid, ids, {'state': 'hod_approved'}, context=context)
    return {}     

def audit_approve(self, cr, uid, ids, context=None):
    self.write(cr, uid, ids, {'state': 'audit_approved'}, context=context)
    return {}   

def ar_approve(self, cr, uid, ids, context=None):
    self.write(cr, uid, ids, {'state': 'ar_approved'}, context=context)
    return {}    

def ec_approve(self, cr, uid, ids, context=None):
    self.write(cr, uid, ids, {'state': 'ec_approved'}, context=context)
    return {}       

def cancel_tcc(self, cr, uid, ids, context=None):
    self.write(cr, uid, ids, {'state': 'draft'}, context=context)    
    return {}    

def cancel_hod(self, cr, uid, ids, context=None):
    self.write(cr, uid, ids, {'state': 'hod_rejected'}, context=context)    
    return {}     

def cancel_audit(self, cr, uid, ids, context=None):
    self.write(cr, uid, ids, {'state': 'audit_rejected'}, context=context)    
    return {}        

def cancel_ar(self, cr, uid, ids, context=None):
    self.write(cr, uid, ids, {'state': 'ar_rejected'}, context=context)    
    return {}     

def cancel_ec(self, cr, uid, ids, context=None):
    self.write(cr, uid, ids, {'state': 'ec_rejected'}, context=context)    
    return {}

Workflow:

<openerp>
<data>
    <record id="wkf" model="workflow">
        <field name="name">rirs.tcc.basic</field>
        <field name="osv">rirs.tcc</field>
        <field name="on_create">True</field>
    </record>

    <record id="act_draft" model="workflow.activity">
        <field name="wkf_id" ref="wkf"/>
        <field name="name">draft</field>
        <field name="flow_start">True</field>
        <field name="kind">function</field>
        <field name="action">draft()</field>
        <field name="split_mode">OR</field>
    </record>

    <record id="act_hod" model="workflow.activity">
        <field name="wkf_id" ref="wkf"/>
        <field name="name">hod_approve</field>
        <field name="action">hod_approve()</field>
        <field name="kind">function</field>                       
    </record>  

    <record id="act_audit" model="workflow.activity">
        <field name="wkf_id" ref="wkf"/>
        <field name="name">audit_approve</field>
        <field name="action">audit_approve()</field>
        <field name="kind">function</field>                       
    </record>

    <record id="act_ar" model="workflow.activity">
        <field name="wkf_id" ref="wkf"/>
        <field name="name">ar_approve</field>
        <field name="action">ar_approve()</field>
        <field name="kind">function</field>                       
    </record>

    <record id="act_cancel" model="workflow.activity">
        <field name="wkf_id" ref="wkf"/>
        <field name="name">cancel_tcc</field>
        <field name="action">cancel_tcc()</field>
        <field name="kind">function</field>                       
    </record>

    <record id="act_ec" model="workflow.activity">
        <field name="wkf_id" ref="wkf"/>
        <field name="name">ec_approve</field>
        <field name="action">ec_approve()</field>
        <field name="kind">function</field> 
        <field name="flow_stop">True</field>
    </record>

    <record id="t1" model="workflow.transition">
        <field name="act_from" ref="act_draft"/>
        <field name="act_to" ref="act_hod"/>
        <field name="signal">hod_approve</field>
    </record>

    <record id="t2" model="workflow.transition">
        <field name="act_from" ref="act_hod"/>
        <field name="act_to" ref="act_audit"/>
        <field name="signal">audit_approve</field>
    </record> 

    <record id="t3" model="workflow.transition">
        <field name="act_from" ref="act_audit"/>
        <field name="act_to" ref="act_ar"/>
        <field name="signal">ar_approve</field>
    </record>

    <record id="t4" model="workflow.transition">
        <field name="act_from" ref="act_ar"/>
        <field name="act_to" ref="act_ec"/>
        <field name="signal">ec_approve</field>
    </record>

     <record id="t5" model="workflow.transition">
        <field name="act_from" ref="act_cancel"/>
        <field name="act_to" ref="act_draft"/>
        <field name="signal">draft</field>
    </record>

</data>

</openerp>

View:

<!-- TCC Form View -->

<record id="view_rirs_tcc_form" model="ir.ui.view">
  <field name="name">rirs.tcc.form</field>
  <field name="model">rirs.tcc</field>
  <field name="arch" type="xml">
    <form string="TCC" version="7.0">  
      <header>
          <button string="HOD Approved" name="hod_approve" type='object' states="draft" class="oe_highlight"/>
          <button string="Cancel TCC" name="cancel_hod" type='object' states="draft"/>    
          <button string="Audit Approved" name="audit_approve" type='object' states="hod_approved" class="oe_highlight"/>
          <button string="Cancel TCC" name="cancel_audit" type='object' states="hod_approved"/> 
          <button string="AR Approved" name="ar_approve" type='object' states="audit_approved" class="oe_highlight"/>
          <button string="Cancel TCC" name="cancel_ar" type='object' states="audit_approved"/>                                  
          <button string="EC Approved" name="ec_approve" type='object' states="ar_approved" class="oe_highlight"/>
          <button string="Cancel TCC" name="cancel_ec" type='object' states="ar_approved"/>                 
          <button string="Set to Draft" name="draft" type='object' states="hod_rejected,audit_rejected,ar_rejected,ec_rejected"/>
          <field name="state" widget="statusbar" statusbar_visible="draft,hod_approved,audit_approved,ar_approved,ec_approved"/>
      </header>
      <sheet string="TCC">
        <h1>
          <label string="Tax Clearance Certificates"/>
        </h1> 
        <div class="oe_title"> 
          <div class="oe_edit_only">   
            <label for="type" string="Clearance Type"/>                                            
            <field name="type"/>    
          </div>    
          <h1>   
            <field name="name" placeholder="Description..."/> 
            <field name="partner_id" placeholder="Tax Payer..."/>
          </h1>       
        </div> 
        <group col="4">                   
          <field name="form_no"/>
          <field name="file_no"/>    
          <field name="tcc_no"/> 
          <field name="our_ref"/>    
          <field name="your_ref"/>       
          <field name="state"/>
        </group>       
        <notebook colspan="4">
          <page string="Payments">    
            <field name="gitr_ids"/>
          </page>
        </notebook>
        <separator string="Notes"/>
        <field name="note"/>  
      </sheet>
    </form>
  </field>
</record>
1
LAKHSAM Khalid
On 12/5/13, 8:30 AM

You should delete "<field name="state"/>" from the form view "". and it will work fine .

Thank you! Worked just like you said.

Bam Technologies Limited, Ademola Oke
on 12/5/13, 10:16 AM

@Faiyer, if the answer is correct you should mark it as correct. ;)

Versão Integral, Anabela Damas
on 12/5/13, 11:13 AM

It's been marked!

Bam Technologies Limited, Ademola Oke
on 12/5/13, 12:28 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/5/13, 8:18 AM
Seen: 1166 times
Last updated: 3/16/15, 8:10 AM