Editable tree view inside a form view is not saving - forms

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.

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>

Is possible treeView inside treeView in odoo

i want to display treeview inside line_ids.
look picture.
group by is sale.order field /line sale.order.line/
How to decision?
Old fashoned tree view:
To get this view you have to define action with view_type="tree" f. e.
<record id="res_partner_action_form" model="ir.actions.act_window">
<field name="name">Partners</field>
<field name="res_model">res.partner</field>
<field name="view_type">tree</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
</p>
<p>
</p>
</field>
</record>
Tree view definition looks the same as normal one. The diffrence is that here you can use parent_id.
<tree string="Account Reports Hierarchy">
<field name="name"/>
<field name="type"/>
<field name="parent_id" invisible="1"/>
<field name="account_report_id"/>
</tree>

odoo 10: extending form view tree of related records (inventory.stock.line)

I need to extend a form (stock.view_inventory_form) in Odoo 10. The form has a sub-tree populated with related records from another model. Here's the part of the original form that I want to change:
<field name="line_ids" string="Inventory Details" context="{'default_location_id': location_id, 'default_product_id': product_id, 'default_prod_lot_id': lot_id, 'default_package_id': package_id, 'default_partner_id': partner_id}" mode="tree,kanban">
<tree string="Inventory Details" editable="bottom" decoration-info="product_qty != theoretical_qty" decoration-danger="theoretical_qty < 0">
<field name="product_id" domain="[('type','=','product')]"/>
<field name="product_uom_id" string="UoM" groups="product.group_uom"/>
<field name="location_id" domain="[('id', 'child_of', parent.location_id)]" groups="stock.group_stock_multi_locations"/>
<field name="prod_lot_id" domain="[('product_id', '=', product_id)]" context="{'default_product_id': product_id}" groups="stock.group_production_lot"/>
<field name="package_id" domain="['|', ('location_id','=', False), ('location_id', '=', location_id)]" groups="stock.group_tracking_lot"/>
<field name="partner_id" groups="stock.group_tracking_owner"/>
<field name="theoretical_qty" readonly="1"/>
<field name="product_qty" string="Real Quantity"/>
<field name="state" invisible="True"/>
</tree>
</field>
Where line_ids is a field from a related model (stock.inventory.line). So I extended the model with the following:
class stock_inventory_line(models.Model):
_inherit = 'stock.inventory.line'
x_container_details = fields.Char('Container details')
x_wagon_no = fields.Char('Wagon No')
x_seal_no = fields.Char('Seal No')
x_invoice_no = fields.Integer('Invoice No')
x_net_weight = fields.Integer('Net weight')
x_gross_weight = fields.Integer('Gross Weight')
Then I tried to extend the form with the following code:
<record id="view_form_todo_task_inherited" model="ir.ui.view">
<field name="name">Test</field>
<field name="model">stock.inventory</field>
<field name="inherit_id" ref="stock.view_inventory_form"/>
<field name="arch" type="xml">
<field name="line_ids">
<field name="x_container_details"/>
<field name="x_wagon_no"/>
</field>
</field>
</record>
Odoo is not returning any error, but my fields are not showed in the (sub) tree of the form.. what am I doing wrong?
Thanks to anyone that can help with this!
This is not the right way to extend a view, you should take a look documentation.
You need to specify the position were you want to add or replace fields, this is an example to insert fields at the end of the list:
<record id="view_form_todo_task_inherited" model="ir.ui.view">
<field name="name">Test</field>
<field name="model">stock.inventory</field>
<field name="inherit_id" ref="stock.view_inventory_form"/>
<field name="arch" type="xml">
<!-- to insert your fields at the end of the list -->
<xpath expr="//tree/field[#name='state']" position="after" >
<field name="x_container_details"/>
<field name="x_wagon_no"/>
</xpath>
</field>
I hope this can be helpfull for you.

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.