Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

Limiting edition of event in calendar only to creator in Odoo 10

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
calendaraccessrules1010.0Odoo10.0
4 Replies
6569 Rodiniai
Portretas
Paweł Ciechomski

How can I edit access rules in Odoo 10 to prevent users from editing other users calendar events?

0
Portretas
Atmesti
Sehrish

http://learnopenerp.blogspot.com/2018/01/groups-and-access-rights-in-odoo.html

Portretas
Royal Administrator
Best Answer
For Odoo 9.0, this patch makes it so the Edit button only appears when viewing your own events,
or under any condition you can compute in a Boolean computed field on the model.
You can use the patch on any model. The example below is for calendar.event.

You will still need a record rule as discussed in other answers
if you want only certain records to be VIEWED or DELETED or WRITTEN from other places.
This patch just deals with selective EDITS so the EDIT button itself does not appear,
rather than letting it appear and then giving the user a cannot-write-this-record message.

Yes, this is modifying core. Kindly forgive.
My intent is to make a module once I have my code base upgraded to Odoo 13.0....

1. Add a computed Boolean field to the model that computes if the row should be editable by the current user.

class CalendarEvent(models.Model):
_inherit = 'calendar.event'

@api.depends('user_id')
@api.one
def _get_selective_readonly_indicator(self):
# JavaScript always allows the admin user to edit, regardless of this indicator field.
self.selective_readonly_indicator = not self.user_id.id == self.env.uid

selective_readonly_indicator = fields.Boolean('Selective Readonly Indicator',
compute='_get_selective_readonly_indicator')

2. Update the form view to add selective_readonly_indicator_field="fieldname" to the <form> element and to include the computed field in the form, at least as an invisible field:

<record id="view_calendar_event_form" model="ir.ui.view">
<field name="name">Calendar - Event Form</field>
<field name="model">calendar.event</field>
<field name="inherit_id" ref="calendar.view_calendar_event_form"/>
<field name="arch" type="xml">
<!-- make editable only by owner of the event -->
<!-- requires patch to addons/web/static/src/js/views/form_view.js -->
<!-- See: https://www.odoo.com/forum/help-1/question/limiting-edition-of-event-in-calendar-only-to-creator-in-odoo-10-136385 -->
<xpath expr="//form" position="attributes">
<attribute name="selective_readonly_indicator_field">selective_readonly_indicator</attribute>
</xpath>
<xpath expr="//form" position="inside">
<field name="selective_readonly_indicator" invisible="1"/>
</xpath>
</field>
</record>

3. Include these three patches to addons/web/static/src/js/views/form_view.js:

Near line 13 after the other require() calls, add one line:

var session = require('web.session'); // 13.0.6.17.18-t13 jimays added

Near line 720 in function FormView._actualize_view(), add one line at the top of the function:

