Skip to Content
Menu
This question has been flagged
1 Reply
5818 Views

hi all, facing problem to add a page in notebook for a One2many field, its appearing in tree style view but I it to appear like a form view but failed. when using <tree> or <form> its working in tree style otherwise showing error on Upgrade module. also notice that it is showing User in tree which is not included in view/xml file. please help and guide how I can have a form like single record entry view here for a One2many field under notebook section. my both file entries are here what I did. definitely i am missing something or doing wrong because of my very little knowledge.

from odoo import models, fields

class Wallets(models.Model):
    _name = 'tests.userwallets'
    _description = "Tests Wallets"

    user_id = fields.Many2one("res.partner", ondelete='cascade', string="User", required=True)
    amount = fields.Float(string="Amount", required=True)
    credits = fields.Integer(string="Credits", required=True)
    description = fields.Text(string="Description")
from odoo import models, fields

class PartnerZone(models.Model):
    _inherit = 'res.partner'

    zone_id = fields.Many2one('tests.zones', string="Zone")
    user_wids = fields.One2many('tests.userwallets', 'user_id', string="User Wallets")
<?xml version="1.0" encoding="UTF-8"?>

<odoo>
    <record id="view_res_partner_form_inherit" model="ir.ui.view">
        <field name="name">Contacts Custom Fields</field>
        <field name="model">res.partner</field>
        <field name="type">form</field>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='category_id']" position="after">
                <field name="zone_id" string="Zone"/>
            </xpath>
            <!-- User Wallet entry under notebook section -->
            <!-- ======================================== -->
            <xpath expr="//notebook" position="inside">
                <page string="Wallets">
                    <field name="user_wids">
                        <form>
                            <group>
                                <field name="amount"/>
                                <field name="credits"/>
                                <field name="description"/>
                            </group>
                        </form>
                    </field>
                </page>
            </xpath>
        </field>
    </record>
</odoo>


Avatar
Discard
Best Answer

Hello SmithJohn45,

In odoo's one2many type field, they will create one table like a tree structure, so If you want to open a single record then you can use many2one instead of one2many field,

Thank you!

Regards,




Email:      odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

   

Avatar
Discard
Author

thank you for reply :)

Related Posts Replies Views Activity
1
Apr 23
1130
1
Jul 22
1152
0
Apr 22
1669
1
Dec 21
2741
1
Dec 20
2445