[IMP] website_event: add link and information in event form view about the website visibility

bzr revid: chm@openerp.com-20131114091709-29td2zb01r9egrrt
This commit is contained in:
Christophe Matthieu 2013-11-14 10:17:09 +01:00
parent 8ae07d4cba
commit a7a33020a5
2 changed files with 22 additions and 1 deletions

View File

@ -34,6 +34,14 @@ class product(osv.osv):
class event(osv.osv):
_name = 'event.event'
_inherit = ['event.event','website.seo.metadata']
def _website_url(self, cr, uid, ids, field_name, arg, context=None):
res = dict.fromkeys(ids, '')
base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
for event in self.browse(cr, uid, ids, context=context):
res[event.id] = "%s/event/%s/" % (base_url, event.id)
return res
_columns = {
'twitter_hashtag': fields.char('Twitter Hashtag'),
'website_published': fields.boolean('Available in the website'),
@ -46,6 +54,7 @@ class event(osv.osv):
string='Website Messages',
help="Website communication history",
),
'website_url': fields.function(_website_url, string="Website url"),
}
_defaults = {
'website_published': False,
@ -76,7 +85,6 @@ class event(osv.osv):
if partner.address_id:
return self.browse(cr, SUPERUSER_ID, ids[0], context=context).address_id.google_map_link()
class sale_order_line(osv.osv):
_inherit = "sale.order.line"

View File

@ -7,6 +7,19 @@
<field name="model">event.event</field>
<field name="inherit_id" ref="event_sale.view_event_form"/>
<field name="arch" type="xml">
<!-- add state field in header -->
<xpath expr="//sheet" position="before">
<div class="oe_form_box_info oe_text_center">
<p attrs="{'invisible': [('website_published', '=', True)]}">
This event is <b>not available</b> for public user in your website.
</p>
<p attrs="{'invisible': [('website_published', '=', False)]}">
This event is <b>available</b> for public user in your website.
</p>
<p>Website view: <field class="oe_inline" name="website_url" widget="url"/></p>
</div>
</xpath>
<field name="organizer_id" position="after">
<field name="website_published"/>
</field>