[MERGE] trunk-website-insomniak-chm
bzr revid: chm@openerp.com-20130805094805-c5y9nklobngdcvz4
This commit is contained in:
@@ -17,4 +17,4 @@ access_product_pricelist_partner_manager,product.pricelist partner manager,model
|
||||
access_product_product_employee,product.product employee,model_product_product,base.group_user,1,0,0,0
|
||||
access_product_template_sale_manager,product.template salemanager,model_product_template,base.group_sale_manager,1,1,1,1
|
||||
access_product_product_sale_manager,product.product salemanager,model_product_product,base.group_sale_manager,1,1,1,1
|
||||
access_product_category_sale_manager,product.category salemanager,product.model_product_category,base.group_sale_manager,1,1,1,1
|
||||
access_product_category_sale_manager,product.category salemanager,product.model_product_category,base.group_sale_manager,1,1,1,1
|
||||
|
@@ -0,0 +1,2 @@
|
||||
import controllers
|
||||
import event
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
'name': 'Website Event',
|
||||
'category': 'mail',
|
||||
'version': '1.0',
|
||||
'description': """
|
||||
OpenERP Blog
|
||||
============
|
||||
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'depends': ['website', 'event'],
|
||||
'data': [
|
||||
'views/website_event.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'security/website_event.xml',
|
||||
],
|
||||
'qweb': ['static/src/xml/*.xml'],
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
import main
|
||||
@@ -0,0 +1,95 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp.addons.web import http
|
||||
from openerp.addons.web.http import request
|
||||
from openerp.addons.website import website
|
||||
from openerp.tools.translate import _
|
||||
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from openerp import tools
|
||||
|
||||
class website_hr(http.Controller):
|
||||
|
||||
@http.route(['/event', '/event/search/<path:searches>'], type='http', auth="public")
|
||||
def events(self, searches=None, **post):
|
||||
data_obj = request.registry['event.event']
|
||||
|
||||
_search = {}
|
||||
for search in searches.split("/"):
|
||||
search = search.split("-")
|
||||
if len(search) == 2:
|
||||
_search[search[0]] = [search[1], []]
|
||||
|
||||
def sd(date):
|
||||
return date.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
today = datetime.today()
|
||||
dates = [
|
||||
['all', _('All Dates'), [(1, "=", 1)], 0],
|
||||
['today', _('Today'), [
|
||||
("date_begin", ">", sd(today)),
|
||||
("date_begin", "<", sd(today + relativedelta(days=1)))],
|
||||
0],
|
||||
['tomorrow', _('Tomorrow'), [
|
||||
("date_begin", ">", sd(today + relativedelta(days=1))),
|
||||
("date_begin", "<", sd(today + relativedelta(days=2)))],
|
||||
0],
|
||||
['week', _('This Week'), [
|
||||
("date_begin", ">=", sd(today + relativedelta(days=-today.weekday()))),
|
||||
("date_begin", "<", sd(today + relativedelta(days=6-today.weekday())))],
|
||||
0],
|
||||
['nextweek', _('Next Week'), [
|
||||
("date_begin", ">=", sd(today + relativedelta(days=7-today.weekday()))),
|
||||
("date_begin", "<", sd(today + relativedelta(days=13-today.weekday())))],
|
||||
0],
|
||||
['month', _('This month'), [
|
||||
("date_begin", ">=", sd(today.replace(day=1) + relativedelta(months=1))),
|
||||
("date_begin", "<", sd(today.replace(day=1) + relativedelta(months=1)))],
|
||||
0],
|
||||
]
|
||||
|
||||
# search domains
|
||||
for date in dates:
|
||||
if _search.get("date") and _search["date"][0] == date[0]:
|
||||
_search["date"].append(date[2])
|
||||
|
||||
# count by domains without self search
|
||||
for date in dates:
|
||||
domain = [(1, "=", 1)]
|
||||
for key, search in _search.items():
|
||||
if key != 'date':
|
||||
domain += search[1]
|
||||
date[3] = data_obj.search(request.cr, request.uid, domain + date[2], count=True)
|
||||
|
||||
# domain and search_path
|
||||
domain = [(1, "=", 1)]
|
||||
search_path = '/search'
|
||||
for key, search in _search.items():
|
||||
search_path = "%s/%s-%s" % (search_path, key, search[0])
|
||||
domain += search[1]
|
||||
|
||||
obj_ids = data_obj.search(request.cr, request.uid, domain)
|
||||
values = {
|
||||
'event_ids': data_obj.browse(request.cr, request.uid, obj_ids),
|
||||
'dates': dates,
|
||||
'search': _search,
|
||||
'search_path': search_path,
|
||||
}
|
||||
|
||||
html = website.render("website_event.index", values)
|
||||
return html
|
||||
|
||||
@http.route(['/event/<int:event_id>'], type='http', auth="public")
|
||||
def event(self, event_id=None, **post):
|
||||
return ""
|
||||
|
||||
@http.route(['/event/publish'], type='http', auth="public")
|
||||
def publish(self, **post):
|
||||
obj_id = int(post['id'])
|
||||
data_obj = request.registry['event.event']
|
||||
|
||||
obj = data_obj.browse(request.cr, request.uid, obj_id)
|
||||
data_obj.write(request.cr, request.uid, [obj_id], {'website_published': not obj.website_published})
|
||||
obj = data_obj.browse(request.cr, request.uid, obj_id)
|
||||
|
||||
return obj.website_published and "1" or "0"
|
||||
@@ -0,0 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp.osv import osv, fields
|
||||
|
||||
|
||||
class event(osv.osv):
|
||||
_inherit = 'event.event'
|
||||
_columns = {
|
||||
'website_published': fields.boolean('Available in the website'),
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_event_event_public,event.event.public,event.model_event_event,base.group_public,1,0,0,0
|
||||
|
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="event_event_public" model="ir.rule">
|
||||
<field name="name">event: Public</field>
|
||||
<field name="model_id" ref="event.model_event_event"/>
|
||||
<field name="domain_force">[('website_published', '=', True)]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_public'))]"/>
|
||||
<field name="perm_read" eval="True"/>
|
||||
<field name="perm_write" eval="False"/>
|
||||
<field name="perm_create" eval="False"/>
|
||||
<field name="perm_unlink" eval="False"/>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -0,0 +1,2 @@
|
||||
sass:
|
||||
sass --compass --trace -t expanded hr.sass hr.css
|
||||
@@ -0,0 +1 @@
|
||||
@import "compass/css3"
|
||||
@@ -0,0 +1,18 @@
|
||||
$(document).ready(function () {
|
||||
$(document).on('click', '.js_publish, .js_unpublish', function (e) {
|
||||
e.preventDefault();
|
||||
var $link = $(this).parent();
|
||||
$link.find('.js_publish, .js_unpublish').addClass("hidden");
|
||||
var $unp = $link.find(".js_unpublish");
|
||||
var $p = $link.find(".js_publish");
|
||||
$.post('/event/publish', {'id': $link.data('id')}, function (result) {
|
||||
if (+result) {
|
||||
$p.addClass("hidden");
|
||||
$unp.removeClass("hidden");
|
||||
} else {
|
||||
$p.removeClass("hidden");
|
||||
$unp.addClass("hidden");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Layout add nav and footer -->
|
||||
|
||||
<record id="header_website_event" model="ir.ui.view">
|
||||
<field name="name">header_website_event</field>
|
||||
<field name="inherit_id" ref="website.header"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="(//li)[last()]" position="after">
|
||||
<li class="pull-right"><a href="/event">Events</a></li>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
<record id="footer_website_event" model="ir.ui.view">
|
||||
<field name="name">footer_website_event</field>
|
||||
<field name="inherit_id" ref="website.footer"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//a[@href='/page/website.contactus']" position="after">
|
||||
<li><a href="/event">Events</a></li>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Page -->
|
||||
|
||||
<template id="index">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="head">
|
||||
<script type="text/javascript" src="/website_event/static/src/js/website_event.js"></script>
|
||||
<t t-raw="head"/>
|
||||
</t>
|
||||
<t t-set="title">Events</t>
|
||||
<div class="container mt48">
|
||||
<div class="row">
|
||||
<div class="span4 css_noprint">
|
||||
<ul class="nav nav-list">
|
||||
<li class="nav-header">Date</li>
|
||||
<t t-foreach="dates" t-as="date">
|
||||
<li t-att-class="search.get('date')[0] == date[0] and 'active' or ''">
|
||||
<a t-att-href="'/event%%s/date-%%s' %% (search_path, date[0])"><t t-esc="date[1]"/> <small t-if="date[3]">(<t t-esc="date[3]"/>)</small></a>
|
||||
</li>
|
||||
</t>
|
||||
</ul>
|
||||
<ul class="nav nav-list">
|
||||
<li class="nav-header">Category</li>
|
||||
<li class="active">
|
||||
<a >All Categories <span>(27)</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a >Conferences <span>(18)</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a >Business <span>(18)</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a>Classes <span>(9)</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav nav-list">
|
||||
<li class="nav-header">Location</li>
|
||||
<li>
|
||||
<a>Ramillies <span>(7)</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a>Eindhoven <span>(6)</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a>Hasselt <span>(6)</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a>Herentals <span>(6)</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a>Geel <span>(2)</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="span8">
|
||||
<ul class="media-list mt32">
|
||||
<t t-foreach="event_ids" t-as="event_id">
|
||||
<li class="media thumbnail">
|
||||
<div class="media-body">
|
||||
<t t-if="event_id.register_avail">
|
||||
<t t-if="event_id.register_avail == 9999">
|
||||
<span class="label pull-right">No ticket available.</span>
|
||||
</t>
|
||||
<span t-if="event_id.register_avail != 9999" t-att-class="'label pull-right label-%%s' %% (event_id.register_avail <= 10 and 'warning' or 'info')">
|
||||
<t t-if="event_id.register_avail <= 10">Only</t>
|
||||
<t t-esc="event_id.register_avail"/>
|
||||
<t t-if="event_id.register_avail > 1">tickets </t>
|
||||
<t t-if="event_id.register_avail == 1">ticket </t>
|
||||
available.
|
||||
</span>
|
||||
</t>
|
||||
<h4 class="media-heading"><a t-att-href="'event/%%s' %% event_id.id"><span t-record="event_id" t-field="name"> </span></a></h4>
|
||||
<t t-if="editable">
|
||||
<a href="#" t-att-data-id="event_id.id" class="pull-right">
|
||||
<span t-att-class="'label label-success js_unpublish %%s' %% (not event_id.website_published and 'hidden' or '')">Click to Unpublish</span>
|
||||
<span t-att-class="'label label-important js_publish %%s' %% (event_id.website_published and 'hidden' or '')">Click to Publish</span>
|
||||
</a>
|
||||
</t>
|
||||
<div>
|
||||
<span t-record="event_id" t-field="type">: </span>
|
||||
<t t-if="event_id.user_id">
|
||||
Organized by: <span t-record="event_id" t-field="user_id"> </span>
|
||||
</t>
|
||||
</div>
|
||||
<div>
|
||||
<i class="icon-time"></i> <span t-record="event_id" t-field="date_begin"> </span> <i>to</i> <span t-record="event_id" t-field="date_end"> </span>
|
||||
</div>
|
||||
<div t-if="event_id.country_id">
|
||||
<i class="icon-map-marker"></i> <span t-record="event_id" t-field="city"> </span> <span t-record="event_id" t-field="zip"> </span>, <span t-record="event_id" t-field="country_id"> </span>
|
||||
</div>
|
||||
<div t-record="event_id" t-field="note"> </div>
|
||||
</div>
|
||||
</li>
|
||||
</t>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -11,6 +11,8 @@ OpenERP Blog
|
||||
'depends': ['website', 'hr'],
|
||||
'data': [
|
||||
'views/website_hr.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'security/website_hr.xml',
|
||||
],
|
||||
'qweb': ['static/src/xml/*.xml'],
|
||||
'installable': True,
|
||||
|
||||
@@ -6,7 +6,7 @@ from openerp.addons.website import website
|
||||
|
||||
class website_hr(http.Controller):
|
||||
|
||||
@http.route(['/team'], type='http', auth="public")
|
||||
@http.route(['/hr'], type='http', auth="public")
|
||||
def blog(self, **post):
|
||||
hr_obj = request.registry['hr.employee']
|
||||
|
||||
@@ -17,3 +17,25 @@ class website_hr(http.Controller):
|
||||
|
||||
html = website.render("website_hr.index", values)
|
||||
return html
|
||||
|
||||
@http.route(['/hr/publish'], type='http', auth="public")
|
||||
def publish(self, **post):
|
||||
obj_id = int(post['id'])
|
||||
data_obj = request.registry['hr.employee']
|
||||
|
||||
obj = data_obj.browse(request.cr, request.uid, obj_id)
|
||||
data_obj.write(request.cr, request.uid, [obj_id], {'website_published': not obj.website_published})
|
||||
obj = data_obj.browse(request.cr, request.uid, obj_id)
|
||||
|
||||
return obj.website_published and "1" or "0"
|
||||
|
||||
@http.route(['/hr/publish_contact'], type='http', auth="public")
|
||||
def publish_contact(self, **post):
|
||||
obj_id = int(post['id'])
|
||||
data_obj = request.registry['hr.employee']
|
||||
|
||||
obj = data_obj.browse(request.cr, request.uid, obj_id)
|
||||
data_obj.write(request.cr, request.uid, [obj_id], {'website_published_on_contact_form': not obj.website_published_on_contact_form})
|
||||
obj = data_obj.browse(request.cr, request.uid, obj_id)
|
||||
|
||||
return obj.website_published_on_contact_form and "1" or "0"
|
||||
|
||||
@@ -6,6 +6,7 @@ from openerp.osv import osv, fields
|
||||
class hr(osv.osv):
|
||||
_inherit = 'hr.employee'
|
||||
_columns = {
|
||||
'website_important': fields.boolean('Publish', help="Publish also on contact form"),
|
||||
'website_published': fields.boolean('Available in the website'),
|
||||
'website_published_on_contact_form': fields.boolean('Publish', help="Publish also on contact form"),
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_hr_employee_public,hr.employee.public,hr.model_hr_employee,base.group_public,1,0,0,0
|
||||
|
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="hr_employee_public" model="ir.rule">
|
||||
<field name="name">hr_employee: Public</field>
|
||||
<field name="model_id" ref="hr.model_hr_employee"/>
|
||||
<field name="domain_force">[('website_published', '=', True)]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_public'))]"/>
|
||||
<field name="perm_read" eval="True"/>
|
||||
<field name="perm_write" eval="False"/>
|
||||
<field name="perm_create" eval="False"/>
|
||||
<field name="perm_unlink" eval="False"/>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,3 +1,34 @@
|
||||
$(document).ready(function () {
|
||||
|
||||
$(document).on('click', '.js_publish, .js_unpublish', function (e) {
|
||||
e.preventDefault();
|
||||
var $link = $(this).parent();
|
||||
$link.find('.js_publish, .js_unpublish').addClass("hidden");
|
||||
var $unp = $link.find(".js_unpublish");
|
||||
var $p = $link.find(".js_publish");
|
||||
$.post('/hr/publish', {'id': $link.data('id')}, function (result) {
|
||||
if (+result) {
|
||||
$p.addClass("hidden");
|
||||
$unp.removeClass("hidden");
|
||||
} else {
|
||||
$p.removeClass("hidden");
|
||||
$unp.addClass("hidden");
|
||||
}
|
||||
});
|
||||
});
|
||||
$(document).on('click', '.js_publish_contact, .js_unpublish_contact', function (e) {
|
||||
e.preventDefault();
|
||||
var $link = $(this).parent();
|
||||
$link.find('.js_publish_contact, .js_unpublish_contact').addClass("hidden");
|
||||
var $unp = $link.find(".js_unpublish_contact");
|
||||
var $p = $link.find(".js_publish_contact");
|
||||
$.post('/hr/publish_contact', {'id': $link.data('id')}, function (result) {
|
||||
if (+result) {
|
||||
$p.addClass("hidden");
|
||||
$unp.removeClass("hidden");
|
||||
} else {
|
||||
$p.removeClass("hidden");
|
||||
$unp.addClass("hidden");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -4,13 +4,13 @@
|
||||
|
||||
<!-- Layout add nav and footer -->
|
||||
|
||||
<record id="footer_hr_mail" model="ir.ui.view">
|
||||
<record id="footer_website_hr" model="ir.ui.view">
|
||||
<field name="name">footer_website_hr</field>
|
||||
<field name="inherit_id" ref="website.footer"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//a[@href='/page/website.contactus']" position="after">
|
||||
<li><a href="/team">Team</a></li>
|
||||
<li><a href="/hr">Team</a></li>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
@@ -21,27 +21,42 @@
|
||||
<template id="index">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="head">
|
||||
<script type="text/javascript" src="/website_mail/static/src/js/blog.js"></script>
|
||||
<link rel='stylesheet' href='/website_mail/static/src/css/blog.css'/>
|
||||
<script type="text/javascript" src="/website_hr/static/src/js/hr.js"></script>
|
||||
<t t-raw="head"/>
|
||||
</t>
|
||||
<t t-set="title">Team</t>
|
||||
<div class="container mt48">
|
||||
<ul class="media-list">
|
||||
<t t-foreach="employee_ids">
|
||||
<!-- TODO: check qweb iteration -->
|
||||
<li class="media pull-left">
|
||||
<div t-att-class="'media-body %%s' %% (website_important and 'css_important' or '')">
|
||||
<a href="#" t-att-data-id="id" class="js_important pull-right" groups="group_website_mail_manager">
|
||||
<span class="label label-success">Unpublish</span>
|
||||
<span class="label label-important">Publish</span>
|
||||
<div class="container">
|
||||
<div class="thumbnails">
|
||||
<t t-foreach="employee_ids" t-as="employee_id">
|
||||
<div class="span4 mt16">
|
||||
<div class="media thumbnail">
|
||||
<a class="pull-left" href="#">
|
||||
<img class="media-object" t-att-src="'data:image/png;base64,%%s' %% employee_id.image_small"/>
|
||||
</a>
|
||||
<t t-raw="image"/>
|
||||
<t t-raw="name"/>
|
||||
<div class="media-body">
|
||||
<t t-if="editable">
|
||||
<div class="pull-right">
|
||||
<a href="#" t-att-data-id="employee_id.id">
|
||||
<span t-att-class="'label label-success js_unpublish %%s' %% (not employee_id.website_published and 'hidden' or '')">Click to Unpublish</span>
|
||||
<span t-att-class="'label label-important js_publish %%s' %% (employee_id.website_published and 'hidden' or '')">Click to Publish</span>
|
||||
</a><br/>
|
||||
<a href="#" t-att-data-id="employee_id.id">
|
||||
<span t-att-class="'label label-success js_unpublish_contact %%s' %% (not employee_id.website_published and 'hidden' or '')">hidden on Contacts</span>
|
||||
<span t-att-class="'label label-important js_publish_contact %%s' %% (employee_id.website_published and 'hidden' or '')">display in Contacts</span>
|
||||
</a>
|
||||
</div>
|
||||
</t>
|
||||
<h5 class="media-heading"><t t-esc="employee_id.name"/></h5>
|
||||
<div t-record="employee_id" t-field="department_id"> </div>
|
||||
<div t-record="employee_id" t-field="job_id"> </div>
|
||||
<div t-record="employee_id" t-field="work_location"> </div>
|
||||
<div t-record="employee_id" t-field="work_phone"> </div>
|
||||
<div t-record="employee_id" t-field="work_email"> </div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</div>
|
||||
</t>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
@@ -62,7 +62,7 @@ class website_mail(http.Controller):
|
||||
|
||||
@http.route(['/blog/publish'], type='http', auth="public")
|
||||
def publish(self, **post):
|
||||
message_id = int(post['message_id'])
|
||||
message_id = int(post['id'])
|
||||
message_obj = request.registry['mail.message']
|
||||
|
||||
blog = message_obj.browse(request.cr, request.uid, message_id)
|
||||
|
||||
@@ -5,7 +5,7 @@ $(document).ready(function () {
|
||||
$link.find('.js_publish, .js_unpublish').addClass("hidden");
|
||||
var $unp = $link.find(".js_unpublish");
|
||||
var $p = $link.find(".js_publish");
|
||||
$.post('/blog/publish/', {'message_id': $link.data('id')}, function (result) {
|
||||
$.post('/blog/publish', {'id': $link.data('id')}, function (result) {
|
||||
if (+result) {
|
||||
$p.addClass("hidden");
|
||||
$unp.removeClass("hidden");
|
||||
|
||||
@@ -126,8 +126,14 @@
|
||||
</li>
|
||||
</t>
|
||||
</ul>
|
||||
<a t-if="prev_date" t-att-href="'?date=%%s' %% (prev_date)" class="pull-left">Newer</a>
|
||||
<a t-if="next_date" t-att-href="'?date=%%s' %% (next_date)" class="pull-right">Older</a>
|
||||
<ul class="pager">
|
||||
<li t-if="next_date" class="previous">
|
||||
<a t-att-href="'?date=%%s' %% (next_date)">&larr; Older</a>
|
||||
</li>
|
||||
<li t-if="prev_date" class="next">
|
||||
<a t-att-href="'?date=%%s' %% (prev_date)">Newer &rarr;</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
import controllers
|
||||
import pricelist
|
||||
import product
|
||||
|
||||
@@ -11,7 +11,9 @@ OpenERP E-Commerce
|
||||
'depends': ['website', 'sale', 'point_of_sale'],
|
||||
'data': [
|
||||
'views/ecommerce.xml',
|
||||
'views/pricelist.xml'
|
||||
'views/pricelist.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'security/ecommerce.xml',
|
||||
],
|
||||
'qweb': ['static/src/xml/*.xml'],
|
||||
'installable': True,
|
||||
|
||||
@@ -71,7 +71,7 @@ class Ecommerce(http.Controller):
|
||||
@http.route(['/shop', '/shop/category/<cat_id>'], type='http', auth="public")
|
||||
def category(self, cat_id=0, offset=0, **post):
|
||||
|
||||
domain = []
|
||||
domain = [("sale_ok", "=", True)]
|
||||
if post.get("search"):
|
||||
domain += ['|', '|', ('name', 'ilike', "%%%s%%" % post.get("search")), ('desrequest.cription', 'ilike', "%%%s%%" % post.get("search")), ('pos_categ_id.name', 'ilike', "%%%s%%" % post.get("search"))]
|
||||
if cat_id:
|
||||
@@ -79,11 +79,11 @@ class Ecommerce(http.Controller):
|
||||
domain = [('pos_categ_id.id', 'child_of', cat_id)] + domain
|
||||
|
||||
product_obj = request.registry.get('product.product')
|
||||
product_ids = product_obj.search(request.cr, openerp.SUPERUSER_ID, domain or [(1, '=', 1)], limit=20, offset=offset)
|
||||
product_ids = product_obj.search(request.cr, request.uid, domain, limit=20, offset=offset)
|
||||
|
||||
values = {
|
||||
'current_category': cat_id,
|
||||
'products': product_obj.browse(request.cr, openerp.SUPERUSER_ID, product_ids),
|
||||
'products': product_obj.browse(request.cr, request.uid, product_ids),
|
||||
'search': post.get("search"),
|
||||
}
|
||||
html = self.render("website_sale.products", values)
|
||||
@@ -314,4 +314,15 @@ class Ecommerce(http.Controller):
|
||||
}
|
||||
return self.render("website_sale.confirmed", values)
|
||||
|
||||
@http.route(['/shop/publish'], type='http', auth="public")
|
||||
def publish(self, **post):
|
||||
product_id = int(post['id'])
|
||||
product_obj = request.registry['product.product']
|
||||
|
||||
product = product_obj.browse(request.cr, request.uid, product_id)
|
||||
product_obj.write(request.cr, request.uid, [product_id], {'website_published': not product.website_published})
|
||||
product = product_obj.browse(request.cr, request.uid, product_id)
|
||||
|
||||
return product.website_published and "1" or "0"
|
||||
|
||||
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp.osv import osv, fields
|
||||
|
||||
|
||||
class product_pricelist(osv.osv):
|
||||
_inherit = "product.product"
|
||||
_columns = {
|
||||
'website_published': fields.boolean('Available in the website'),
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="product_product_public" model="ir.rule">
|
||||
<field name="name">product: Public product</field>
|
||||
<field name="model_id" ref="product.model_product_product"/>
|
||||
<field name="domain_force">[('website_published', '=', True), ("sale_ok", "=", True)]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_public'))]"/>
|
||||
<field name="perm_read" eval="True"/>
|
||||
<field name="perm_write" eval="False"/>
|
||||
<field name="perm_create" eval="False"/>
|
||||
<field name="perm_unlink" eval="False"/>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -0,0 +1,3 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_product_product_public,product.product.public,product.model_product_product,base.group_public,1,0,0,0
|
||||
access_point_of_sale_category_public,point_of_sale.category.public,point_of_sale.model_pos_category,base.group_public,1,0,0,0
|
||||
|
@@ -1,4 +1,21 @@
|
||||
$(document).ready(function () {
|
||||
$('.oe_ecommerce').on('click', '.js_publish, .js_unpublish', function (e) {
|
||||
e.preventDefault();
|
||||
var $link = $(this).parent();
|
||||
$link.find('.js_publish, .js_unpublish').addClass("hidden");
|
||||
var $unp = $link.find(".js_unpublish");
|
||||
var $p = $link.find(".js_publish");
|
||||
$.post('/shop/publish', {'id': $link.data('id')}, function (result) {
|
||||
if (+result) {
|
||||
$p.addClass("hidden");
|
||||
$unp.removeClass("hidden");
|
||||
} else {
|
||||
$p.removeClass("hidden");
|
||||
$unp.addClass("hidden");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.oe_ecommerce').on('click', '.oe_product .btn, .oe_product_detail .btn', function (e) {
|
||||
var $button = $(e.currentTarget);
|
||||
var $product = $button.parents('.oe_product:first, .oe_product_detail:first');
|
||||
|
||||
@@ -16,6 +16,31 @@
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
<record id="header_ecommerce" model="ir.ui.view">
|
||||
<field name="name">header_ecommerce</field>
|
||||
<field name="inherit_id" ref="website.header"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="(//li)[last()]" position="after">
|
||||
<li class="pull-right"><a href="/shop/mycart"><i class="icon-shopping-cart icon-large" style="position: absolute;"></i>&nbsp; &nbsp; &nbsp; My cart</a></li>
|
||||
<li class="pull-right"><a href="/shop">Shop</a></li>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="product_normal_form_view" model="ir.ui.view">
|
||||
<field name="name">product.normal.form.inherit</field>
|
||||
<field name="model">product.product</field>
|
||||
<field name="inherit_id" ref="stock.view_normal_procurement_locations_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<group name="sale" position="before">
|
||||
<group name="pos" string="Website">
|
||||
<field name="website_published"/>
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Page Shop -->
|
||||
|
||||
@@ -88,10 +113,13 @@
|
||||
<div class="oe_ecommerce_description" t-field="product.description_sale"><t t-esc="product.description_sale"/></div>
|
||||
<div class="oe_ecommerce_price"><span><span t-field="product.list_price"><t t-esc="product.list_price"/></span>€</span></div>
|
||||
<div class="oe_button_cart">
|
||||
<button t-att-class="'btn btn-small btn-inverse %%s' %% (not quantity and 'oe_hidden' or '')" t-att-data-id="product.id">Remove one</button>
|
||||
<button t-att-class="'btn btn-small %%s' %% (quantity and 'btn-success' or 'btn-primary')" t-att-data-id="product.id">Add to cart
|
||||
<span class="oe_txt">(<span class="oe_quantity"><t t-esc="quantity"/></span>)</span>
|
||||
</button>
|
||||
<div class="alert mb0" t-if="editable and not product.website_published">Product not published</div>
|
||||
<t t-if="product.website_published">
|
||||
<button t-att-class="'btn btn-small btn-inverse %%s' %% (not quantity and 'oe_hidden' or '')" t-att-data-id="product.id">Remove one</button>
|
||||
<button t-att-class="'btn btn-small %%s' %% (quantity and 'btn-success' or 'btn-primary')" t-att-data-id="product.id">Add to cart
|
||||
<span class="oe_txt">(<span class="oe_quantity"><t t-esc="quantity"/></span>)</span>
|
||||
</button>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -113,6 +141,10 @@
|
||||
<t t-set="title">Product</t>
|
||||
<t t-set="shop_content">
|
||||
<div class="oe_product_detail">
|
||||
<a href="#" t-att-data-id="product.id" class="pull-right" t-if="editable">
|
||||
<span t-att-class="'label label-success js_unpublish %%s' %% (not product.website_published and 'hidden' or '')">Click to Unpublish</span>
|
||||
<span t-att-class="'label label-important js_publish %%s' %% (product.website_published and 'hidden' or '')">Click to Publish</span>
|
||||
</a>
|
||||
<h1 t-field="product.name"></h1>
|
||||
<div class="oe_button_cart">
|
||||
<button t-att-class="'btn btn-inverse %%s' %% (not quantity and 'oe_hidden' or '')" t-att-data-id="product.id">Remove one</button>
|
||||
|
||||
Reference in New Issue
Block a user