[FIX] Remove test from saas-3 - Tech Saas & AL agreement
authorKersten Jeremy <jke@openerp.com>
Wed, 12 Mar 2014 12:57:57 +0000 (13:57 +0100)
committerKersten Jeremy <jke@openerp.com>
Wed, 12 Mar 2014 12:57:57 +0000 (13:57 +0100)
bzr revid: dle@openerp.com-20140311164559-1vi0mw3qm8n0vobn
bzr revid: dle@openerp.com-20140312111450-smumao0hm1vzifgn
bzr revid: dle@openerp.com-20140312121555-uum96hj8f2y1rvna
bzr revid: jke@openerp.com-20140312125757-e2kgxuwz0jko77ve

1  2 
addons/account/account.py
addons/account_check_writing/account_voucher.py
addons/audittrail/audittrail.py
addons/crm/crm_lead.py
addons/portal/mail_message.py

@@@ -30,7 -30,7 +30,7 @@@ from openerp import SUPERUSER_I
  from openerp import tools
  from openerp.osv import fields, osv, expression
  from openerp.tools.translate import _
--from openerp.tools.float_utils import float_round
++from openerp.tools.float_utils import float_round as round
  
  import openerp.addons.decimal_precision as dp
  
@@@ -2144,7 -2144,7 +2144,7 @@@ class account_tax(osv.osv)
          tax_compute_precision = precision
          if taxes and taxes[0].company_id.tax_calculation_rounding_method == 'round_globally':
              tax_compute_precision += 5
--        totalin = totalex = float_round(price_unit * quantity, precision)
++        totalin = totalex = round(price_unit * quantity, precision)
          tin = []
          tex = []
          for tax in taxes:
@@@ -41,6 -41,6 +41,23 @@@ class account_voucher(osv.osv)
          'number': fields.char('Number', size=32),
      }
  
++    def _amount_to_text(self, cr, uid, amount, currency_id, context=None):
++        # Currency complete name is not available in res.currency model
++        # Exceptions done here (EUR, USD, BRL) cover 75% of cases
++        # For other currencies, display the currency code
++        currency = self.pool['res.currency'].browse(cr, uid, currency_id, context=context)
++        if currency.name.upper() == 'EUR':
++            currency_name = 'Euro'
++        elif currency.name.upper() == 'USD':
++            currency_name = 'Dollars'
++        elif currency.name.upper() == 'BRL':
++            currency_name = 'reais'
++        else:
++            currency_name = currency.name
++        #TODO : generic amount_to_text is not ready yet, otherwise language (and country) and currency can be passed
++        #amount_in_word = amount_to_text(amount, context=context)
++        return amount_to_text(amount, currency=currency_name)
++
      def onchange_amount(self, cr, uid, ids, amount, rate, partner_id, journal_id, currency_id, ttype, date, payment_rate_currency_id, company_id, context=None):
          """ Inherited - add amount_in_word and allow_check_writting in returned value dictionary """
          if not context:
          default = super(account_voucher, self).onchange_amount(cr, uid, ids, amount, rate, partner_id, journal_id, currency_id, ttype, date, payment_rate_currency_id, company_id, context=context)
          if 'value' in default:
              amount = 'amount' in default['value'] and default['value']['amount'] or amount
--
--            # Currency complete name is not available in res.currency model
--            # Exceptions done here (EUR, USD, BRL) cover 75% of cases
--            # For other currencies, display the currency code
--            currency = self.pool['res.currency'].browse(cr, uid, currency_id, context=context)
--            if currency.name.upper() == 'EUR':
--                currency_name = 'Euro'
--            elif currency.name.upper() == 'USD':
--                currency_name = 'Dollars'
--            elif currency.name.upper() == 'BRL':
--                currency_name = 'reais'
--            else:
--                currency_name = currency.name
--            #TODO : generic amount_to_text is not ready yet, otherwise language (and country) and currency can be passed
--            #amount_in_word = amount_to_text(amount, context=context)
--            amount_in_word = amount_to_text(amount, currency=currency_name)
++            amount_in_word = self._amount_to_text(cr, uid, amount, currency_id, context=context)
              default['value'].update({'amount_in_word':amount_in_word})
              if journal_id:
                  allow_check_writing = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context).allow_check_writing
                  },
              'nodestroy': True
              }
