Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
4 Odpowiedzi
7216 Widoki

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
Awatar
Odrzuć

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()

Najlepsza odpowiedź

Use like below:

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


Awatar
Odrzuć
Autor Najlepsza odpowiedź

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.


Awatar
Odrzuć

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

Autor

this is not working