Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

How can i customize website by adding my own theme

By
preethy
on 7/2/16, 7:12 AM 287 views

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?

Ermin Trevisan
on 7/3/16, 2:08 AM
0
preethy
On 7/4/16, 12:07 AM

Hai,

I want some news(flash news,politics ,sports,health etc) in front page. if any read more on that news, by clicking that news go to detail page(first problem). If i add an image from back end of size 256*256, i want a layout in front end to fix this image in a place (second problem). I want to control all these from back end (odoo 9).

give me suggestion?

I am doing my project in odoo 9. Can you help me ?

Can you please send me the code?


0

Ermin Trevisan

--Ermin Trevisan--
3524
| 6 3 7
Walchwil, Switzerland
--Ermin Trevisan--


Ermin Trevisan
On 7/4/16, 12:53 AM

I would sketch it in the frontend using the website builder and then look at the code in the HTML editor. I would not fix the image size, but instead using bootstraps columns and rows in order to keep your website responsive.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/2/16, 7:12 AM
Seen: 287 times
Last updated: 7/4/16, 5:12 AM