From 3b73e2b2a48f0e9b48256f97fa361156f58756c4 Mon Sep 17 00:00:00 2001 From: ggh-openerp Date: Mon, 29 Apr 2013 12:45:57 +0530 Subject: [IMP]Removed space before Exclamation marks [!] bzr revid: ggh@tinyerp.com-20130429071557-vnxo5nni03vc886j --- addons/base_status/base_state.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/base_status/base_state.py') diff --git a/addons/base_status/base_state.py b/addons/base_status/base_state.py index b856bbd74ad..3fe59ecbd21 100644 --- a/addons/base_status/base_state.py +++ b/addons/base_status/base_state.py @@ -104,7 +104,7 @@ class base_state(object): if parent_id.change_responsible and parent_id.user_id: data['user_id'] = parent_id.user_id.id else: - raise osv.except_osv(_('Error !'), _('You can not escalate, you are already at the top level regarding your sales-team category.')) + raise osv.except_osv(_('Error!'), _('You can not escalate, you are already at the top level regarding your sales-team category.')) self.write(cr, uid, [case.id], data, context=context) case.case_escalate_send_note(parent_id, context=context) return True -- cgit v1.2.3 From 319a222c7c494ae973e637bd54244c85580f3144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 13 Aug 2013 11:55:46 +0200 Subject: [REM] Removed base_status module. bzr revid: tde@openerp.com-20130813095546-knv3pq2ljznfvuv4 --- addons/base_status/base_state.py | 201 --------------------------------------- 1 file changed, 201 deletions(-) delete mode 100644 addons/base_status/base_state.py (limited to 'addons/base_status/base_state.py') diff --git a/addons/base_status/base_state.py b/addons/base_status/base_state.py deleted file mode 100644 index 3fe59ecbd21..00000000000 --- a/addons/base_status/base_state.py +++ /dev/null @@ -1,201 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-today OpenERP SA () -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from openerp.osv import fields, osv -from openerp.tools.translate import _ - -class base_state(object): - """ Base utility mixin class for objects willing to manage their state. - Object subclassing this class should define the following colums: - - ``date_open`` (datetime field) - - ``date_closed`` (datetime field) - - ``user_id`` (many2one to res.users) - - ``partner_id`` (many2one to res.partner) - - ``email_from`` (char field) - - ``state`` (selection field) - """ - - def _get_default_partner(self, cr, uid, context=None): - """ Gives id of partner for current user - :param context: if portal not in context returns False - """ - if context is None: - context = {} - if not context or not context.get('portal'): - return False - user = self.pool.get('res.users').browse(cr, uid, uid, context=context) - if hasattr(user, 'partner_address_id') and user.partner_address_id: - return user.partner_address_id - return user.company_id.partner_id.id - - def _get_default_email(self, cr, uid, context=None): - """ Gives default email address for current user - :param context: if portal not in context returns False - """ - if context is None: - context = {} - if not context or not context.get('portal'): - return False - user = self.pool.get('res.users').browse(cr, uid, uid, context=context) - return user.email - - def _get_default_user(self, cr, uid, context=None): - """ Gives current user id - :param context: if portal not in context returns False - """ - if context is None: - context = {} - if not context or not context.get('portal'): - return False - return uid - - def onchange_partner_address_id(self, cr, uid, ids, add, email=False): - """ This function returns value of partner email based on Partner Address - :param add: Id of Partner's address - :param email: Partner's email ID - """ - data = {'value': {'email_from': False, 'phone':False}} - if add: - address = self.pool.get('res.partner').browse(cr, uid, add) - data['value'] = {'email_from': address and address.email or False , - 'phone': address and address.phone or False} - if 'phone' not in self._columns: - del data['value']['phone'] - return data - - def onchange_partner_id(self, cr, uid, ids, part, email=False): - """ This function returns value of partner address based on partner - :param part: Partner's id - :param email: Partner's email ID - """ - data={} - if part: - addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['contact']) - data.update(self.onchange_partner_address_id(cr, uid, ids, addr['contact'])['value']) - return {'value': data} - - def case_escalate(self, cr, uid, ids, context=None): - """ Escalates case to parent level """ - cases = self.browse(cr, uid, ids, context=context) - cases[0].state # fill browse record cache, for _action having old and new values - data = {'active': True} - for case in cases: - parent_id = case.section_id.parent_id - if parent_id: - data['section_id'] = parent_id.id - if parent_id.change_responsible and parent_id.user_id: - data['user_id'] = parent_id.user_id.id - else: - raise osv.except_osv(_('Error!'), _('You can not escalate, you are already at the top level regarding your sales-team category.')) - self.write(cr, uid, [case.id], data, context=context) - case.case_escalate_send_note(parent_id, context=context) - return True - - def case_open(self, cr, uid, ids, context=None): - """ Opens case """ - cases = self.browse(cr, uid, ids, context=context) - for case in cases: - values = {'active': True} - if case.state == 'draft': - values['date_open'] = fields.datetime.now() - if not case.user_id: - values['user_id'] = uid - self.case_set(cr, uid, [case.id], 'open', values, context=context) - return True - - def case_close(self, cr, uid, ids, context=None): - """ Closes case """ - return self.case_set(cr, uid, ids, 'done', {'date_closed': fields.datetime.now()}, context=context) - - def case_cancel(self, cr, uid, ids, context=None): - """ Cancels case """ - return self.case_set(cr, uid, ids, 'cancel', {'active': True}, context=context) - - def case_pending(self, cr, uid, ids, context=None): - """ Sets case as pending """ - return self.case_set(cr, uid, ids, 'pending', {'active': True}, context=context) - - def case_reset(self, cr, uid, ids, context=None): - """ Resets case as draft """ - return self.case_set(cr, uid, ids, 'draft', {'active': True}, context=context) - - def case_set(self, cr, uid, ids, state_name, update_values=None, context=None): - """ Generic method for setting case. This methods wraps the update - of the record, as well as call to _action and browse_record - case setting to fill the cache. - - :params: state_name: the new value of the state, such as - 'draft' or 'close'. - :params: update_values: values that will be added with the state - update when writing values to the record. - """ - cases = self.browse(cr, uid, ids, context=context) - cases[0].state # fill browse record cache, for _action having old and new values - if update_values is None: - update_values = {} - update_values['state'] = state_name - return self.write(cr, uid, ids, update_values, context=context) - - # ****************************** - # Notifications - # ****************************** - - def case_get_note_msg_prefix(self, cr, uid, id, context=None): - return '' - - def case_open_send_note(self, cr, uid, ids, context=None): - for id in ids: - msg = _('%s has been opened.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, context=context) - return True - - def case_escalate_send_note(self, cr, uid, ids, new_section=None, context=None): - for id in ids: - if new_section: - msg = '%s has been escalated to %s.' % (self.case_get_note_msg_prefix(cr, uid, id, context=context), new_section.name) - else: - msg = '%s has been escalated.' % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, context=context) - return True - - def case_close_send_note(self, cr, uid, ids, context=None): - for id in ids: - msg = _('%s has been closed.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, context=context) - return True - - def case_cancel_send_note(self, cr, uid, ids, context=None): - for id in ids: - msg = _('%s has been canceled.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, context=context) - return True - - def case_pending_send_note(self, cr, uid, ids, context=None): - for id in ids: - msg = _('%s is now pending.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, context=context) - return True - - def case_reset_send_note(self, cr, uid, ids, context=None): - for id in ids: - msg = _('%s has been renewed.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context)) - self.message_post(cr, uid, [id], body=msg, context=context) - return True -- cgit v1.2.3