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.

1

Create an osv_memory wizard system

By
Samba Faye
on 10/29/13, 1:17 PM 2,553 views

I want to create an osv_memory wizard system. For that I've create, in the wizard folder of the holidays module, the following classe:

import time from openerp.osv

import fields, osv

class hr_holidays_popup_confirm(osv.osv_memory):

_name = 'hr.holidays.popup.confirm'
_description = 'Popup de confirmation'
def act_ok(self, cr, uid, ids, context=None):
    return {'type':'ir.actions.act_window_close'

}

def act_destroy(self, *args):
    return {'type':'ir.actions.act_window_close'

}

def test(self):
    return 1
_columns = {
        'message': fields.text('Message', 256, readonly=True),
        'value': fields.integer('Returning'),
        }   def action_call_popup(self,cr,uid,ids,context=None):
    #print'lol wut?'
    data={'Message': 'Vous avez depasse le nombre de jour max a detailler!','value':1}
    if context is None: context = {}
    wizard_id = self.pool.get("hr.holidays.popup.confirm").create(
        cr, uid, data, context=dict(context, active_ids=ids))
    #print 'wizard_id : ', wizard_id
    return {
        'name':_("Attention"),
        'view_mode': 'form',
        'view_id': False,
        'view_type': 'form',
        'res_model': 'hr.holidays.popup.confirm',
        'res_id':wizard_id,
        'type': 'ir.actions.act_window',
        'nodestroy': True,
        'target': 'new',
        'domain': '[]',
        'context': dict(context, active_ids=ids)
    } hr_holidays_popup_confirm().

I've create the view as bollow:

<openerp>

<data>
    <record id="popup" model="ir.ui.view">
        <field name="name">Attention</field>
        <field name="model">hr.holidays.popup.confirm</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form col="4" string="Attention">
                <group col="2" fill="0">
                    <field name="message" />
                </group>
                <group col="2" colspan="3" fill="0">
                    <button name="act_ok" string="Ok" type="object"/>
                    <button  name="act_destroy" special="cancel" string="Close" type="object"/>
                </group>
                <group col="2" fill="0">
                    <field name="value" invisible="1"/>
                </group>
            </form>
        </field>
    </record>
</data>

</openerp>.

I import the classe hr_holidays_popup_confirm inth the file __init___.py which is in the wizard folder. In the __openerp__.py file of the holidays module I declare the view of my wizard.

After that I call my wizard in the method check_holidays() of the module holidays like this:

holi_popup_confirm_obj = self.pool.get('hr.holidays.popup.confirm') holi_popup_confirm_obj.action_call_popup(cr,uid,ids,context)

But when I click on the save button to create a leave resquest; I have the following error message:

Integrity error The operation could not be completed, probably as a result of: - Deletion: you try to delete a record which other records refer - Creation / modification: a required field has not been completed correctly [object with reference to: message - message].

Some body can help me?

I don't have now the error message. But my wizard does not appear. The error was due to the fact that I not inform the fields 'message'. I misspelled the fields. I wrote Message instead of message. It was the uppercase M. The wizard still does not display. But the data are stored in a database.

Samba Faye
on 10/29/13, 2:36 PM
0
Samba Faye
On 10/29/13, 2:36 PM

I don't have now the error message. But my wizard does not appear. The error was due to the fact that I not inform the fields 'message'. I misspelled the fields. I wrote Message instead of message. It was the uppercase M. The wizard still does not display. But the data are stored in a database.

No body can help me????

Samba Faye
on 10/30/13, 8:39 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

0 follower(s)

Stats

Asked: 10/29/13, 1:17 PM
Seen: 2553 times
Last updated: 3/16/15, 8:10 AM