_actualize_mode: function(switch_to) {
switch_to = this.selective_readonly ? "view" : switch_to; // 13.0.6.17.18-t13 jimays selective_readonly
var mode = switch_to || this.get("actual_mode");
// ...

Near line 362 in function FormView.load_record(), add:

this.datarecord = record;
// 13.0.6.17.18-t13 jimays begin patch for selective_readonly_indicator_field
// For example, use <form selective_readonly_indicator_field="selective_readonly_indicator">
// to indicate that records should be readonly even in edit mode
// if the Boolean value of the "selective_readonly_indicator" field is True.
// gratitude View.is_action_enabled() in addons/web/static/src/js/framework/view.js
var attrs = this.fields_view.arch.attrs;
this.selective_readonly_indicator_field = (
'selective_readonly_indicator_field' in attrs ? attrs['selective_readonly_indicator_field'] : '');
// Default to edit mode 1) if admin user or 2) if <form> is free of selective_readonly_indicator_field=.
this.selective_readonly = !(session.uid == 1 || this.selective_readonly_indicator_field == '');
if(this.selective_readonly) { // if default is r/o, check value of field
true || console.log('datarecord: ' + JSON.stringify(this.datarecord));
if ( this.selective_readonly_indicator_field in self.datarecord ) {
this.selective_readonly = self.datarecord[this.selective_readonly_indicator_field];
}
}
true || console.log('selective_readonly: ' + JSON.stringify(this.selective_readonly));
// Blink the Edit button if there are buttons and an Edit button.
// Some forms, e.g. User Preferences window, are already free of visible buttons.
if(this.$buttons != undefined && this.$buttons.length) {
var $edit_button = this.$buttons.find('.oe_form_button_edit')
if($edit_button.length) {
$edit_button.toggle(!this.selective_readonly);
}
}
// 13.0.6.17.18-t13 jimays end patch for selective_readonly_indicator_field
this._actualize_mode();

Enjoy! As you click left/right in the form view to browse records,
the Edit button blinks on whenever you are on your own event.
The admin user is still able to edit all events.

Also answers https://www.odoo.com/forum/help-1/question/how-to-disable-other-user-edit-my-calendar-meeting-2432
More... I realized the calendar view also needs to restrict click/drag.
Patched addons/web_calendar/static/src/js/web_calendar.js
In the middle of view_loaded():
        // Check whether the date field is editable (i.e. if the events can be dragged and dropped)
this.editable = !this.options.read_only_mode && !this.fields_view.fields[this.date_start].readonly;

// 13.0.7.0.4-t6 Add support for selective_readonly_indicator_field.

this.selective_readonly_indicator_field =
'selective_readonly_indicator_field' in attrs ? attrs.selective_readonly_indicator_field : '';
And at the bottom of event_data_transform():
        // 13.0.7.0.4-t6 jimays Add support for selective_readonly_indicator_field.
// gratitude https://fullcalendar.io/docs/event-object

if ( this.selective_readonly_indicator_field && this.selective_readonly_indicator_field in evt ) {
r.editable = !evt[this.selective_readonly_indicator_field];
}

return r;
And added one more xml view:
        <record id="view_calendar_event_calendar" model="ir.ui.view">
<field name="name">Meeting</field>
<field name="model">calendar.event</field>
<field name="inherit_id" ref="calendar.view_calendar_event_calendar"/>
<field name="arch" type="xml">
<!-- make editable only by owner of the event -->
<!-- requires patch to addons/web/static/src/js/views/form_view.js -->
<!-- requires patch to addons/web_calendar/static/src/js/web_calendar.js -->
<xpath expr="//calendar" position="attributes">
<attribute name="selective_readonly_indicator_field">selective_readonly_indicator</attribute>
</xpath>
<xpath expr="//field[@name='name']" position="after">
<field name="selective_readonly_indicator" invisible="1"/>
</xpath>
</field>
</record>




0
Portretas
Atmesti
Portretas
Paweł Ciechomski
Autorius Best Answer

I've read tese articles and I'm sorry, but I do not see this well documented, description is very complicated and not so understandable. 

0
Portretas
Atmesti
Portretas
Hilar Andikkadavath
Best Answer

go through these links

https://www.odoo.com/documentation/10.0/reference/security.html#record-rules

https://www.odoo.yenthevg.com/creating-security-groups-odoo/

http://odoo-development.readthedocs.io/en/latest/dev/access/tutorial.html

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

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

Registracija
Related Posts Replies Rodiniai Veikla
How to retain logged in user privileges once sudo.create method executes in Odoo 10
10 10.0
Portretas
Portretas
1
spal. 19
7807
Edi support in odoo 10-11
edi 10 10.0 11
Portretas
0
saus. 18
4849
[Odoo 10] How to create a journal through code (custom module)? Solved
journal sale.order 10 10.0
Portretas
Portretas
1
geg. 17
9673
Mass Mailing: Use partner field in button's URL href
mailing mass_mailing mailtemplate 10 10.0
Portretas
Portretas
1
kov. 23
6420
The following fields are invalid: Unit of Measure - Odoo 10 Community Edition
sales.order delivery_order UOM 10.0 Odoo10.0
Portretas
Portretas
Portretas
3
vas. 20
5032
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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