Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
7248 Lượt xem

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
Ảnh đại diện
Huỷ bỏ

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

Câu trả lời hay nhất

Use like below:

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


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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.


Ảnh đại diện
Huỷ bỏ

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

Tác giả

this is not working