Mohammed Mansour
Mohammed Mansour

Reputation: 124

OpennERP Confirm Message

I have tried to use this warning box module in create method, but it yields an error because of the return of create method must be the created record ID in the database (not any thing else).

I only want to display a confirm message (Yes/No) when the user clicks save when creating or editing the view.

I don't want to use Javascript.

I have also used the Python Easy Gui library. It works very well locally, but on the remote server it yields this error:

_tkinter.TclError: no display name and no $DISPLAY environment variable

When trying to overcome this problem, I have logged in the remote server using -X attribute in the ssh command line (ssh -X UserName@IP) and the library works well when testing so the solution to solve this problem to set the parameters of the ssh configuration file correctly but it doesn't work yet.

How can I create a confirm message in the create method?

Upvotes: 1

Views: 2084

Answers (2)

Yaseen Shareef
Yaseen Shareef

Reputation: 767

There are two methods by which you can do this,

1)In Buttons, you can add a special field called confirm to the definition and that, alone, will do what you want. Eg:

<button name="Name of the button"
    string="Showable label"
    type="object"
    confirm="Are you sure you want to do this?"
/>

This will pop up a confirmation window showing the text "Are you sure you want to do this?".

2) You can create a wizard,with the two Button, one of type special cancel and the other execute a function that will also call the confirm function in the workflow.

Example:

<record id="view_cancel_repair" model="ir.ui.view">
<field name="name">Cancel Repair</field>
<field name="model">mrp.repair.cancel</field>
<field name="arch" type="xml">
    <form string="Cancel Repair Order" version="7.0">
        <group>
            <label string="This operation will cancel the Repair process, but will not cancel it's Invoice. Do you want to continue?"/>
        </group>
        <footer>
            <button name="cancel_repair" string="Yes" type="object" class="oe_highlight"/>
            or
            <button string="Cancel" class="oe_link" special="cancel" />
        </footer>
    </form>
</field>

I hope this helps you! Thanks And Regards

Upvotes: 1

Daniel Reis
Daniel Reis

Reputation: 13342

The correct way to do that is to use a Wizard.

It means some overhead, since you must before hand define a Model and a Form View for the wizard, but there's no shortcut for that in the standard Odoo.

Upvotes: 0

Related Questions