diff --git a/addons/crm/wizard/crm_lead_to_opportunity.py b/addons/crm/wizard/crm_lead_to_opportunity.py index d9380ff774d..73b329cf0f0 100644 --- a/addons/crm/wizard/crm_lead_to_opportunity.py +++ b/addons/crm/wizard/crm_lead_to_opportunity.py @@ -112,10 +112,11 @@ class crm_lead2opportunity_partner(osv.osv_memory): res = False lead_ids = vals.get('lead_ids', []) team_id = vals.get('section_id', False) + partner_id = vals.get('partner_id') data = self.browse(cr, uid, ids, context=context)[0] leads = lead.browse(cr, uid, lead_ids, context=context) for lead_id in leads: - partner_id = self._create_partner(cr, uid, lead_id.id, data.action, lead_id.partner_id.id, context=context) + partner_id = self._create_partner(cr, uid, lead_id.id, data.action, partner_id or lead_id.partner_id.id, context=context) res = lead.convert_opportunity(cr, uid, [lead_id.id], partner_id, [], False, context=context) user_ids = vals.get('user_ids', False) if context.get('no_force_assignation'): @@ -138,18 +139,26 @@ class crm_lead2opportunity_partner(osv.osv_memory): w = self.browse(cr, uid, ids, context=context)[0] opp_ids = [o.id for o in w.opportunity_ids] + vals = { + 'section_id': w.section_id.id, + } + if w.partner_id: + vals['partner_id'] = w.partner_id.id if w.name == 'merge': lead_id = lead_obj.merge_opportunity(cr, uid, opp_ids, context=context) lead_ids = [lead_id] lead = lead_obj.read(cr, uid, lead_id, ['type', 'user_id'], context=context) if lead['type'] == "lead": context = dict(context, active_ids=lead_ids) - self._convert_opportunity(cr, uid, ids, {'lead_ids': lead_ids, 'user_ids': [w.user_id.id], 'section_id': w.section_id.id}, context=context) + vals.update({'lead_ids': lead_ids, 'user_ids': [w.user_id.id]}) + self._convert_opportunity(cr, uid, ids, vals, context=context) elif not context.get('no_force_assignation') or not lead['user_id']: - lead_obj.write(cr, uid, lead_id, {'user_id': w.user_id.id, 'section_id': w.section_id.id}, context=context) + vals.update({'user_id': w.user_id.id}) + lead_obj.write(cr, uid, lead_id, vals, context=context) else: lead_ids = context.get('active_ids', []) - self._convert_opportunity(cr, uid, ids, {'lead_ids': lead_ids, 'user_ids': [w.user_id.id], 'section_id': w.section_id.id}, context=context) + vals.update({'lead_ids': lead_ids, 'user_ids': [w.user_id.id]}) + self._convert_opportunity(cr, uid, ids, vals, context=context) return self.pool.get('crm.lead').redirect_opportunity_view(cr, uid, lead_ids[0], context=context) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index f685971f4b2..1f7e888dbd8 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -369,6 +369,16 @@ openerp.mail = function (session) { this.is_log = false; this.recipients = []; this.recipient_ids = []; + session.web.bus.on('clear_uncommitted_changes', this, function(e) { + if (this.show_composer && !e.isDefaultPrevented()){ + if (!confirm(_t("You are currently composing a message, your message will be discarded.\n\nAre you sure you want to leave this page ?"))) { + e.preventDefault(); + } + else{ + this.on_cancel(); + } + } + }); }, start: function () { diff --git a/openerp/addons/base/res/res_lang.py b/openerp/addons/base/res/res_lang.py index 59ec5703432..0a6f784189c 100644 --- a/openerp/addons/base/res/res_lang.py +++ b/openerp/addons/base/res/res_lang.py @@ -127,6 +127,15 @@ class lang(osv.osv): return False return True + def _check_grouping(self, cr, uid, ids, context=None): + for lang in self.browse(cr, uid, ids, context=context): + try: + if not all(isinstance(x, int) for x in eval(lang.grouping)): + return False + except Exception: + return False + return True + def _get_default_date_format(self, cursor, user, context=None): return '%m/%d/%Y' @@ -162,7 +171,8 @@ class lang(osv.osv): ] _constraints = [ - (_check_format, 'Invalid date/time format directive specified. Please refer to the list of allowed directives, displayed when you edit a language.', ['time_format', 'date_format']) + (_check_format, 'Invalid date/time format directive specified. Please refer to the list of allowed directives, displayed when you edit a language.', ['time_format', 'date_format']), + (_check_grouping, "The Separator Format should be like [,n] where 0 < n :starting from Unit digit.-1 will end the separation. e.g. [3,2,-1] will represent 106500 to be 1,06,500;[1,2,-1] will represent it to be 106,50,0;[3] will represent it as 106,500. Provided ',' as the thousand separator in each case.", ['grouping']) ] @tools.ormcache(skiparg=3) diff --git a/openerp/tools/translate.py b/openerp/tools/translate.py index 69837402535..abc5a3758f9 100644 --- a/openerp/tools/translate.py +++ b/openerp/tools/translate.py @@ -358,6 +358,7 @@ class TinyPoFile(object): source = unquote(line[6:]) line = self.lines.pop(0).strip() if not source and self.first: + self.first = False # if the source is "" and it's the first msgid, it's the special # msgstr with the informations about the traduction and the # traductor; we skip it @@ -387,8 +388,6 @@ class TinyPoFile(object): if t == trans_type == 'code': continue self.extra_lines.append((t, n, r, source, trad, comments)) - self.first = False - if name is None: if not fuzzy: self.warn('Missing "#:" formated comment at line %d for the following source:\n\t%s',