Is possible treeView inside treeView in odoo - group-by

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>

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>

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.

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 create wizard to copy an object many time?

I am beginner in OpenERP, I want to create a wizard to duplicate an object many time, which when i click on the button the wizard open a form the content if this form it's ( textbox + ok button) the textBox for to write how many time the wizard will call copy function to copy the object
This is my class
class immo_article(osv.osv):
_name = "immo.article"
_description = "immo article"
_columns = {
'name':fields.integer('N d inventaire',required=True , size=10),
}
_defaults = {
'date_creation': fields.date.context_today,
}
immo_article()
and this my view
<record id="immo_article_form" model="ir.ui.view">
<field name="name">immo.article.form</field>
<field name="model">immo.article</field>
<field name="arch" type="xml">
<form string="article" >
<button string="%(action_duplicate_object)d" type="action" name="duplicate.wiz"/>
<field name="name" />
</form>
</field>
</record>
<record id="immo_article_tree" model="ir.ui.view">
<record id="immo_article_tree" model="ir.ui.view">
<field name="name">immo.article.tree</field>
<field name="model">immo.article</field>
<field name="arch" type="xml">
<tree string="articles">
<field name="name" />
</tree>
</field>
</record>
<record id="immo_article_form_act" model="ir.actions.act_window">
<field name="name">Article</field>
<field name="res_model">immo.article</field>
<field name="view_mode">tree,form</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_id" ref="immo_article_tree"/>
<field name="help" type="html"></field>
</record>
and this my wizard .py
class duplicate_wiz(osv.osv_memory):
_name = 'duplicate.wiz'
_description = 'duplicate wizard'
_columns = {
'number_of_copies':fields.integer('Number of copies', size=2 , required=True),
}
_defaults = {
'number_of_copies': '0',
}
def duplicate_object(self, cr, uid, ids, context=None):
data = self.read(cr, uid, ids)[0]
article_id = context['active_id']
try:
number_of_copies = data['number_of_copies']
except:
raise osv.except_osv(_('Error'), _('Trouble!'))
return {'type': 'ir.actions.act_window_close'}
duplicate_wiz()
and this my wizard view
<record id="dup_view" model="ir.ui.view">
<field name="name">duplicate.wizard</field>
<field name="model">duplicate.wiz</field>
<field name="priority">1</field>
<field name="arch" type="xml">
<form string="Duplicate" version="7.0">
<group col="2">
<field name="number_of_copies"/>
</group>
<footer>
<button name="duplicate_object" string="_Import" type="action" class="oe_highlight"/>
<button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
<record id="action_duplicate_object" model="ir.actions.act_window">
<field name="name">duplicater action</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">duplicate.wiz</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="view_id" ref="dup_view"/>
</record>
</data>
I know I have many errors in wizard code, because I don't know how to it and how I can call the wizard from the button, anyone can help me with this ?
I don't have time now to read all your code, but the button on immo.article.form should have action reference in name attribute, not in string:
<button name="%(action_duplicate_object)d" type="action" string="A string"/>