How to hide button "Approve" in from view of odoo without coding? - odoo

Please, I need to hide the "Approve" button that is in the "Expense Reports to Approve" view without any code changes, I use odoo 11 and, the module I installed is hr_expense. Here is part of the code for this view:
<form string="Expense Reports" class="o_expense_sheet" modifiers="{}">
<header modifiers="{}">
<button name="approve_expense_sheets" states="submit" string="Approve" type="object" class="oe_highlight o_expense_sheet_approve" modifiers="{'invisible':[['state','not in',['submit']]]}" options="{}"/>
<button name="action_sheet_move_create" states="approve" string="Post Journal Entries" type="object" class="oe_highlight o_expense_sheet_post" modifiers="{'invisible':[['state','not in',['approve']]]}" options="{}"/>
<button name="248" type="action" string="Register Payment" class="oe_highlight o_expense_sheet_pay" attrs="{'invisible': [('state', '!=', 'post')]}" context="{'default_amount': total_amount, 'partner_id': address_id}" modifiers="{'invisible':[['state','!=','post']]}" options="{}"/>
<button name="reset_expense_sheets" states="cancel" string="Resubmit" type="object" modifiers="{'invisible':[['state','not in',['cancel']]]}" options="{}"/>
<button name="247" states="submit,approve" context="{'hr_expense_refuse_model':'hr.expense.sheet'}" string="Refuse" type="action" modifiers="{'invisible':[['state','not in',['submit','approve']]]}" options="{}"/>
<field name="state" widget="statusbar" statusbar_visible="draft,submit,approve,post,done" on_change="1" modifiers="{'readonly':true,'required':true}"/>
</header>
<sheet modifiers="{}">
<div class="oe_button_box" modifiers="{}">
<button name="action_get_attachment_view" class="oe_stat_button" icon="fa-book" type="object" modifiers="{}" options="{}">
<field name="attachment_number" widget="statinfo" string="Documents" modifiers="{'readonly':true}"/>
</button>
</div>

Related

How to add a new button inside the action menu Odoo 12?

Im trying to add a button inside the action in the model named 'consultation', After clicking the button i need to open up the wizard i created follow,But im stuck in some errors
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="specialist_no_show" model="ir.ui.view">
<field name="name">specialist no show</field>
<field name="model">specialist.no.show</field>
<field name="arch" type="xml">
<form string="No Show">
<group>
<group>
<field name="partner_id" readonly="1"/>
</group>
</group>
<footer>
<button name="update_no_show" string="Confirm" type="object" class="btn-primary"/>
<button string="Cancel" class="btn-secondary" special="cancel"/>
</footer>
</form>
</field>
</record>
<act_window name="No Show"
id="specialist_no_show"
res_model="specialist_no_show" #model created for the wizard
binding_model="consultation" #model where i want to show the button in the action
binding_views="form"
view_mode="list"
target="new"
/>
</odoo>
I can spot some problems that you can try:
The XML ID for the form and the act_window must be different. In your example it is both specialist_no_show
The res_model must be specialist.no.show
The structure for the act_window is different depending on your Odoo Version (see below).
For Odoo Version 12.0
<act_window name="No Show"
id="action_specialist_no_show"
res_model="specialist.no.show"
src_model="consultation"
view_mode="form"
target="new"
/>
For Odoo Version 13.0
<act_window name="No Show"
id="action_specialist_no_show"
res_model="specialist.no.show"
binding_model="consultation"
view_mode="form"
target="new"
/>
Also, the error logs would be helpful as #Kenly suggested. Always post those.

Open pop up form in edit mode

Is it possible to have a one2many field in a form view that when you click it, it will pop open the form view of that one2many model but give the user the option to edit and save?
Currently, it pops open the form view of the corresponding model but it doesn't give edit option. Therefore users can only view the details.
I have tried using editable bottom. But this is for inline editing.
Thanks
Below is the example I am facing. If I click on the consultation_ids I get a pop-up form without the ability to edit it.
<record id="view_patient_form" model="ir.ui.view">
<field name="name">medical.record.form</field>
<field name="model">fhg.patient</field>
<field name="priority" eval="1"/>
<field name="arch" type="xml">
<form string="Patient">
<sheet>
<div class="container-fluid">
<field style="z-index: 100" name="image_medium" widget="image" class="openerp oe_left oe_avatar" nolabel="1" />
<div class="oe_title">
<field name="barcode_preview" readonly="1" />
<field name="unique_number" string="Ref:" readonly="1" />
<field name="legacy_unique_number" string="Legacy ref:" />
</div>
</div>
<notebook>
<page string="Outpatient">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<field name="consultation_ids" nolabel="1">
<tree>
<field name="date" string="Date" />
<field name="medical_specialty_id" string="Medical Specialty" />
<field name="consultation_type" string="Consultation Type" />
<field name="medical_staff_id" string="Medical Staff" />
<field name="medical_center_id" string="Medical Center" />
<field name="state" string="State" />
</tree>
</field>
</div>
</div>
</div>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

How can I change boolean_button terminology?

I have defined a button with the boolean_button widget
<button name="toggle_enable" type="object" class="oe_stat_button" icon="fa-unlink">
<field name="enabled" widget="boolean_button" options='{"terminology": "active"}'/>
</button>
I've tried to change the terminology to Exported / Not exported but I have not succeeded. Can someone tell me if it is possible to define a new terminology?
In Odoo v10, you can do it as following :
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object" class="oe_stat_button" icon="fa-check-square" >
<field name="active" widget="boolean_button" options='{"terminology": {
"string_true": "Production Environment",
"hover_true": "Switch to test environment",
"string_false": "Test Environment",
"hover_false": "Switch to production environment"
}}'/>
</button>
</div>
But in Odoo v9, by default it is not there.

How to display button and status bar items in line

How to display below mentioned two group(marked in red circle) in line?
relevant code for the same is given below
<header>
<button name="mymod_assigned" class="oe_highlight" type="workflow" string="Assigned" state="new" />
<button name="mymod_negotiation" class="oe_highlight" type="workflow" string="In Negotiation" state="assigned" />
<button name="mymod_won" class="oe_highlight" type="workflow" string="Won" state="negotiating"/>
<button name="mymod_lost" class="oe_highlight" type="workflow" string="Lost" state="negotiating"/>
<field name="state" widget="statusbar"
statusbar_visible="new,assigned,negotiation,won,lost"
statusbar_colors='{
"new":"blue",
"assigned":"blue",
"negotiation":"blue",
"won":"red",
"lost":"red"
}'
/>
</header>
Try putting left group of buttons in one div with float:left and right group in another div with float:right.

Customer Invoice validate button

I have created a button named 'Confirm' in customer invoice. When i click 'Confirm' button 'state1' will be 'confirmed'. I want to hide Validate button when 'state1'='draft' and show the Validate button when 'state1'='confirmed'. I tried below code but it is not working. Can anyone help me?
<!-- inherit account invoice form -->
<record id="invoice_form_inheritai" model="ir.ui.view">
<field name="name">account.invoice.form.inheritai</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<button name="invoice_print" position="after">
<field name="state1" invisible="1"/>
<button name="invoice_check" string="Confirm" type="object" attrs="{'invisible': [('state1','not in', ['draft'])]}" class="oe_highlight" groups="base.group_user"/>
</button>
<button name="invoice_open" position="replace">
<button name="invoice_open" state="draft" string="Validate" attrs="{'invisible': [('state1','!=', ['confirmed'])]}" groups="base.group_user"/>
</button>
</field>
</record>
<button name="invoice_open" string="Validate" attrs="{'invisible': [('state1','not in', ['confirmed']),('state','not in',['draft'])]}" groups="base.group_user"/>
Please avoid using both invisible attribute and states.
Try using 'states' instead of 'state'. And even attr won't be required. It will work automatically. Ex:
<button name="invoice_open" states="confirmed" string="Validate" groups="base.group_user"/>