[REF] event: visibility moved from portal_event to event. Customized rules, removed now unnecessary files.

bzr revid: tde@openerp.com-20130410125117-m9ir36qhkp9fqax1
This commit is contained in:
Thibault Delavallée 2013-04-10 14:51:17 +02:00
parent ef3ff580f5
commit 7c026132ff
8 changed files with 51 additions and 86 deletions

View File

@ -173,6 +173,13 @@ class event_event(osv.osv):
continue
return res
def _get_visibility_selection(self, cr, uid, context=None):
""" Overriden in project_issue to offer more options """
return [('public', 'All Users'),
('employees', 'Employees Only')]
# Lambda indirection method to avoid passing a copy of the overridable method when declaring the field
_visibility_selection = lambda self, *args, **kwargs: self._get_visibility_selection(*args, **kwargs)
_columns = {
'name': fields.char('Name', size=64, required=True, translate=True, readonly=False, states={'done': [('readonly', True)]}),
'user_id': fields.many2one('res.users', 'Responsible User', readonly=False, states={'done': [('readonly', True)]}),
@ -210,11 +217,14 @@ class event_event(osv.osv):
'note': fields.text('Description', readonly=False, states={'done': [('readonly', True)]}),
'company_id': fields.many2one('res.company', 'Company', required=False, change_default=True, readonly=False, states={'done': [('readonly', True)]}),
'is_subscribed' : fields.function(_subscribe_fnc, type="boolean", string='Subscribed'),
'visibility': fields.selection(_visibility_selection, 'Privacy / Visibility',
select=True, required=True),
}
_defaults = {
'state': 'draft',
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'event.event', context=c),
'user_id': lambda obj, cr, uid, context: uid,
'visibility': 'employees',
}
def subscribe_to_event(self, cr, uid, ids, context=None):

View File

@ -76,6 +76,7 @@
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
<h1><field name="name"/></h1>
<field name="visibility"/>
</div>
<group>
<group>

View File

@ -25,25 +25,35 @@
<data noupdate="1">
<!-- Multi - Company Rules -->
<record model="ir.rule" id="event_event_comp_rule">
<field name="name">Event multi-company</field>
<record model="ir.rule" id="event_event_company_rule">
<field name="name">Event: multi-company</field>
<field name="model_id" ref="model_event_event"/>
<field name="global" eval="True"/>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
<field name="domain_force">['|',
('company_id', '=', False),
('company_id', 'child_of', [user.company_id.id]),
]
</field>
</record>
<record model="ir.rule" id="event_registration_comp_rule">
<field name="name">Event Registration multi-company</field>
<record model="ir.rule" id="event_registration_company_rule">
<field name="name">Event/Registration: multi-company</field>
<field name="model_id" ref="model_event_registration"/>
<field name="global" eval="True"/>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
<field name="domain_force">['|',
('company_id', '=', False),
('company_id', 'child_of', [user.company_id.id]),
]
</field>
</record>
<record model="ir.rule" id="report_event_registration_comp_rule">
<field name="name">Report Event Registration multi-company</field>
<record model="ir.rule" id="report_event_registration_company_rule">
<field name="name">Event/Report Registration: multi-company</field>
<field name="model_id" ref="model_report_event_registration"/>
<field name="global" eval="True"/>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
<field name="domain_force">['|',
('company_id', '=', False),
('company_id', 'child_of', [user.company_id.id]),
]
</field>
</record>
</data>

View File

@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
# Copyright (C) 2004-TODAY OpenERP SA (<http://www.openerp.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -18,5 +18,3 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import event

View File

@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
# Copyright (C) 2004-TODAY OpenERP SA (<http://www.openerp.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -30,11 +30,13 @@ This module adds event menu and features to your portal if event and portal are
==========================================================================================
""",
'author': 'OpenERP SA',
'depends': ['event','portal'],
'depends': [
'event',
'portal',
],
'data': [
'event_view.xml',
'security/portal_security.xml',
'portal_event_view.xml',
'security/portal_security.xml',
'security/ir.model.access.csv',
],
'installable': True,

View File

@ -1,39 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import fields, osv
class event_event(osv.osv):
_description = 'Portal event'
_inherit = 'event.event'
"""
``visibility``: defines if the event appears on the portal's event page
- 'public' means the event will appear for everyone (anonymous)
- 'private' means the event won't appear
"""
_columns = {
'visibility': fields.selection([('public', 'Public'),('private', 'Private')],
string='Visibility', help='Event\'s visibility in the portal\'s contact page'),
}
_defaults = {
'visibility': 'private',
}

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- add visibility field to the event form view -->
<record id="view_event_form_portal" model="ir.ui.view">
<field name="name">portal.event.form</field>
<field name="model">event.event</field>
<field name="inherit_id" ref="event.view_event_form"/>
<field name="arch" type="xml">
<xpath expr="//page[last()]" position="after">
<page string="Portal Settings" groups="base.group_user">
<group>
<field name="visibility"/>
</group>
</page>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@ -2,17 +2,21 @@
<openerp>
<data noupdate="1">
<record id="portal_event_rule" model="ir.rule">
<field name="name">Portal Visible Events</field>
<field ref="event.model_event_event" name="model_id"/>
<field name="domain_force">['|', ('visibility', '=', 'public'), ('message_follower_ids','in', [user.partner_id.id])]</field>
<record model="ir.rule" id="event_portal_rule">
<field name="name">Event: portal and anonymous users: public only</field>
<field name="model_id" ref="event.model_event_event"/>
<field name="domain_force">['|',
('visibility', '=', 'public'),
('message_follower_ids', 'in', [user.partner_id.id])
]
</field>
<field name="groups" eval="[(4, ref('portal.group_portal')), (4, ref('portal.group_anonymous'))]"/>
</record>
<record id="portal_registration_rule" model="ir.rule">
<field name="name">Portal Personal Registrations</field>
<field ref="event.model_event_registration" name="model_id"/>
<field name="domain_force">[('user_id','=',user.id)]</field>
<record model="ir.rule" id="event_registration_portal_rule">
<field name="name">Event/Registration: portal and anonymous users: personal only</field>
<field name="model_id" ref="event.model_event_registration"/>
<field name="domain_force">[('user_id', '=', user.id)]</field>
<field name="groups" eval="[(4, ref('portal.group_portal')), (4, ref('portal.group_anonymous'))]"/>
</record>