diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 3a0f889d931..cc74b2a9158 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -482,7 +482,6 @@ class account_move_line(osv.osv): cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'account_move_line_journal_id_period_id_index\'') if not cr.fetchone(): cr.execute('CREATE INDEX account_move_line_journal_id_period_id_index ON account_move_line (journal_id, period_id)') - cr.commit() def _check_no_view(self, cr, uid, ids): lines = self.browse(cr, uid, ids) @@ -797,7 +796,7 @@ class account_move_line(osv.osv): title = self.view_header_get(cr, uid, view_id, view_type, context) xml = '''\n\n\t''' % (title) journal_pool = self.pool.get('account.journal') - + ids = journal_pool.search(cr, uid, []) journals = journal_pool.browse(cr, uid, ids) all_journal = [None] @@ -814,14 +813,14 @@ class account_move_line(osv.osv): else: fields.get(field.field).append(journal.id) common_fields[field.field] = common_fields[field.field] + 1 - + fld.append(('period_id', 3)) fld.append(('journal_id', 10)) flds.append('period_id') flds.append('journal_id') fields['period_id'] = all_journal fields['journal_id'] = all_journal - + from operator import itemgetter fld = sorted(fld, key=itemgetter(1)) @@ -835,13 +834,13 @@ class account_move_line(osv.osv): for field_it in fld: field = field_it[0] - + if common_fields.get(field) == total: fields.get(field).append(None) - + if field=='state': state = 'colors="red:state==\'draft\'"' - + attrs = [] if field == 'debit': attrs.append('sum="Total debit"') @@ -864,7 +863,7 @@ class account_move_line(osv.osv): if field in widths: attrs.append('width="'+str(widths[field])+'"') - + attrs.append("invisible=\"context.get('visible_id') not in %s\"" % (fields.get(field))) xml += '''\n''' % (field,' '.join(attrs)) @@ -914,7 +913,7 @@ class account_move_line(osv.osv): journal = self.pool.get('account.journal').browse(cr, uid, [journal_id])[0] if journal.allow_date and period_id: period = self.pool.get('account.period').browse(cr, uid, [period_id])[0] - if not time.strptime(vals['date'],'%Y-%m-%d')>=time.strptime(period.date_start,'%Y-%m-%d') or not time.strptime(vals['date'],'%Y-%m-%d')<=time.strptime(period.date_stop,'%Y-%m-%d'): + if not time.strptime(vals['date'][:10],'%Y-%m-%d')>=time.strptime(period.date_start,'%Y-%m-%d') or not time.strptime(vals['date'][:10],'%Y-%m-%d')<=time.strptime(period.date_stop,'%Y-%m-%d'): raise osv.except_osv(_('Error'),_('The date of your Ledger Posting is not in the defined period !')) else: return True diff --git a/addons/account/report/account_journal.py b/addons/account/report/account_journal.py index 5b8418be430..eaa3366ce47 100644 --- a/addons/account/report/account_journal.py +++ b/addons/account/report/account_journal.py @@ -46,7 +46,6 @@ class journal_print(report_sxw.rml_parse): ids_journal_period = obj_jperiod.search(self.cr, self.uid, [('journal_id','=',journal), ('period_id','=',period)]) if ids_journal_period: self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed',journal,period,'draft')) - self.cr.commit() self.cr.execute('select id from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\' order by ('+ sort_selection +'),id', (period, journal)) ids = map(lambda x: x[0], self.cr.fetchall()) ids_final.append(ids) @@ -56,7 +55,6 @@ class journal_print(report_sxw.rml_parse): line_ids.append(a) return line_ids self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed',journal_id,period_id,'draft')) - self.cr.commit() self.cr.execute('select id from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\' order by date,id', (period_id, journal_id)) ids = map(lambda x: x[0], self.cr.fetchall()) return obj_mline.browse(self.cr, self.uid, ids) diff --git a/addons/account/report/invoice.rml b/addons/account/report/invoice.rml index 6f1cac05102..b14f3d2ed68 100644 --- a/addons/account/report/invoice.rml +++ b/addons/account/report/invoice.rml @@ -127,10 +127,10 @@ - + - + - + - + - - - - - - - - - - - - - - + - + + + + + - - - - - - - + + + + + + + - - - + + @@ -227,25 +213,32 @@ - + + + - [[ repeatIn(objects,'o') ]] - [[ setLang(o.partner_id.lang) ]] + [[ setLang(o.partner_id.lang) ]] - - [[ o.partner_id.name ]] [[ o.partner_id.title or '' ]] + + + + + + [[ o.partner_id.title or '' ]] [[ o.partner_id.name ]] [[ o.address_invoice_id.title or '' ]] [[ o.address_invoice_id.name ]] [[ o.address_invoice_id.street ]] [[ o.address_invoice_id.street2 or '' ]] [[ o.address_invoice_id.zip or '' ]] [[ o.address_invoice_id.city or '' ]] [[ o.address_invoice_id.state_id and o.address_invoice_id.state_id.name or '' ]] [[ o.address_invoice_id.country_id and o.address_invoice_id.country_id.name or '' ]] - + + + Tel. : [[ o.address_invoice_id.phone or removeParentNode('para') ]] Fax : [[ o.address_invoice_id.fax or removeParentNode('para') ]] VAT : [[ o.partner_id.vat or removeParentNode('para') ]] @@ -255,168 +248,278 @@ Invoice [[ ((o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')) or removeParentNode('para')) and '' ]] [[ o.number ]] PRO-FORMA [[ ((o.type == 'out_invoice' and o.state == 'proforma2') or removeParentNode('para')) and '' ]] Draft Invoice [[ ((o.type == 'out_invoice' and o.state == 'draft') or removeParentNode('para')) and '' ]] - Canceled Invoice [[ ((o.type == 'out_invoice' and o.state == 'cancel') or removeParentNode('para')) and '' ]] + Cancelled Invoice [[ ((o.type == 'out_invoice' and o.state == 'cancel') or removeParentNode('para')) and '' ]] [[ o.number ]] Refund [[ (o.type=='out_refund' or removeParentNode('para')) and '' ]] [[ o.number ]] Supplier Refund [[ (o.type=='in_refund' or removeParentNode('para')) and '' ]] [[ o.number ]] Supplier Invoice [[ (o.type=='in_invoice' or removeParentNode('para')) and '' ]] [[ o.number ]] - + + + - Document - Invoice Date - Partner Ref. + + Document + + + Invoice Date + + + Partner Ref. + - [[ o.name ]] - [[ formatLang(o.date_invoice,date=True) ]] - [[ o.address_invoice_id.partner_id.ref or '' ]] + + [[ o.name ]] + + + [[ formatLang(o.date_invoice,date=True) ]] + + + [[ o.address_invoice_id.partner_id.ref or '' ]] + - - - + + + + - Description - Taxes - Quantity - Unit Price - Disc.(%) - Price + + Description + + + Taxes + + + Quantity + + + Unit Price + + + Disc.(%) + + + Price +
[[ repeatIn(o.invoice_line,'l') ]] - + - [[ l.name ]] - [[ ', '.join([ lt.description or '' for lt in l.invoice_line_tax_id ]) ]] - [[ formatLang(l.quantity)]] - [[ (l.uos_id and l.uos_id.name) or '' ]] - [[ formatLang(l.price_unit) ]] - [[ formatLang(l.discount) ]] - [[ formatLang(l.price_subtotal) ]] - [[ o.currency_id.code ]] + + [[ l.name ]] + + + [[ ', '.join([ lt.name or '' for lt in l.invoice_line_tax_id ]) ]] + + + [[ formatLang(l.quantity)]] + + + [[ (l.uos_id and l.uos_id.name) or '' ]] + + + [[ formatLang(l.price_unit) ]] + + + [[ formatLang(l.discount) ]] + + + [[ formatLang(l.price_subtotal) ]] + + + [[ o.currency_id.code ]] + - [[ format(l.note) or removeParentNode('tr') ]] - - - - - - - + + [[ format(l.note or '') or removeParentNode('tr') ]] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- + - - + + + + + + + + + + - + - Net Total: - [[ formatLang(o.amount_untaxed) ]] - [[ o.currency_id.code ]] + + Net Total: + + + [[ formatLang(o.amount_untaxed) ]] + + + [[ o.currency_id.code ]] + - + + + + - Taxes: - [[ formatLang(o.amount_tax) ]] - [[ o.currency_id.code ]] + + Taxes: + + + [[ formatLang(o.amount_tax) ]] + + + [[ o.currency_id.code ]] + - + + + + - Total: - [[ formatLang(o.amount_total) ]] - [[ o.currency_id.code ]] + + Total: + + + [[ formatLang(o.amount_total) ]] + + + [[ o.currency_id.code ]] + - + - + - Tax - Base - Amount + + Tax + + + Base + + + Amount + + + + + + + + + + + [[ repeatIn(o.tax_line,'t') ]] + + + + [[ t.name ]] + + + [[ formatLang(t.base) ]] + + + [[ (t.tax_code_id and t.tax_code_id.notprintable) and removeParentNode('blockTable') or '' ]] [[ formatLang(t.amount) ]] + - [[ repeatIn(o.tax_line,'t') ]] - - - [[ t.name ]] - [[ formatLang(t.base) ]] - [[ (t.tax_code_id and t.tax_code_id.notprintable) and removeParentNode('blockTable') or '' ]][[ formatLang(t.amount) ]] - - + + + + + - - - - - - - + [[ format(o.comment or '') or removeParentNode('blockTable') ]] - + - - + + [[ format((o.payment_term and o.payment_term.note) or '') or removeParentNode('blockTable') ]] + - - - [[ format(o.comment or removeParentNode('blockTable')) ]] - - - - - - - - [[ format((o.payment_term and o.payment_term.note) or removeParentNode('blockTable')) ]] - - - - - - + Fiscal Position Remark : - [[ format(o.fiscal_position and o.fiscal_position.note or removeParentNode('blockTable')) ]] + [[ format((o.fiscal_position and o.fiscal_position.note) or '') or removeParentNode('blockTable') ]] - - - - - - + + + + +
diff --git a/addons/account_followup/__openerp__.py b/addons/account_followup/__openerp__.py index 5aefa0abc96..7d47d46f926 100644 --- a/addons/account_followup/__openerp__.py +++ b/addons/account_followup/__openerp__.py @@ -53,6 +53,7 @@ 'account_followup_data.xml' ], 'demo_xml': ['account_followup_demo.xml'], + 'test': ['test/account_followup.yml'], 'installable': True, 'active': False, 'certificate': '0072481076453', diff --git a/addons/account_payment/test/account_payment.yml b/addons/account_payment/test/account_payment.yml index f24ad4dc443..3379ebe9003 100644 --- a/addons/account_payment/test/account_payment.yml +++ b/addons/account_payment/test/account_payment.yml @@ -1,8 +1,5 @@ - - In order to test account_payment in OpenERP I create a new record Type -- -- - Creating a payment.type record + In order to test account_payment in OpenERP I create a new record Type. - !record {model: payment.type, id: payment_type_t0}: code: T0 @@ -127,19 +124,3 @@ - state == 'done' - - - - - - - - - - - - - - - - diff --git a/addons/auction/wizard/auction_lots_buyer_map.py b/addons/auction/wizard/auction_lots_buyer_map.py index bee39e0d258..f9225b65291 100644 --- a/addons/auction/wizard/auction_lots_buyer_map.py +++ b/addons/auction/wizard/auction_lots_buyer_map.py @@ -90,7 +90,6 @@ class wiz_auc_lots_buyer_map(osv.osv_memory): for rec in recs: if rec.ach_login==datas['ach_login']: lots_obj.write(cr, uid, [rec.id], {'ach_uid': datas['ach_uid']}, context=context) - cr.commit() return {} def fields_view_get(self, cr, uid, view_id=None, view_type='form', diff --git a/addons/auction/wizard/auction_lots_make_invoice.py b/addons/auction/wizard/auction_lots_make_invoice.py index 8cda461e186..ca069c96182 100644 --- a/addons/auction/wizard/auction_lots_make_invoice.py +++ b/addons/auction/wizard/auction_lots_make_invoice.py @@ -73,7 +73,6 @@ class auction_lots_make_invoice(osv.osv_memory): result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter') id = mod_obj.read(cr, uid, result, ['res_id']) lots_ids = order_obj.seller_trans_create(cr, uid, context['active_ids'], context) - cr.commit() return { 'domain': "[('id','in', ["+','.join(map(str, lots_ids))+"])]", 'name': 'Seller invoices', diff --git a/addons/auction/wizard/auction_lots_make_invoice_buyer.py b/addons/auction/wizard/auction_lots_make_invoice_buyer.py index 5d2e370a81e..9357983c315 100644 --- a/addons/auction/wizard/auction_lots_make_invoice_buyer.py +++ b/addons/auction/wizard/auction_lots_make_invoice_buyer.py @@ -73,7 +73,6 @@ class auction_lots_make_invoice_buyer(osv.osv_memory): for lot in lots: up_auction = order_obj.write(cr, uid, [lot.id], {'ach_uid': data['buyer_id']}) lots_ids = order_obj.lots_invoice(cr, uid, context['active_ids'], context, data['number']) - cr.commit() return { 'domain': "[('id','in', ["+','.join(map(str, lots_ids))+"])]", 'name': 'Buyer invoices', diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index b1ef4f5ca13..f7f6f8bf3d0 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -105,8 +105,8 @@ the rule to mark CC(mail to any other person defined in actions)."), 'act_mail_to_email': fields.char('Mail to these Emails', size=128, \ help="Email-id of the persons whom mail is to be sent"), 'act_mail_body': fields.text('Mail body', help="Content of mail"), - 'regex_name': fields.char('Regex on Resource Name', size=128, help="Regular expression for mathching name of the resource\ -\ne.g.: urgent.* will search for records having name starting with urgent\ + 'regex_name': fields.char('Regex on Resource Name', size=128, help="Regular expression for matching name of the resource\ +\ne.g.: 'urgent.*' will search for records having name starting with the string 'urgent'\ \nNote: This is case sensitive search."), 'server_action_id': fields.many2one('ir.actions.server', 'Server Action', help="Describes the action name.\neg:on which object which action to be taken on basis of which condition"), 'filter_id':fields.many2one('ir.filters', 'Filter', required=False), diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 85ec16bda8d..f66cd0ca463 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -690,7 +690,6 @@ true, it will allow you to hide the event alarm information without removing it. cr.execute('Update %s set base_calendar_alarm_id=%s, alarm_id=%s \ where id=%s' % (model_obj._table, \ alarm_id, basic_alarm.id, data.id)) - cr.commit() return True def do_alarm_unlink(self, cr, uid, ids, model, context=None): @@ -714,7 +713,6 @@ true, it will allow you to hide the event alarm information without removing it. alarm_obj.unlink(cr, uid, alarm_ids) cr.execute('Update %s set base_calendar_alarm_id=NULL, alarm_id=NULL\ where id=%s' % (model_obj._table, datas.id)) - cr.commit() return True res_alarm() diff --git a/addons/base_contact/test/base_contact00.yml b/addons/base_contact/test/base_contact00.yml index 335f525f92f..c6a4ed9e057 100644 --- a/addons/base_contact/test/base_contact00.yml +++ b/addons/base_contact/test/base_contact00.yml @@ -55,7 +55,7 @@ Now I will check that the new job is assigned properly to contact or not - !assert {model: res.partner.contact, id: res_partner_contact_williams0}: - - len(job_ids) > 2 + - len(job_ids) >= 2 - | In order to check contacts working at several addresses for different partners I will create contact with 2 different addresses diff --git a/addons/base_setup/__init__.py b/addons/base_setup/__init__.py index 3b78c6cb557..efdcfe16135 100644 --- a/addons/base_setup/__init__.py +++ b/addons/base_setup/__init__.py @@ -48,7 +48,7 @@ class base_setup_config_choice(osv.osv_memory): user_ids = user_obj.search(cr, uid, []) users = user_obj.browse(cr, uid, user_ids) user_str = '\n'.join(map(lambda x: ' - %s: %s / %s' % (x.name, x.login, x.password), users)) - return _('The following users have been installed on your database: \n')+ user_str + return _('The following users have been installed : \n')+ user_str _columns = { 'installed_users':fields.text('Installed Users', readonly=True), diff --git a/addons/base_setup/base_setup_data.xml b/addons/base_setup/base_setup_data.xml index 024accc77ce..2f53f2c322d 100644 --- a/addons/base_setup/base_setup_data.xml +++ b/addons/base_setup/base_setup_data.xml @@ -16,7 +16,7 @@ - diff --git a/addons/base_setup/base_setup_todo.xml b/addons/base_setup/base_setup_todo.xml index ae7ae7f23c7..5db25283777 100644 --- a/addons/base_setup/base_setup_todo.xml +++ b/addons/base_setup/base_setup_todo.xml @@ -11,7 +11,7 @@ Main Company Setup - Information of your company will be used to custiomise your documents like Invoices, Sale Orders,... + Information of your company will be used to custiomise your documents like Invoices, Sale Orders and many more. Configure Your Company @@ -24,16 +24,16 @@ - - - - + + - - + + - + + + diff --git a/addons/board/board_view.xml b/addons/board/board_view.xml index c7e1a37b8fa..f34c0ce5917 100644 --- a/addons/board/board_view.xml +++ b/addons/board/board_view.xml @@ -4,9 +4,28 @@ - - + name="Dashboard" sequence="30" /> + + + board.note.search + board.note + search + + + + + + + + + + + + + + + + board.note.tree @@ -15,10 +34,11 @@ + - + @@ -31,7 +51,8 @@ - + + @@ -43,6 +64,7 @@ board.note form form,tree + @@ -72,7 +94,7 @@ name="%(action_board_menu_create)d" string="Create Menu" type="action" icon="gtk-justify-fill" /> - + diff --git a/addons/crm/crm.py b/addons/crm/crm.py index ba05269c474..743650d5497 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -124,7 +124,7 @@ class crm_case(object): stage_pool = self.pool.get('crm.case.stage') for case in self.browse(cr, uid, ids, context): if section in s: - st = case.stage_id.id or False + st = not context.get('force_domain', False) and case.stage_id.id or False if st in s[section]: data = {'stage_id': s[section][st]} stage = s[section][st] @@ -141,8 +141,12 @@ class crm_case(object): if not context: context = {} stage_obj = self.pool.get('crm.case.stage') - sid = stage_obj.search(cr, uid, \ - [('object_id.model', '=', self._name)], context=context) + tmp = self.read(cr, uid, ids, ['section_id'], context)[0]['section_id'] + section_id = tmp and tmp[0] or False + domain = [('object_id.model', '=', self._name), ('section_id', '=', section_id)] + if 'force_domain' in context and context['force_domain']: + domain += context['force_domain'] + sid = stage_obj.search(cr, uid, domain, context=context) s = {} previous = {} section = self._name @@ -168,7 +172,7 @@ class crm_case(object): stage_pool = self.pool.get('crm.case.stage') for case in self.browse(cr, uid, ids, context): if section in s: - st = case.stage_id.id or False + st = not context.get('force_domain', False) and case.stage_id.id or False s[section] = dict([(v, k) for (k, v) in s[section].iteritems()]) if st in s[section]: data = {'stage_id': s[section][st]} @@ -440,7 +444,7 @@ class crm_case_section(osv.osv): 'active': fields.boolean('Active', help="If the active field is set to \ true, it will allow you to hide the sales team without removing it."), 'allow_unlink': fields.boolean('Allow Delete', help="Allows to delete non draft cases"), - 'change_responsible': fields.boolean('Change Responsible', help="Set responsible of this Sales team on escalation to this team"), + 'change_responsible': fields.boolean('Change Responsible', help="Thick this box if you want that on escalation, the responsible of this sale team automatically becomes responsible of the lead/opportunity escaladed"), 'user_id': fields.many2one('res.users', 'Responsible User'), 'member_ids':fields.many2many('res.users', 'sale_member_rel', 'section_id', 'member_id', 'Team Members'), 'reply_to': fields.char('Reply-To', size=64, help="The email address put \ diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 01c597fcb97..9069bec1d17 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -177,10 +177,18 @@ and users"), @param ids: List of case's Ids @param *args: Give Tuple Value """ + old_state = self.read(cr, uid, ids, ['state'])[0]['state'] res = super(crm_lead, self).case_open(cr, uid, ids, *args) - self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}) + if old_state == 'draft': + stage_id = super(crm_lead, self).stage_next(cr, uid, ids, *args) + if not stage_id: + raise osv.except_osv(_('Warning !'), _('There is no stage defined for this Sale Team.')) + value = self.onchange_stage_id(cr, uid, ids, stage_id, context={})['value'] + value.update({'date_open': time.strftime('%Y-%m-%d %H:%M:%S'), 'stage_id': stage_id}) + self.write(cr, uid, ids, value) + for (id, name) in self.name_get(cr, uid, ids): - message = _('Lead ') + " '" + name + "' "+ _("is Open.") + message = _('The Lead') + " '" + name + "' "+ _("has been written as Open.") self.log(cr, uid, id, message) return res @@ -195,7 +203,7 @@ and users"), res = super(crm_lead, self).case_close(cr, uid, ids, args) self.write(cr, uid, ids, {'date_closed': time.strftime('%Y-%m-%d %H:%M:%S')}) for (id, name) in self.name_get(cr, uid, ids): - message = _('Lead ') + " '" + name + "' "+ _("is Closed.") + message = _('The Lead') + " '" + name + "' "+ _("has been written as Closed.") self.log(cr, uid, id, message) return res diff --git a/addons/crm/crm_opportunity.py b/addons/crm/crm_opportunity.py index e13a428138a..0b672721ba3 100644 --- a/addons/crm/crm_opportunity.py +++ b/addons/crm/crm_opportunity.py @@ -64,9 +64,36 @@ class crm_opportunity(osv.osv): @param *args: Tuple Value for additional Params """ res = super(crm_opportunity, self).case_close(cr, uid, ids, args) - self.write(cr, uid, ids, {'probability' : 100.0, 'date_closed': time.strftime('%Y-%m-%d %H:%M:%S')}) + stage_id = super(crm_opportunity, self).stage_next(cr, uid, ids, context={'force_domain': [('probability', '=', 100)]}) + if not stage_id: + raise osv.except_osv(_('Warning !'), _('There is no stage for won oppportunities defined for this Sale Team.')) + value = self.onchange_stage_id(cr, uid, ids, stage_id, context={})['value'] + value.update({'date_closed': time.strftime('%Y-%m-%d %H:%M:%S'), 'stage_id': stage_id}) + + self.write(cr, uid, ids, value) for (id, name) in self.name_get(cr, uid, ids): - message = _('Opportunity ') + " '" + name + "' "+ _("is Won.") + message = _('The Opportunity') + " '" + name + "' "+ _("has been written as Won.") + self.log(cr, uid, id, message) + return res + + def case_mark_lost(self, cr, uid, ids, *args): + """Mark the case as lost: state = done and probability = 0% + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of case Ids + @param *args: Tuple Value for additional Params + """ + res = super(crm_opportunity, self).case_close(cr, uid, ids, args) + stage_id = super(crm_opportunity, self).stage_next(cr, uid, ids, context={'force_domain': [('probability', '=', 0)]}) + if not stage_id: + raise osv.except_osv(_('Warning !'), _('There is no stage for lost oppportunities defined for this Sale Team.')) + value = self.onchange_stage_id(cr, uid, ids, stage_id, context={})['value'] + value.update({'date_closed': time.strftime('%Y-%m-%d %H:%M:%S'), 'stage_id': stage_id}) + + res = self.write(cr, uid, ids, value) + for (id, name) in self.name_get(cr, uid, ids): + message = _('The Opportunity') + " '" + name + "' "+ _("has been written as Lost.") self.log(cr, uid, id, message) return res @@ -80,13 +107,23 @@ class crm_opportunity(osv.osv): """ res = super(crm_opportunity, self).case_cancel(cr, uid, ids, args) self.write(cr, uid, ids, {'probability' : 0.0}) - for (id, name) in self.name_get(cr, uid, ids): - message = _('Opportunity ') + " '" + name + "' "+ _("is Lost.") - self.log(cr, uid, id, message) return res - + + def case_reset(self, cr, uid, ids, *args): + """Overrides reset as draft in order to set the stage field as empty + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of case Ids + @param *args: Tuple Value for additional Params + """ + res = super(crm_opportunity, self).case_reset(cr, uid, ids, *args) + self.write(cr, uid, ids, {'stage_id': False}) + return True + + def case_open(self, cr, uid, ids, *args): - """Overrides cancel for crm_case for setting Open Date + """Overrides open for crm_case for setting Open Date @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, diff --git a/addons/crm/crm_opportunity_view.xml b/addons/crm/crm_opportunity_view.xml index 4bcdb8afa49..5c3f3ffa8e1 100644 --- a/addons/crm/crm_opportunity_view.xml +++ b/addons/crm/crm_opportunity_view.xml @@ -65,8 +65,11 @@ - + +