'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):
"""
# 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)
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):