Perform "actions" in status bar widget - odoo

I have a field with a status bar widget, and I want if I press a button in the statusbar a function is launched, (something like onchange), some help??

You can use directly the onchange or you can extend the statusbar widget.

Try this:
xml file
<button name="action_draft" type="object"
string="Reset to draft"
states="confirm"/>
<button name="action_confirm" type="object"
string="Confirm" states="draft"
class="oe_highlight"/>
<field name="state" widget="statusbar"/>
.py file
def action_draft(self):
self.state = 'draft'
def action_confirm(self):
self.state = 'confirm'

Related

How to autofocus some field in tree view on "add new" button?

For example, I have this tree view in one2many field:
<tree editable="bottom" class="check_class">
<field name="check" class="oe_edit_only" string=" "/>
<field name="description" decoration-crossed="check == True" string="Чек лист"/>
</tree>
When I click button "add new", in tree view appears a new line and focus go to first field. I want to autofocus second field. Is there some parameter or attribute to achieve this?

How can I make an invoice from custom module ?? I know I need to make Create method for invoice but where to put that method ?? I am beginner in odoo

This is my Custom Module :
When I Click on Create invoice button it shows wizard as shown below :
But when I try to Create regular invoice it shows error :
I Changed the invoicing policy of product from "delivered quantities" to "ordered quantities" but still it throws same error.
xml code adding buttons :
<header>
<button name="action_draft" string="Draft" type="object" data-hotkey="r"/>
<button name="action_in_progress" string="In Progress" type="object" data-hotkey="p"/>
<button name="action_done" string="Done" type="object" states="in_progress"/>
<button name="action_cancel" string="Cancel" type="object" data-hotkey="x"/>
<field name="state" widget="statusbar" nolabel="1"/>
<button name="331" string="Create Invoice" type="action" data-hotkey="x" states="done"/>
</header>
You need to create a python function that does it and then to call that function by naming a button as your function.
Odoo tutorial explaining how to proceed
Code example about how to create an account.move
Don't forget to add taxes if you need to.

how hide button if have same name with different field based on user selection

For example below mentioned code
<button name="invoice_recreate" string="Recreate Invoice"/>
<button name="invoice_corrected" string="Ignore Exception" />
Add the field selection to the view and the attrs attribute to the button like this:
<field name="selection_field" invisible="1" />
<button name="invoice_recreate"
string="Recreate Invoice"
attrs="{'invisible': [('selection_field', '=', 'value')]}" />
<button name="invoice_corrected"
string="Ignore Exception"
attrs="{'invisible': [('selection_field', '!=', 'value')]}" />
I am not sure if this is what you are asking for, let me know if you are asking anything different

Show successfully message after close wizard in odoo v9

What is best solution for display successfully message after close wizard in odoo 9?
Any small popup in right corner?
It's not a proper answer to your question but i have faced the same problem, the problem was that i have to display "successfully submitted" message when user click on submit button on a wizard. and i have done this as my solution
i have done this
i have created one class for the wizard
from odoo import api, fields, models, _
class CustomPopMessage(models.TransientModel):
_name = "custom.pop.message"
name = fields.Char('Message')
create view for custom wizard
<odoo>
<data>
<record id="custom_pop_message_wizard_view_form" model="ir.ui.view">
<field name="name">custom.pop.message.form</field>
<field name="model">custom.pop.message</field>
<field name="arch" type="xml">
<form string="Custom POP Message">
<field name="name" readonly="1"/>
<footer>
<button string="Close" class="btn-default" special="cancel"/>
</footer>
</form>
</field>
</record>
</data></odoo>
button method of another wizard by pressing that button you want to display certain Pop-Up massage
def my_custom_button_function_for_another_wizard():
return {
'name': 'Message',
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'custom.pop.message',
'target':'new',
'context':{'default_name':"Successfully Submitted."}
}

Display a simple message box

How to display a simple message box inside method of a button at the user click.
When the user click on the button he see a message box.
If you just want to show a message box before executing the button function then you need to add an attribute conform in your button xml tag. For example
<button name="button_process" string="Proceed" confirm="Do you want to proceed?" type="object" class="oe_highlight"/>
When user click on this button Proceed a dialog box will be showed with message "Do you want to proceed?", when you click ok on that dialog box, then only the button_process will be executed.
I have Just Add small method in .py file and generate the message box on button click
XML File
<record id="view_hr_payroll_payslip_wizard" model="ir.ui.view">
<field name="name">hr.payroll.payslip.wizards</field>
<field name="model">hr.payroll.payslip.wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="moves" version="7.0">
<footer>
<button name="generate_msg" string="Click To Me" type="object" class="oe_highlight"/>or
</footer>
</form>
</field>
</record>
same name of method are define in my button name attribute in my .py file
from openerp.tools.translate import _
def generate_msg(self, cr, uid, ids, context=None):
raise osv.except_osv(_("Warning!"), _(" Hello Mehdi Mokni !!."))
python Library can be added for covert your message in your Language
I hope this should helpful for you ..:)