Skip to Content
Menu
This question has been flagged
4 Replies
6405 Views

I am using odoo 12


sale_individual.py file

from odoo import fields, models


class SaleIndividual(models.Model):
_name = 'sale.individual'
_inherit = 'res.users'
name = fields.Char()
email = fields.Char()
    individual_description = fields.Char()


And the view file is sale_individual_view.xml
<?xml version="1.0"?>
<odoo>
<record id="view_form_sale_custom_individual" model="ir.ui.view">
<field name="name">Individual Form</field>
<field name="model">sale.individual</field>
<field name="arch" type="xml">
<form string="Individual"> <group>
<field name="name" />
<field name="email" />
<field name="individual_description" />
</group>
</form>
</field>
</record>

<record id="view_tree_sale_custom_individual" model="ir.ui.view">
<field name="name">Individual Form</field>
<field name="model">sale.individual</field>
<field name="arch" type="xml">
<tree>
<field name="individual_description" />
</tree>
</field>
</record>
</odoo>

After writing this code, I am getting the error.
"You cannot create a new user from here.
To create new user please go to configuration panel."
But I want to create the new user on the new view sale_individual_view itself and want my data to enter table sale_individual in db
Avatar
Discard

why do u want to inherit res.users? why dont you just create a seperate model and write a function to create res.user record,link it your model and call that function on create()

Best Answer

Use like below:

class SaleIndividual(models.Model):
    _name = 'sale.individual'
    _inherit​s = 'res.users'
name = fields.Char()
email = fields.Char()
individual_description = fields.Char()


Avatar
Discard
Author Best Answer

can you please give me an example of how to do it?

Also I want all the fields of res,users in the table of my own sale_individual table in db alongwith new fields.


Avatar
Discard

Use inherits then for getting all the fields of res.users to your model

Author

this is not working