How to use a confirmation dialog box in Odoo? - odoo

I'd like to get a value in a confirmation dialog bow in odoo.
I have a form with a select. When I choose a value in the select and click the save button, I have a diablog box with a message. In this message I'd like to get the selected value.
Any idea ?
<button string="save"
icon="gtk-ok"
type="object"
name="update_year"
confirm="The selected year is XXXX. Confirm ?"/>

Related

Disable of submit button based on 3 fields(2 input fields and one checkbox) validation

I am trying to enable the submit button if user enters the Password field, the confirm Password field and checks the terms and conditions checkbox, if any of these field is blank, the submit button should get disabled.
For me the button is only getting enabled if user provides all of the above fields, but once it is enabled, the button is not getting disabled if user removes any of the field values and make it blank.
Can someone Please help ?
<div>
<wb-button v-bind:disabled="disableSubmitButton" v-if="showFinalSubmit" v-on:click="validatePassword" type="submit" size="m" variant="primary">
{{ t("submit") }}
</wb-button>
<div>

trigger (ngOnChange) by code to bind the changed model value

I have an input field that takes a date and use pipe to change the output accordingly and with that I am using
(ngOnChange)="myvalye=myFunction($event)"
to update the value. now I have a button whose onclick i want to reset all the data. Below is the code for refrence.
<mydatepicker [ngModel]="mydate | datepipe" (ngModelChange)="mydate=myFun()"/></mydatepicker>
<button class="btn btn-default" (click)="reset()">Reset</button>
so on click of reset button myValue is not getting changed in input box.
datepicker library can be found here

How can I stop Odoo custom button from auto save?

I have created a button inside my view which triggers a method inside the module. However on clicking the button the temporary edited fields are saved and not reverted when clicking the 'Discard' button.
Here is the code for my view:
<form>
<sheet>
<group>
<field name="name" />
</group>
<button name="my_button" string="My Button" type="object" class="oe_edit_only" />
</sheet>
</form>
Once I click my_button the field name is saved in the database and the button Discard has no effect any more.
How can I prevent Odoo from saving the temporary data when clicking my custom button?
(I'm working with Odoo10 but I guess it's the same for older versions of Odoo)
You may be able to change your button into a Boolean field and make your my_button method an onchange.
Python
my_button = fields.Boolean('Label')
#api.multi
#api.onchange('my_button')
def onchange_my_button(self):
for record in self:
# whatever my_button does
If you want it to still display as a button, you can show the label styled as a button and hide the actual checkbox.
XML
<label for="my_button" class="btn btn-sm btn-primary"/>
<field name="my_button" invisible="1"/>
By default in odoo while any of the server side code will render once you trigger any event (Like button click) then record will be saved first anyhow and you will get the record in Self (Invoking object).
So once you click on that button it means that record has been saved in database and there will no effect of Discard after that.
The best example you can see in the Sales Quotation / Order there is one link "Update" which will just return True from the method it performs nothing but once that method will be called then the entire record will be saved and totals (all functional fields will be calculated) and you feel that update link performs calculation (that link is visible in edit mode only).
Generally in new api methods which are called from the button click should be having decorators #api.one or #api.multi.
##Single record will be there in self.
#api.one
def button_click(self):
return False
##list of records (recordset) will be there in self.
#api.multi
def button_click(self):
return False
So when you click that button that record save first and then method will be called.

Domino designer display field after click

In form I have button, i want display field "Price" after button "Save" click, it's possible ?
Or can be solution to add to field HTML atribute "readonly".
In your form, enable option "Generate HTML for all fields" (check the image below):
It will generate html for all fields, even for hidden ones.
Add field price to the form and hide id by paragraph hide formulas according to your requirements.
When you have saved your form, add a flag to your document, that turns the hide formula for price field to false, and invoke the command:
#Command( [RefreshHideFormulas] );
It will make your price field visible.

Hide edit button according to status in openerp

I want to hide the edit button from the form in my module.But it should hide after changing the status to 'done'.I have three states for record (new,draft,done).If it is in 'draft' status I want to show the edit button . But if it is on 'done' state need to hide the edit button. I tried this
<form string="Consumption Result" edit="false" version="7.0">
But this cause always hide the edit button . How can I give condition here.
You can provide states="draft" for the button "edit" like below:
<button name="case_edit" string="Edit" type="object" states="draft"/>
with this definition the button is available when the states="draft" and not available at "new" and "done".