From 3c26ec305a6aa003a6d764048a82bd39a16e5792 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse <> Date: Thu, 4 Oct 2012 06:46:24 +0200 Subject: [PATCH 01/23] [IMP] mail: move the code from publisher_warranty to mail bzr revid: stw@openerp.com-20121004044624-hwa3kztl58zrjguh --- addons/mail/__init__.py | 1 + addons/mail/data/mail_data.xml | 14 +++++ addons/mail/mail_message.py | 2 +- addons/mail/update.py | 112 +++++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 addons/mail/update.py diff --git a/addons/mail/__init__.py b/addons/mail/__init__.py index 92e882ae6d8..abf714ad534 100644 --- a/addons/mail/__init__.py +++ b/addons/mail/__init__.py @@ -33,6 +33,7 @@ import report import wizard import res_config import mail_group_menu +import update # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index 5fe1ee45b1d..522cbe8c7a7 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -13,6 +13,20 @@ + + Update Notification + + + 1 + weeks + -1 + + + + + 1000 + + comment diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index bbf68509277..9c873a31097 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -504,7 +504,7 @@ class mail_message(osv.Model): if not values.get('message_id') and values.get('res_id') and values.get('model'): values['message_id'] = tools.generate_tracking_message_id('%(model)s-%(res_id)s' % values) newid = super(mail_message, self).create(cr, uid, values, context) - self._notify(cr, 1, newid, context=context) + self._notify(cr, SUPERUSER_ID, newid, context=context) return newid def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'): diff --git a/addons/mail/update.py b/addons/mail/update.py new file mode 100644 index 00000000000..0e10ee0a7f1 --- /dev/null +++ b/addons/mail/update.py @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- +import datetime +import logging +import sys +import urllib +import urllib2 + +import pooler +import release +from osv import osv, fields +from tools.translate import _ +from tools.safe_eval import safe_eval +from tools.config import config +from tools import misc + +_logger = logging.getLogger(__name__) + +""" +Time interval that will be used to determine up to which date we will +check the logs to see if a message we just received was already logged. +@type: datetime.timedelta +""" +_PREVIOUS_LOG_CHECK = datetime.timedelta(days=365) + +def get_sys_logs(cr, uid): + """ + Utility method to send a publisher warranty get logs messages. + """ + pool = pooler.get_pool(cr.dbname) + + dbuuid = pool.get('ir.config_parameter').get_param(cr, uid, 'database.uuid') + db_create_date = pool.get('ir.config_parameter').get_param(cr, uid, 'database.create_date') + limit_date = datetime.datetime.now() + limit_date = limit_date - datetime.timedelta(15) + limit_date_str = limit_date.strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT) + nbr_users = pool.get("res.users").search(cr, uid, [], count=True) + nbr_active_users = pool.get("res.users").search(cr, uid, [("date", ">=", limit_date_str)], count=True) + nbr_share_users = False + nbr_active_share_users = False + if "share" in pool.get("res.users")._all_columns: + nbr_share_users = pool.get("res.users").search(cr, uid, [("share", "=", True)], count=True) + nbr_active_share_users = pool.get("res.users").search(cr, uid, [("share", "=", True), ("date", ">=", limit_date_str)], count=True) + user = pool.get("res.users").browse(cr, uid, uid) + msg = { + "dbuuid": dbuuid, + "nbr_users": nbr_users, + "nbr_active_users": nbr_active_users, + "nbr_share_users": nbr_share_users, + "nbr_active_share_users": nbr_active_share_users, + "dbname": cr.dbname, + "db_create_date": db_create_date, + "version": release.version, + "language": user.lang, + } + msg.update(pool.get("res.company").read(cr,uid,[1],["name","email","phone"])[0]) + + add_arg = {"timeout":30} if sys.version_info >= (2,6) else {} + arguments = {'arg0': msg, "action": "update",} + arguments_raw = urllib.urlencode(arguments) + + url = config.get("publisher_warranty_url") + uo = urllib2.urlopen(url, arguments_raw, **add_arg) + result = {} + try: + submit_result = uo.read() + result = safe_eval(submit_result) + finally: + uo.close() + return result + +class publisher_warranty_contract(osv.osv): + _name = "publisher_warranty.contract" + + def update_notification(self, cr, uid, ids, cron_mode=True, context=None): + """ + Send a message to OpenERP's publisher warranty server to check the + validity of the contracts, get notifications, etc... + + @param cron_mode: If true, catch all exceptions (appropriate for usage in a cron). + @type cron_mode: boolean + """ + try: + try: + result = get_sys_logs(cr, uid) + except Exception: + if cron_mode: # we don't want to see any stack trace in cron + return False + _logger.debug("Exception while sending a get logs messages", exc_info=1) + raise osv.except_osv(_("Error"), _("Error during communication with the publisher warranty server.")) + limit_date = (datetime.datetime.now() - _PREVIOUS_LOG_CHECK).strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT) + # old behavior based on res.log; now on mail.message, that is not necessarily installed + proxy = self.pool.get('mail.message') + + model, res_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', 'group_all_employees') + + for message in result["messages"]: + values = { + 'body' : message, + 'model' : 'mail.group', + 'res_id' : res_id, + 'user_id' : False, + } + proxy.create(cr, uid, values, context=context) + except Exception: + if cron_mode: + return False # we don't want to see any stack trace in cron + else: + raise + return True + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + From 5562530ea513164ba6dc9caa8f2019c110057aa9 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Thu, 4 Oct 2012 19:02:46 +0530 Subject: [PATCH 02/23] [IMP]Remove add_last for on_write_completed bzr revid: vja@tinyerp.com-20121004133246-4atym1p9ib59kgk4 --- addons/web/static/src/js/view_form.js | 9 +++------ addons/web_gantt/static/src/js/gantt.js | 4 +--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 1c32d5ef63e..b6ccc196afd 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2893,7 +2893,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc title: _t("Open: ") + self.string } ); - pop.on_write_completed.add_last(function() { + pop.on('on_write_complete',self,function(){ self.display_value = {}; self.render_value(); self.focus(); @@ -4038,9 +4038,7 @@ instance.web.form.Many2ManyListView = instance.web.ListView.extend(/** @lends in title: _t("Open: ") + this.m2m_field.string, readonly: this.getParent().get("effective_readonly") }); - pop.on_write_completed.add_last(function() { - self.reload_content(); - }); + pop.on('on_write_complete',self,self.reload_content); } }); @@ -4287,7 +4285,7 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ }; this.dataset.write_function = function(id, data, options, sup) { var fct = self.options.write_function || sup; - return fct.call(this, id, data, options).then(self.on_write_completed); + return fct.call(this, id, data, options).then(function(){self.trigger('on_write_complete',self)}); }; this.dataset.parent_view = this.options.parent_view; this.dataset.child_name = this.options.child_name; @@ -4307,7 +4305,6 @@ instance.web.form.AbstractFormPopup = instance.web.Widget.extend({ this.$buttonpane = dialog.$el.dialog("widget").find(".ui-dialog-buttonpane").html(""); this.start(); }, - on_write_completed: function() {}, setup_form_view: function() { var self = this; if (this.row_id) { diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index 00e057258f1..0d600712d4a 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -211,9 +211,7 @@ instance.web_gantt.GanttView = instance.web.View.extend({ on_task_display: function(task) { var self = this; var pop = new instance.web.form.FormOpenPopup(self); - pop.on_write_completed.add_last(function() { - self.reload(); - }); + pop.on('on_write_complete',self,self.reload); pop.show_element( self.dataset.model, task.id, From 1a84478f61f5fa5a04cfcd6a785e4207f355f9ac Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Thu, 4 Oct 2012 16:38:41 +0200 Subject: [PATCH 03/23] [IMP] remove whitespaces bzr revid: abo@openerp.com-20121004143841-h1vjvn87nsvfvxnt --- addons/base_calendar/crm_meeting.py | 2 -- addons/base_calendar/crm_meeting_view.xml | 4 ++-- addons/event/event_view.xml | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/addons/base_calendar/crm_meeting.py b/addons/base_calendar/crm_meeting.py index b87114f3a66..80c8f54d52b 100644 --- a/addons/base_calendar/crm_meeting.py +++ b/addons/base_calendar/crm_meeting.py @@ -115,5 +115,3 @@ class crm_meeting(base_state, osv.Model): def case_close_send_note(self, cr, uid, ids, context=None): return self.message_post(cr, uid, ids, body=_("Meeting completed."), context=context) - - diff --git a/addons/base_calendar/crm_meeting_view.xml b/addons/base_calendar/crm_meeting_view.xml index adcfc23a520..aff3aa2d6cb 100644 --- a/addons/base_calendar/crm_meeting_view.xml +++ b/addons/base_calendar/crm_meeting_view.xml @@ -73,7 +73,7 @@
-

