I want to create a News-portal website:
By referring 'building a website'
My controllers.py
import logging
from openerp import http
_logger = logging.getLogger(__name__)
class Newsportal(http.Controller):
@http.route('/newsportal/newsportal/', auth='public', website=True)
def index(self, **kw):
Headings = http.request.env['news.headings']
return http.request.render('news_portal.index', {
'headings': Headings.search([])
})
@http.route('/newsportal/<model("news.headings"):heading>/', auth='public', website=True)
def description(self, heading):
return http.request.render('news_portal.description', {
'main_heading': heading
})
my templates.xml
<?xml version="1.0" encoding="utf-8" ?>
<openerp>
<data>
<template id="index">
<t t-call="website.layout">
<t t-set="title">Newsportal</t>
<div class="services">
<div class="container">
<t t-foreach="headings" t-as="heading">
<p><a t-attf-href="/newsportal/{{ slug(heading) }}">
<t t-esc="heading.name"/></a>
</p>
</t>
</div>
</div>
</t>
</template>
<template id="description">
<t t-call="website.layout">
<t t-set="title">Newsportal</t>
<div class="services">
<div class="services"/>
<div class="container">
<t t-foreach="main_heading" t-as="head_line">
<t t-esc="head_line.description"/>
</t>
</div>
<div class="container">
<t t-foreach="main_heading" t-as="head_line">
<t t-esc="head_line.short_des"/>
</t>
</div>
<div class="container">
<t t-foreach="main_heading" t-as="head_line">
<span t-field="head_line.image" t-field-options='{"widget": "image"}'/>
</t>
</div>
<div class="ad box">
<t t-foreach="main_heading" t-as="head_line">
<span t-field="head_line.image_box" t-field-options='{"widget": "image" , "position":"top-right"}'/>
</t>
</div>
</div>
</t>
</template>
</data>
</openerp>
my model.py
import openerp
from openerp import models, fields, api
class Headings(models.Model):
_name = 'news.headings'
name = fields.Char()
short_des = fields.Char()
description = fields.Char()
image = openerp.fields.Binary()
image_box = openerp.fields.Binary()
My view.xml
<?xml version="1.0" encoding="utf-8" ?>
<openerp>
<data>
<record id="news_form_view" model="ir.ui.view">
<field name="name">news.form.view</field>
<field name="model">news.headings</field>
<field name="view_mode">tree,form</field>
<field name="arch" type="xml">
<form>
<sheet>
<field name="name">Name</field>
<field name="short_des">Short Description</field>
<field name="image" widget='image' class="oe_avatar oe_right"/>
<field name="image_box" widget='image' class="oe_avatar oe_right"/>
<field name="description">Description</field>
</sheet>
</form>
</field>
</record>
<record id="action_news_headings" model="ir.actions.act_window">
<field name="name">Our Services</field>
<field name="res_model">news.headings</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem sequence="0" id="menu_newsportal" name="Newsportal"/>
<menuitem id="menu_newsportal_content" parent="menu_newsportal" name="Newsportal Management System"/>
<menuitem id="menu_newsportal_content_headings" parent="menu_newsportal_content" action="action_news_headings"/>
</data>
</openerp>
Any one can help?
What's the problem?