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

How to open a pop-up with a fields.text inside?

By
Yannick Gerard
on 4/28/15, 4:17 AM 865 views

hello, here's my problem.

I installed hr_holidays module to manage employee's leaves and, what i want to do now is, when a leave is refused, open a pop-up where we can write why we refused that leave, then we have choices :continue or cancel.

I overrode the official hr_holidays.py to add my text field : 'refusal_explanation': fields.text('Refusal explanation') but i don't know how to use it afterwards.

Hope you can help me,


1
ankita
On 4/28/15, 6:14 AM

Hello  Yannick ,

You need to create wizard for the solution this problem and create method in it. like

Python Code -

from openerp.osv import fields, osv

from openerp.tools.translate import _

class refuse_leave(osv.osv_memory):

_name = "refuse.leave"

_description = "Leave Refused"

_columns = {

'refusal_explanation': fields.text('Refusal explanation', required=True)

}

def refuse_leave(self, cr, uid, ids, context=None):

abc_obj = self.pool.get('hr.holiday')

record_id = context.get('active_id')

data = self.read(cr,uid,ids)[0]

print data

xyz = data['refusal_explanation']

print abc_obj.write(cr,uid,[record_id], {'refusal_explanation':xyz,'state':'refuse'})

abc_obj.write(cr,uid,[record_id], {'refusal_explanation':xyz,'state':'refuse'})

return True

refuse_leave()

Xml code -

<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data>

<record id="view_refuse_leave" model="ir.ui.view">

<field name="name">Leave Refuse</field>

<field name="model">refuse.leave</field>

<field name="arch" type="xml">

<form string="Refuse_Leave" version="7.0">

<group col="4">

<field name="refusal_explanation"/>

</group>

<footer>

<button string="Refused" type="object" name="refuse_leave" />

<button string="Cancel" class="oe_link" special="cancel"/>

</footer>

</form>

</field>

</record>

<record id="action_view_refuse_leave" model="ir.actions.act_window">

<field name="name">Leave Refuse</field>

<field name="type">ir.actions.act_window</field>

<field name="res_model">refuse.leave</field>

<field name="view_type">form</field>

<field name="view_mode">form</field>

<field name="target">new</field>

</record>

</data>

</openerp>

Hope it helps


0
Yannick Gerard
On 4/28/15, 8:31 AM

Thanks, but I dont know how to link my button to your code :s

I guess i have to add/change an attribute to it but which one?

And my button is a workflow type, not Action, is it a problem ?

here's my button :

<button string="Refuse" name="refuse" states="confirm,validate,validate1" type="workflow" groups="base.group_hr_user"/>


EDIT// here's the new button i'm talking about in my com below : <button attrs="{'invisible':[('state', 'in', ['draft', 'refuse'])] }" class="oe_highlight" groups="cesbron_hr13.group_holidays_validate" icon="gtk-apply" name="%(action_view_refuse_leave)d" string="Motif de refus" type="action"/>

Ok so here some news ... we can't link a wizard to a workflow button, so I create an other button to fill my field with the wizard, and then, user have to clic and my worflow button. here's my new button: the name is the link to the wizard.

Yannick Gerard
on 5/12/15, 5:30 AM
Yannick Gerard
on 5/12/15, 5:30 AM

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: 4/28/15, 4:17 AM
Seen: 865 times
Last updated: 5/12/15, 5:32 AM