Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

how to write a security rule so that any users can view and edit their own records

Odoberať

Get notified when there's activity on this post

This question has been flagged
securityodoohelpforumsecurity.xmlv14
1 Odpoveď
4794 Zobrazenia
Avatar
alfik

i created a custom module and now i want to give a security rule that any users who logged in can can edit their own records

Thanks in advance

my code

from odoo import fields, models, api
from odoo.exceptions import UserError





class Subject(models.Model):
_name = 'std.subject'
_description = 'Subject'

name = fields.Char(string='Subject')
student_id = fields.Many2many('std.record', string='students')


class StudentDetails(models.Model):
_name = 'std.record'
_description = 'Student'

name = fields.Char(string='Name')
middle_name = fields.Char(string='Middle Name')
last_name = fields.Char(string='Last Name')
roll_no = fields.Integer(string='Roll Number')
std_dob = fields.Date(string='Date of Birth')
image = fields.Binary(string='Image')
introduction = fields.Text(string="Introduction")
std_class = fields.Many2one(comodel_name='std.class', string='Student Class')
subj = fields.Many2many(comodel_name='std.subject', string='Subject')
user_id = fields.Many2one(comodel_name='res.users',string='User')

_sql_constraints = [
('unique_roll_number', 'unique(roll_no)', 'This roll number is already used on another student.'), ]

@api.constrains('std_dob')
def check_student_dob(self):
if self.std_dob and self.std_dob >= fields.Date.today():
raise UserError(('DOB should be less than Today\'s Date.'))


class Class(models.Model):
_name = 'std.class'
_description = 'Class'

name = fields.Char(string='Class')
stdnt_class = fields.One2many(
comodel_name='std.record',
inverse_name='std_class',
string='class',
required=False)


0
Avatar
Zrušiť
Avatar
Jainesh Shah(Aktiv Software)
Best Answer

Hello alfik,

Please find below answer it may help you,

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

0
Avatar
Zrušiť
Jainesh Shah(Aktiv Software)

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="base.module_category_student" model="ir.module.category">
<field name="description">Helps you handle your student details.</field>
<field name="sequence">1</field>
</record>

<!-- Groups -->
<record id="group_student_user" model="res.groups">
<field name="name">User: Own Documents Only</field>
<field name="category_id" ref="base.module_category_student"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
<field name="comment">the user will have access to his own data.</field>
</record>

<record id="group_student_manager" model="res.groups">
<field name="name">Administrator</field>
<field name="comment">the user will have an access to the student configuration as well as all user recode.</field>
<field name="category_id" ref="base.module_category_student"/>
<field name="implied_ids" eval="[(4, ref('group_student_user'))]"/>
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
</record>
<!-- Recode Rules -->
<record id="studunt_rule_all_recode" model="ir.rule">
<field name="name">All Student</field>
<field ref="model_std_record" name="model_id"/>
<field name="domain_force">[(1,'=',1)]</field>
<field name="groups" eval="[(4, ref('YOURE_MODULE_NAME.group_student_manager'))]"/>
</record>

<record model="ir.rule" id="student_own_recode">
<field name="name">Users can only access their own recode</field>
<field name="model_id" ref="model_std_record"/>
<field name="domain_force">[('user_id', '=', user.id)]</field>
</record>
</odoo>

alfik
Autor

Thanks a bunch Jainesh Shah

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
AttributeError: 'str' object has no attribute 'get' odoo14
python helpdesk odoo helpforum v14
Avatar
Avatar
Avatar
2
júl 24
8705
i am trying to override var ServicesMixin = require('web.ServicesMixin'); issue
web helpme odoo helpforum v14
Avatar
0
jan 24
1797
Element cannot be located in parent view. odoo 14
error helpdesk odoo helpforum v14
Avatar
Avatar
Avatar
2
máj 23
7956
index error: list index out of range
csv helpdesk odoo helpforum v14
Avatar
0
mar 22
101
How to raise a warning like "Your DOB is should be less then today date"? Solved
helpdesk date.time odoo helpforum v14
Avatar
Avatar
Avatar
2
feb 22
4260
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now