++    def create(self, cr, uid, vals, context=None):
++        if vals.get('amount') and vals.get('journal_id') and 'amount_in_word' not in vals:
++            vals['amount_in_word'] = self._amount_to_text(cr, uid, vals['amount'], vals.get('currency_id') or \
++                self.pool['account.journal'].browse(cr, uid, vals['journal_id'], context=context).currency.id or \
++                self.pool['res.company'].browse(cr, uid, vals['company_id']).currency_id.id, context=context)
++        return super(account_voucher, self).create(cr, uid, vals, context=context)
++
++    def write(self, cr, uid, ids, vals, context=None):
++        if vals.get('amount') and vals.get('journal_id') and 'amount_in_word' not in vals:
++            vals['amount_in_word'] = self._amount_to_text(cr, uid, vals['amount'], vals.get('currency_id') or \
++                self.pool['account.journal'].browse(cr, uid, vals['journal_id'], context=context).currency.id or \
++                self.pool['res.company'].browse(cr, uid, vals['company_id']).currency_id.id, context=context)
++        return super(account_voucher, self).write(cr, uid, ids, vals, context=context)
  
      def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
          """
@@@ -463,14 -463,14 +463,12 @@@ def process_data(cr, uid, pool, res_ids
          # if at least one modification has been found
          for model_id, resource_id in lines:
              line_model = pool.get('ir.model').browse(cr, SUPERUSER_ID, model_id).model
--            name = pool.get(line_model).name_get(cr, uid, [resource_id])[0][1]
  
              vals = {
                  'method': method,
                  'object_id': model_id,
                  'user_id': uid,
                  'res_id': resource_id,
--                'name': name,
              }
              if (model_id, resource_id) not in old_values and method not in ('copy', 'read'):
                  # the resource was not existing so we are forcing the method to 'create'
                  # the resource is not existing anymore so we are forcing the method to 'unlink'
                  # (because it could also come with the value 'write' if we are deleting the
                  #  record through a one2many field)
++                name = old_values[(model_id, resource_id)]['value'].get('name',False)
                  vals.update({'method': 'unlink'})
++            else :
++                name = pool[line_model].name_get(cr, uid, [resource_id])[0][1]
++            vals.update({'name': name})
              # create the audittrail log in super admin mode, only if a change has been detected
              if lines[(model_id, resource_id)]:
                  log_id = pool.get('audittrail.log').create(cr, SUPERUSER_ID, vals)
@@@ -313,7 -313,7 +313,10 @@@ class crm_lead(format_address, osv.osv)
          stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context=context)
          if not stage.on_change:
              return {'value': {}}
--        return {'value': {'probability': stage.probability}}
++        vals = {'probability': stage.probability}
++        if stage.probability >= 100 or (stage.probability == 0 and stage.sequence > 1):
++                vals['date_closed'] = fields.datetime.now()
++        return {'value': vals}
  
      def on_change_partner_id(self, cr, uid, ids, partner_id, context=None):
          values = {}
                          'probability = 0 %, select "Change Probability Automatically".\n'
                          'Create a specific stage or edit an existing one by editing columns of your opportunity pipe.'))
          for stage_id, lead_ids in stages_leads.items():
--            self.write(cr, uid, lead_ids, {'stage_id': stage_id, 'date_closed': fields.datetime.now()}, context=context)
++            self.write(cr, uid, lead_ids, {'stage_id': stage_id}, context=context)
          return True
  
      def case_mark_won(self, cr, uid, ids, context=None):
                          'probability = 100 % and select "Change Probability Automatically".\n'
                          'Create a specific stage or edit an existing one by editing columns of your opportunity pipe.'))
          for stage_id, lead_ids in stages_leads.items():
--            self.write(cr, uid, lead_ids, {'stage_id': stage_id, 'date_closed': fields.datetime.now()}, context=context)
++            self.write(cr, uid, lead_ids, {'stage_id': stage_id}, context=context)
          return True
  
      def case_escalate(self, cr, uid, ids, context=None):
@@@ -35,7 -35,7 +35,7 @@@ class mail_message(osv.Model)
          """
          if uid == SUPERUSER_ID:
              return super(mail_message, self)._search(cr, uid, args, offset=offset, limit=limit, order=order,
--                context=context, count=False, access_rights_uid=access_rights_uid)
++                context=context, count=count, access_rights_uid=access_rights_uid)
          group_ids = self.pool.get('res.users').browse(cr, uid, uid, context=context).groups_id
          group_user_id = self.pool.get("ir.model.data").get_object_reference(cr, uid, 'base', 'group_user')[1]
          if group_user_id not in [group.id for group in group_ids]: