diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index d3a58272b89..09e51486ad2 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -127,6 +127,7 @@ module named account_vouchers 'board_account_demo.xml', ], 'test': [ + 'test/account_sequence_test.yml', 'test/account_customer_invoice.yml', 'test/account_supplier_invoice.yml', 'test/account_change_currency.yml', diff --git a/addons/account/account.py b/addons/account/account.py index 6aa47551a98..45d3cb4377c 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2684,6 +2684,15 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'position_id' : new_fp, } obj_ac_fp.create(cr, uid, vals_acc) + + #fially inactive the demo chart of accounts + data_id = data_pool.search(cr, uid, [('model','=','account.account'), ('name','=','chart0')]) + if data_id: + data = data_pool.browse(cr, uid, data_id[0]) + account_id = data.res_id + if account_id: + cr.execute("update account_account set active='f' where id=%s" % (account_id)) + wizard_multi_charts_accounts() class account_bank_accounts_wizard(osv.osv_memory): diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index e0d31b9cf18..d0d8a8e9458 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -25,6 +25,7 @@ from osv import fields, osv from tools.misc import currency from tools.translate import _ +import decimal_precision as dp class account_bank_statement(osv.osv): @@ -130,9 +131,9 @@ class account_bank_statement(osv.osv): states={'confirm': [('readonly', True)]}, domain=[('type', '=', 'cash')]), 'period_id': fields.many2one('account.period', 'Period', required=True, states={'confirm':[('readonly', True)]}), - 'balance_start': fields.float('Starting Balance', digits=(16,2), + 'balance_start': fields.float('Starting Balance', digits_compute=dp.get_precision('Account'), states={'confirm':[('readonly',True)]}), - 'balance_end_real': fields.float('Ending Balance', digits=(16,2), + 'balance_end_real': fields.float('Ending Balance', digits_compute=dp.get_precision('Account'), states={'confirm':[('readonly', True)]}), 'balance_end': fields.function(_end_balance, method=True, string='Balance'), 'line_ids': fields.one2many('account.bank.statement.line', diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py index 1a0727e626f..b6c36dd3337 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -25,6 +25,7 @@ import time from mx import DateTime from decimal import Decimal from tools.translate import _ +import decimal_precision as dp class account_cashbox_line(osv.osv): @@ -55,9 +56,9 @@ class account_cashbox_line(osv.osv): return {'value':{'subtotal': sub or 0.0}} _columns = { - 'pieces': fields.float('Values', digits=(16,2)), + 'pieces': fields.float('Values', digits_compute=dp.get_precision('Account')), 'number': fields.integer('Number'), - 'subtotal': fields.function(_sub_total, method=True, string='Sub Total', type='float',digits=(16,2)), + 'subtotal': fields.function(_sub_total, method=True, string='Sub Total', type='float', digits_compute=dp.get_precision('Account')), 'starting_id': fields.many2one('account.bank.statement',ondelete='cascade'), 'ending_id': fields.many2one('account.bank.statement',ondelete='cascade'), } @@ -176,7 +177,7 @@ class account_cash_statement(osv.osv): _columns = { 'company_id':fields.many2one('res.company', 'Company', required=False), 'journal_id': fields.many2one('account.journal', 'Journal', required=True), - 'balance_end_real': fields.float('Closing Balance', digits=(16,2), states={'confirm':[('readonly', True)]}, help="closing balance entered by the cashbox verifier"), + 'balance_end_real': fields.float('Closing Balance', digits_compute=dp.get_precision('Account'), states={'confirm':[('readonly', True)]}, help="closing balance entered by the cashbox verifier"), 'state': fields.selection( [('draft', 'Draft'), ('confirm', 'Confirm'), diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 6fe0182b584..6e770864799 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -201,13 +201,13 @@ - + + + Forward to Partner crm.lead.forward.to.partner form form + new diff --git a/addons/crm/wizard/crm_lead_to_opportunity.py b/addons/crm/wizard/crm_lead_to_opportunity.py index 7f47e27a4ff..acb259718f1 100644 --- a/addons/crm/wizard/crm_lead_to_opportunity.py +++ b/addons/crm/wizard/crm_lead_to_opportunity.py @@ -126,9 +126,9 @@ class crm_lead2opportunity(osv.osv_memory): if lead.state in ['done', 'cancel']: raise osv.except_osv(_("Warning !"), _("Closed/Cancelled \ Leads Could not convert into Opportunity")) - if lead.state != 'open': + if lead.state not in ('open', 'pending'): raise osv.except_osv(_('Warning !'), _('Lead should be in \ -\'Open\' state before converting to Opportunity.')) +\'Open\' or \'Pending\' state before converting to Opportunity.')) return False def default_get(self, cr, uid, fields, context=None): @@ -289,9 +289,9 @@ class crm_lead2opportunity_partner(osv.osv_memory): if lead.state in ['done', 'cancel']: raise osv.except_osv(_("Warning !"), _("Closed/Cancelled \ Leads Could not convert into Opportunity")) - if lead.state != 'open': + if lead.state not in ('open', 'pending'): raise osv.except_osv(_('Warning !'), _('Lead should be in \ -\'Open\' state before converting to Opportunity.')) +\'Open\' or \'Pending\' state before converting to Opportunity.')) return False crm_lead2opportunity_partner() diff --git a/addons/crm/wizard/crm_send_email.py b/addons/crm/wizard/crm_send_email.py index bc2b5357c15..3f1c1916585 100644 --- a/addons/crm/wizard/crm_send_email.py +++ b/addons/crm/wizard/crm_send_email.py @@ -20,11 +20,13 @@ # ############################################################################## +from crm import crm from osv import osv, fields from tools.translate import _ import base64 +import itertools import tools -from crm import crm +import re class crm_send_new_email_attachment(osv.osv_memory): _name = 'crm.send.mail.attachment' @@ -46,32 +48,25 @@ class crm_send_new_email(osv.osv_memory): 'email_to' : fields.char('To', size=512, required=True), 'email_from' : fields.char('From', size=128, required=True), 'reply_to' : fields.char('Reply To', size=128, required=True, help="Reply-to of the Sales team defined on this case"), - 'email_cc' : fields.char('CC', size=512, help="Carbon Copy: list of recipients that will receive"\ - " a copy of this mail, and future communication related to this case"), + 'email_cc' : fields.char('CC', size=512, help="Carbon Copy: list of recipients that will receive a copy of this mail"), 'subject': fields.char('Subject', size=512, required=True), - 'text': fields.text('Message', required=True), + 'body': fields.text('Message Body', required=True), 'state': fields.selection(crm.AVAILABLE_STATES, string='Set New State To', required=True), 'attachment_ids' : fields.one2many('crm.send.mail.attachment', 'wizard_id'), } - def action_cancel(self, cr, uid, ids, context=None): - """ Closes Phonecall to Opportunity form - """ - return {'type':'ir.actions.act_window_close'} - def action_send(self, cr, uid, ids, context=None): """ This sends an email to ALL the addresses of the selected partners. """ - hist_obj = self.pool.get('mailgate.message') if not context: context = {} - if not context.get('model'): + if not context.get('active_model'): raise osv.except_osv(_('Error'), _('Can not send mail!')) - model = context.get('model') + model = context.get('active_model') case_pool = self.pool.get(model) res_id = context and context.get('active_id', False) or False @@ -83,24 +78,38 @@ class crm_send_new_email(osv.osv_memory): message_id = None ref_id = None - case = case_pool.browse(cr, uid, res_id) + case = case_pool.browse(cr, uid, res_id, context=context) if context.get('mail', 'new') == 'new': if case.message_ids: message_id = case.message_ids[0].message_id + elif context.get('mail') == 'forward': + # extract attachements from case and emails according to mode + attachments = [] + attach_pool = self.pool.get('ir.attachment') + direct_attachments = attach_pool.search(cr, uid, [('res_model', '=', 'crm.lead'), ('res_id', '=', res_id)], context=context) + attachments += attach_pool.browse(cr, uid, direct_attachments, context=context) + if obj.history in ['latest', 'whole'] and case.message_ids: + msgs = case.message_ids + if obj.history == 'latest': + msgs = msgs[:1] + attachments.extend(itertools.chain(*[m.attachment_ids for m in msgs])) + attach_all = [(a.datas_fname or a.name, base64.decodestring(a.datas)) for a in attachments if a.datas] + attach += attach_all + else: - hist = hist_obj.browse(cr, uid, res_id) + hist = hist_obj.browse(cr, uid, res_id, context=context) message_id = hist.message_id model = hist.model - model_pool = self.pool.get(model) + case_pool = self.pool.get(model) res_id = hist.res_id ref_id = hist.ref_id - case = model_pool.browse(cr, uid, res_id) + case = case_pool.browse(cr, uid, res_id, context=context) emails = [obj.email_to] - email_cc = obj.email_cc and obj.email_cc.split(',') or '' + email_cc = re.findall(r'([^ ,<@]+@[^> ,]+)', obj.email_cc) emails = filter(None, emails) - body = obj.text + body = obj.body - body = case_pool.format_body(body) + body = body and tools.ustr(body) or '' email_from = getattr(obj, 'email_from', False) x_headers = {} if message_id: @@ -121,10 +130,11 @@ class crm_send_new_email(osv.osv_memory): if not flag: raise osv.except_osv(_('Error!'), _('Unable to send mail. Please check SMTP is configured properly.')) - case_pool.history(cr, uid, [case], _('Send'), history=True, \ + msg_dict = {'new': 'Send', 'reply': 'Reply', 'forward': 'Forward'} + case_pool.history(cr, uid, [case], _(msg_dict[context.get('mail', 'new')]), history=True, \ email=obj.email_to, details=body, \ subject=obj.subject, email_from=email_from, \ - email_cc=email_cc, message_id=message_id, \ + email_cc=', '.join(email_cc), message_id=message_id, \ references=ref_id or message_id, attach=attach) if obj.state == 'unchanged': pass @@ -145,7 +155,7 @@ class crm_send_new_email(osv.osv_memory): if not context: context = {} - if not context.get('model'): + if not context.get('active_model'): raise osv.except_osv(_('Error'), _('Can not send mail!')) res = super(crm_send_new_email, self).default_get(cr, uid, fields, context=context) @@ -154,7 +164,7 @@ class crm_send_new_email(osv.osv_memory): res.update(self.get_reply_defaults(cr, uid, fields, context=context)) return res - model = context.get('model') + model = context.get('active_model') mod_obj = self.pool.get(model) res_id = context and context.get('active_ids', []) or [] @@ -172,8 +182,8 @@ class crm_send_new_email(osv.osv_memory): res.update({'subject': tools.ustr(context.get('subject', case.name) or '')}) if 'email_cc' in fields: res.update({'email_cc': tools.ustr(case.email_cc or '')}) - if 'text' in fields: - res.update({'text': u'\n'+(tools.ustr(case.user_id.signature or ''))}) + if 'body' in fields: + res.update({'body': u'\n'+(tools.ustr(case.user_id.signature or ''))}) if 'state' in fields: res.update({'state': u'pending'}) @@ -209,7 +219,7 @@ class crm_send_new_email(osv.osv_memory): signature = u'\n' + (tools.ustr(case.user_id.signature or '')) + u'\n' original = [signature] - if include_original == True and 'text' in fields: + if include_original == True and 'body' in fields: header = u'-------- Original Message --------' sender = u'From: %s' %(tools.ustr(hist.email_from or '')) to = u'To: %s' % (tools.ustr(hist.email_to or '')) @@ -218,10 +228,14 @@ class crm_send_new_email(osv.osv_memory): original = [signature, header, sender, to, sentdate, desc] - res['text']= u'\n' + u'\n'.join(original) + res['body']= u'\n' + u'\n'.join(original) if 'subject' in fields: res.update({u'subject': u'Re: %s' %(tools.ustr(hist.name or ''))}) + if 'email_cc' in fields: + res.update({'email_cc': case.email_cc and tools.ustr(case.email_cc) or False}) + if 'reply_to' in fields: + res.update({'reply_to': case.section_id.reply_to}) if 'state' in fields: res['state'] = u'pending' return res @@ -239,7 +253,7 @@ class crm_send_new_email(osv.osv_memory): if not context: context = {} - if not context.get('model'): + if not context.get('active_model'): raise osv.except_osv(_('Error'), _('Can not send mail!')) return True diff --git a/addons/crm/wizard/crm_send_email_view.xml b/addons/crm/wizard/crm_send_email_view.xml index df7218cbc02..77202a19f6c 100644 --- a/addons/crm/wizard/crm_send_email_view.xml +++ b/addons/crm/wizard/crm_send_email_view.xml @@ -9,7 +9,7 @@ crm.send.mail form -
+ @@ -19,7 +19,7 @@ - + @@ -36,7 +36,7 @@ -