Inherit Button From Picking Stock Form View Odoo 12 - odoo-12

i want to make inherit for button on stock picking view form odoo 12 (i have been make it on sale order and purchase order, its fixed), the code is like this:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="stock_picking_form_inherit" model="ir.ui.view">
<field name="name">stock.picking.form</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<xpath expr="//button[#name='button_validate']" position ="before">
<button name="action_confirm" string="Batalkan" type="object" class="oe_highlight"/>
</xpath>
</field>
</record>
</odoo>
but the button of "Batalkan" not show, even if i use before or after on attribute position.

dionpamungkas
On this view there has two button_validate button, so you can choose your customize button from this two-button.
<xpath expr="//button[#name='button_validate'][hasclass('oe_highlight')]" position="before">
<button name="action_confirm" string="Batalkan" type="object" class="oe_highlight"/>
</xpath>
<xpath expr="//button[#name='button_validate'][hasclass('o_btn_validate')]" position="before">
<button name="action_confirm" string="Batalkan" type="object" class="oe_highlight"/>
</xpath>
Thanks

Related

How to display your custom app on home page

I tried to make a menu for my custom app but it doesn't display to home page. Any idea on how to make it happen? I wanted to display my app beside to installed apps. I am using Odoo 14.
This is my form:
<record id="view_custom_module_form" model="ir.ui.view">
<field name="name">view.custom.module.form</field>
<field name="model">custom.model</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Custom" create="false" delete="false" edit="false">
<sheet>
<group>
<group>
<field name="name" readonly="1"/>
<field name="number" readonly="1"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="action_custom_module" model="ir.actions.act_window">
<field name="name">Custom Module</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">custom.model</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_custom_module_form"/>
</record>
And this is my menu:
<menuitem
name="Custom"
id="menu_custom_menu"
sequence="1"
web_icon="custom_module,static/description/icon.png"
groups="base.group_user,base.group_partner_manager"/>
<menuitem id="submenu_custom_menu"
name="Custom"
parent="menu_custom_menu"
action="action_custom_menu"
sequence="1"/>
And I wanted to display my custom app icon here:
I already solved it. This is what I did to show my app.
I put the sequence on it. Make sure you already make your form view so that your custom module will show up.
<menuitem id="menu_custom_form_root"
name="Custom FOrm"
sequence="9"/>
<menuitem id="menu_form"
name="Forms"
parent="menu_custom_form_root"
action="action_forms"
sequence="9"/>

How to solve"Uncaught TypeError: Cannot read property 'type' of undefined when adding button to tree view of Odoo"?

This is my code; I want to add it at the footer of the tree.
<tree string="Generate Payment" create="false">
<group><field name="name"/>
<field name="x_leave_generate"/>
<field name="x_overtime_generate"/>
<field name="x_attendance_generate"/> </group>
</tree>
<button name="method_name" string="Check" type="object" class="oe_button oe_form_button oe_highlight" />
If you are adding button in view it must be added in view like below. You can hader tag if you want to display in top of tree view.
<tree string="Generate Payment" create="false">
<button name="method_name" string="Check" type="object" class="oe_button oe_form_button oe_highlight" />
<group>
<field name="name"/>
<field name="x_leave_generate"/>
<field name="x_overtime_generate"/>
<field name="x_attendance_generate"/>
</group>
</tree>

Problem with creating action for an existing button

I am working with odoo12.
I created a popup in the purchase.order view so that when the user clicks on the "confirm" button a popup appears asking him to enter a value. when executing, I don't have the popup displayed. I think i have to overwrite the "confirm" button and recreate it beacause i tried to create a new button and it works. Can you tell me about the syntaxe of overwriting an exist button in order to add an action.
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!--Proforma Button-->
<record model="ir.ui.view" id="proforma_button_view">
<field name="model">purchase.order</field>
<field name="name">purchase.order.form</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="//header" position="inside">
<button name="button_confirm" string="confirm" type="action" position="inside" class="oe_highlight">
</button>
</xpath>
<xpath expr="//field[#name='state']" position="attributes">
<attribute name="statusbar_visible">draft,sent,purchase,proforma</attribute>
</xpath>
</field>
</record>
</data>
</odoo>

Editable tree view inside a form view is not saving

I have an editable tree view inside my form view.
See this picture:
I can edit the values inside the tree, but every time I hit the Save button at the top, it doesn't save the updated values inside my tree. It goes back to default (in this case 0).
Below is the code for my form view:
<record model="ir.ui.view" id="score_card_form_view">
<field name="name">Score Card</field>
<field name="model">golf_online_ph.score_card</field>
<field name="arch" type="xml">
<form>
<sheet>
<group string="Score Card">
<field name="round_id" />
<field name="player_id" />
<field name="round_holes">
<tree editable="top" >
<field name="hole_number" readonly="1"/>
<field name="score_value"/>
</tree>
</field>
</group>
</sheet>
</form>
</field>
</record>
What should be my workaround here?
Hello #Adrian Steven Quevada,
Your solved? Else update more info about fields. Because your view seems right.

How to save form data using a custom button in Openerp/Odoo

We have a form with fields. We have added our own "Save" button, and want to persist the data on the form to the server when this button is clicked.
We know how to create actions on the server to handle button clicks, but no idea how to retrieve the form data.
Currently, we are using the inbuilt Save button but need to trigger some extra functionality hence the request.
This is what our XML looks like currently.
<record model="ir.ui.view" id="petra_ticket_hold_dialog">
<field name="name">petra.ticket_request.hold.dialog</field>
<field name="model">petra.ticket_request</field>
<field name="arch" type="xml">
<form string="Hold Ticket" edit="false" create="false" delete="false">
<sheet>
<group colspan="2">
<field name="hold_reason"/>
<field name="status" invisible="1"/>
</group>
<button string="Save" />
</sheet>
</form>
</field>
</record>
Here a small example which can help you. First of all you need to add some action of model to button like this:
<record model="ir.ui.view" id="petra_ticket_hold_dialog">
<field name="name">petra.ticket_request.hold.dialog</field>
<field name="model">petra.ticket_request</field>
<field name="arch" type="xml">
<form string="Hold Ticket" edit="false" create="false" delete="false">
<sheet>
<group colspan="2">
<field name="hold_reason"/>
<field name="status" invisible="1"/>
</group>
<!-- it means that will be calls method 'action_my_action' of object 'petra.ticket_request' -->
<button string="Save" name="action_my_action" type="object"/>
</sheet>
</form>
</field>
</record>
After this you need to add method to your model:
# you can use #api.multi for collection processing like this:
# for ticket in self: ...something do here
# or you can use #api.model for processing only one object
#api.model
def action_my_action(self):
# here you have values from form and context
print(self.hold_reason, self._context)
# todo something here... and close dialog
return {'type': 'ir.actions.act_window_close'}
Restart openerp-server and update your module.
Be careful! Object will be saved in db before your action_my_action.
Hope this helps you.