@@ -299,7 +299,7 @@ {"calendar_default_user_id": uid}

- Click to schedule a new meeting. + Click to schedule a new meeting.

The calendar is shared between employees and fully integrated with other applications such as the employee holidays or the business diff --git a/addons/event/event_view.xml b/addons/event/event_view.xml index 6ad8fb20467..508bbb12bc5 100644 --- a/addons/event/event_view.xml +++ b/addons/event/event_view.xml @@ -1,7 +1,7 @@ - + event.registration form From ec563e56da3ab5f2168f43c65dcd336b310ebc23 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Thu, 4 Oct 2012 16:40:15 +0200 Subject: [PATCH 04/23] [IMP] meeting form view bzr revid: abo@openerp.com-20121004144015-17nkeu5akjy3l31a --- addons/base_calendar/crm_meeting_view.xml | 84 ++++++++++++----------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/addons/base_calendar/crm_meeting_view.xml b/addons/base_calendar/crm_meeting_view.xml index aff3aa2d6cb..140f49cdcfc 100644 --- a/addons/base_calendar/crm_meeting_view.xml +++ b/addons/base_calendar/crm_meeting_view.xml @@ -116,9 +116,49 @@ - - + + + + + +

+ + +
+
- - + calendar.attendee.tree calendar.attendee @@ -73,8 +71,7 @@
- - + calendar.attendee.search calendar.attendee @@ -110,18 +107,16 @@ {'default_sent_by_uid': uid} - + - - - + res.alarm.form res.alarm @@ -140,8 +135,7 @@ - - + res.alarm.tree res.alarm @@ -171,15 +165,13 @@ - - + - - + Event Form calendar.event @@ -334,8 +326,7 @@ - - + Event Tree calendar.event @@ -352,8 +343,7 @@ - - + Events Calendar calendar.event @@ -367,8 +357,7 @@ - - + Calendar Events Search calendar.event @@ -393,8 +382,7 @@ - - + Events ir.actions.act_window @@ -404,8 +392,7 @@ - - + diff --git a/addons/base_calendar/crm_meeting.py b/addons/base_calendar/crm_meeting.py index 80c8f54d52b..9ceaea671ca 100644 --- a/addons/base_calendar/crm_meeting.py +++ b/addons/base_calendar/crm_meeting.py @@ -43,14 +43,14 @@ class crm_meeting(base_state, osv.Model): _name = 'crm.meeting' _description = "Meeting" _order = "id desc" - _inherit = ["calendar.event", "mail.thread", 'ir.needaction_mixin'] + _inherit = ["calendar.event", "mail.thread", "ir.needaction_mixin"] _columns = { # base_state required fields 'create_date': fields.datetime('Creation Date', readonly=True), 'write_date': fields.datetime('Write Date', readonly=True), 'date_open': fields.datetime('Confirmed', readonly=True), 'date_closed': fields.datetime('Closed', readonly=True), - 'partner_ids': fields.many2many('res.partner', 'crm_meeting_partner_rel', 'meeting_id','partner_id', + 'partner_ids': fields.many2many('res.partner', 'crm_meeting_partner_rel', 'meeting_id', 'partner_id', string='Attendees', states={'done': [('readonly', True)]}), 'state': fields.selection( [('draft', 'Unconfirmed'), ('open', 'Confirmed')], From def9d0dabfbcb72c97ceed06265adc86f6ff9c5c Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Fri, 5 Oct 2012 16:54:13 +0200 Subject: [PATCH 06/23] [IMP] meeting form view: when 'recurrency' is checked, the recurrency options are required bzr revid: abo@openerp.com-20121005145413-7yyc3rr6ecx3ofu5 --- addons/base_calendar/crm_meeting_view.xml | 69 +++++++++++------------ 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/addons/base_calendar/crm_meeting_view.xml b/addons/base_calendar/crm_meeting_view.xml index 140f49cdcfc..37797a012aa 100644 --- a/addons/base_calendar/crm_meeting_view.xml +++ b/addons/base_calendar/crm_meeting_view.xml @@ -15,9 +15,9 @@ action_crm_meeting_read - + action - + crm.meeting client_action_multi @@ -33,9 +33,9 @@ action_crm_meeting_unread - + action - + crm.meeting client_action_multi @@ -124,38 +124,38 @@