Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

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

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
securityodoohelpforumsecurity.xmlv14
1 Răspunde
4790 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Imagine profil
Jainesh Shah(Aktiv Software)
Cel mai bun răspuns

Hello alfik,

Please find below answer it may help you,

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

0
Imagine profil
Abandonează
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!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
AttributeError: 'str' object has no attribute 'get' odoo14
python helpdesk odoo helpforum v14
Imagine profil
Imagine profil
Imagine profil
2
iul. 24
8704
i am trying to override var ServicesMixin = require('web.ServicesMixin'); issue
web helpme odoo helpforum v14
Imagine profil
0
ian. 24
1795
Element cannot be located in parent view. odoo 14
error helpdesk odoo helpforum v14
Imagine profil
Imagine profil
Imagine profil
2
mai 23
7956
index error: list index out of range
csv helpdesk odoo helpforum v14
Imagine profil
0
mar. 22
101
How to raise a warning like "Your DOB is should be less then today date"? Rezolvat
helpdesk date.time odoo helpforum v14
Imagine profil
Imagine profil
Imagine profil
2
feb. 22
4260
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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