diff --git a/addons/product/security/ir.model.access.csv b/addons/product/security/ir.model.access.csv index d4c4261bb8c..637c4b47a28 100644 --- a/addons/product/security/ir.model.access.csv +++ b/addons/product/security/ir.model.access.csv @@ -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 \ No newline at end of file diff --git a/addons/website_event/__init__.py b/addons/website_event/__init__.py new file mode 100644 index 00000000000..91898dc2123 --- /dev/null +++ b/addons/website_event/__init__.py @@ -0,0 +1,2 @@ +import controllers +import event \ No newline at end of file diff --git a/addons/website_event/__openerp__.py b/addons/website_event/__openerp__.py new file mode 100644 index 00000000000..f871094048a --- /dev/null +++ b/addons/website_event/__openerp__.py @@ -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, +} diff --git a/addons/website_event/controllers/__init__.py b/addons/website_event/controllers/__init__.py new file mode 100644 index 00000000000..8ee9bae18d9 --- /dev/null +++ b/addons/website_event/controllers/__init__.py @@ -0,0 +1 @@ +import main diff --git a/addons/website_event/controllers/main.py b/addons/website_event/controllers/main.py new file mode 100644 index 00000000000..532bead0d95 --- /dev/null +++ b/addons/website_event/controllers/main.py @@ -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/'], 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/'], 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" diff --git a/addons/website_event/event.py b/addons/website_event/event.py new file mode 100644 index 00000000000..a1f6b32081a --- /dev/null +++ b/addons/website_event/event.py @@ -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'), + } + diff --git a/addons/website_event/security/ir.model.access.csv b/addons/website_event/security/ir.model.access.csv new file mode 100644 index 00000000000..6bc81d1794d --- /dev/null +++ b/addons/website_event/security/ir.model.access.csv @@ -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 \ No newline at end of file diff --git a/addons/website_event/security/website_event.xml b/addons/website_event/security/website_event.xml new file mode 100644 index 00000000000..05014176217 --- /dev/null +++ b/addons/website_event/security/website_event.xml @@ -0,0 +1,15 @@ + + + + + event: Public + + [('website_published', '=', True)] + + + + + + + + diff --git a/addons/website_event/static/src/css/Makefile b/addons/website_event/static/src/css/Makefile new file mode 100644 index 00000000000..2694cc0791b --- /dev/null +++ b/addons/website_event/static/src/css/Makefile @@ -0,0 +1,2 @@ +sass: + sass --compass --trace -t expanded hr.sass hr.css diff --git a/addons/website_event/static/src/css/hr.sass b/addons/website_event/static/src/css/hr.sass new file mode 100644 index 00000000000..33ae61b5260 --- /dev/null +++ b/addons/website_event/static/src/css/hr.sass @@ -0,0 +1 @@ +@import "compass/css3" diff --git a/addons/website_event/static/src/js/website_event.js b/addons/website_event/static/src/js/website_event.js new file mode 100644 index 00000000000..54115172481 --- /dev/null +++ b/addons/website_event/static/src/js/website_event.js @@ -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"); + } + }); + }); +}); \ No newline at end of file diff --git a/addons/website_event/views/website_event.xml b/addons/website_event/views/website_event.xml new file mode 100644 index 00000000000..ec841cc7002 --- /dev/null +++ b/addons/website_event/views/website_event.xml @@ -0,0 +1,131 @@ + + + + + + + + header_website_event + + + + +
  • Events
  • +
    +
    +
    +
    + + footer_website_event + + + + +
  • Events
  • +
    +
    +
    +
    + + + + +
    +
    \ No newline at end of file diff --git a/addons/website_hr/__openerp__.py b/addons/website_hr/__openerp__.py index 5aa9c24d8fb..d0f938da4bb 100644 --- a/addons/website_hr/__openerp__.py +++ b/addons/website_hr/__openerp__.py @@ -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, diff --git a/addons/website_hr/controllers/main.py b/addons/website_hr/controllers/main.py index 57d41eddcb5..cf5d33325bc 100644 --- a/addons/website_hr/controllers/main.py +++ b/addons/website_hr/controllers/main.py @@ -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" diff --git a/addons/website_hr/hr.py b/addons/website_hr/hr.py index 3a661f56389..542e03e2a1c 100644 --- a/addons/website_hr/hr.py +++ b/addons/website_hr/hr.py @@ -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"), } diff --git a/addons/website_hr/security/ir.model.access.csv b/addons/website_hr/security/ir.model.access.csv new file mode 100644 index 00000000000..91c044e1964 --- /dev/null +++ b/addons/website_hr/security/ir.model.access.csv @@ -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 \ No newline at end of file diff --git a/addons/website_hr/security/website_hr.xml b/addons/website_hr/security/website_hr.xml new file mode 100644 index 00000000000..0b581fa600b --- /dev/null +++ b/addons/website_hr/security/website_hr.xml @@ -0,0 +1,15 @@ + + + + + hr_employee: Public + + [('website_published', '=', True)] + + + + + + + + diff --git a/addons/website_hr/static/src/js/hr.js b/addons/website_hr/static/src/js/hr.js index c7a609b0105..1d8e8deac03 100644 --- a/addons/website_hr/static/src/js/hr.js +++ b/addons/website_hr/static/src/js/hr.js @@ -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"); + } + }); + }); }); \ No newline at end of file diff --git a/addons/website_hr/views/website_hr.xml b/addons/website_hr/views/website_hr.xml index 356a9f2ba0d..66c380b176b 100644 --- a/addons/website_hr/views/website_hr.xml +++ b/addons/website_hr/views/website_hr.xml @@ -4,13 +4,13 @@ - + footer_website_hr -
  • Team
  • +
  • Team
  • @@ -21,27 +21,42 @@ diff --git a/addons/website_mail/controllers/main.py b/addons/website_mail/controllers/main.py index dd155eccf32..18fceb2ea7c 100644 --- a/addons/website_mail/controllers/main.py +++ b/addons/website_mail/controllers/main.py @@ -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) diff --git a/addons/website_mail/static/src/js/blog.js b/addons/website_mail/static/src/js/blog.js index 1588c7cd9b5..7d62d43ba5e 100644 --- a/addons/website_mail/static/src/js/blog.js +++ b/addons/website_mail/static/src/js/blog.js @@ -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"); diff --git a/addons/website_mail/views/website_mail.xml b/addons/website_mail/views/website_mail.xml index 5826e9593ce..6834b71d7e8 100644 --- a/addons/website_mail/views/website_mail.xml +++ b/addons/website_mail/views/website_mail.xml @@ -126,8 +126,14 @@ - Newer - Older + diff --git a/addons/website_sale/__init__.py b/addons/website_sale/__init__.py index e6dc1baf9d5..ce36211f7be 100644 --- a/addons/website_sale/__init__.py +++ b/addons/website_sale/__init__.py @@ -1,2 +1,3 @@ import controllers import pricelist +import product diff --git a/addons/website_sale/__openerp__.py b/addons/website_sale/__openerp__.py index 6565269b1b4..ace4505c1f5 100644 --- a/addons/website_sale/__openerp__.py +++ b/addons/website_sale/__openerp__.py @@ -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, diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 4d2733d75e6..bae6b8b0758 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -71,7 +71,7 @@ class Ecommerce(http.Controller): @http.route(['/shop', '/shop/category/'], 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: diff --git a/addons/website_sale/product.py b/addons/website_sale/product.py new file mode 100644 index 00000000000..c6f8da63613 --- /dev/null +++ b/addons/website_sale/product.py @@ -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'), + } \ No newline at end of file diff --git a/addons/website_sale/security/ecommerce.xml b/addons/website_sale/security/ecommerce.xml new file mode 100644 index 00000000000..b37578d41e0 --- /dev/null +++ b/addons/website_sale/security/ecommerce.xml @@ -0,0 +1,15 @@ + + + + + product: Public product + + [('website_published', '=', True), ("sale_ok", "=", True)] + + + + + + + + diff --git a/addons/website_sale/security/ir.model.access.csv b/addons/website_sale/security/ir.model.access.csv new file mode 100644 index 00000000000..8d41ba779d4 --- /dev/null +++ b/addons/website_sale/security/ir.model.access.csv @@ -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 \ No newline at end of file diff --git a/addons/website_sale/static/src/js/ecommerce.js b/addons/website_sale/static/src/js/ecommerce.js index a53a1451302..ed4581abf2b 100644 --- a/addons/website_sale/static/src/js/ecommerce.js +++ b/addons/website_sale/static/src/js/ecommerce.js @@ -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'); diff --git a/addons/website_sale/views/ecommerce.xml b/addons/website_sale/views/ecommerce.xml index 7a654f2cc6b..bc848ec18e5 100644 --- a/addons/website_sale/views/ecommerce.xml +++ b/addons/website_sale/views/ecommerce.xml @@ -16,6 +16,31 @@
    + + header_ecommerce + + + + +
  • &nbsp; &nbsp; &nbsp; My cart
  • +
  • Shop
  • +
    +
    +
    +
    + + + product.normal.form.inherit + product.product + + + + + + + + + @@ -88,10 +113,13 @@
    €
    - - +
    Product not published
    + + + +
    @@ -113,6 +141,10 @@ Product