~gs.clearcorp/openerp-ccorp-addons/7.0_budget2

« back to all changes in this revision

Viewing changes to exchange_rate_calculated/account_move_line.py

[MRG] Fix onchange_amount_currency method in exchange_rate_calculated

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
from osv import osv, fields, orm
24
24
import time
 
25
import copy
25
26
 
26
27
class accountMoveline(orm.Model):
27
28
    
32
33
        depends of currency selected. It only works in amount_currency to debit/credit.
33
34
        In debit/credit to amount_currency it isn't implemented.
34
35
    """
35
 
    def onchange_amount_currency(self, cr, uid, ids, amount_currency, currency_id, context=None):
 
36
    def onchange_amount_currency(self, cr, uid, ids, date, amount_currency, currency_id, context=None):
36
37
        res_currency_obj = self.pool.get('res.currency')
37
38
        res_user_obj = self.pool.get('res.users')
38
39
        res = {'value':{}}
 
40
        if context is None:
 
41
            context = {}
39
42
        
40
43
        """
41
44
        1. Get currency for current company. 
44
47
        res_user = res_user_obj.browse(cr, uid, uid, context=context)
45
48
        company_currency = res_user.company_id.currency_id
46
49
        
47
 
        """ 2. Get today's date as string"""
48
 
        now = time.strftime('%Y-%m-%d')
 
50
        """ 2. Get date as string"""
 
51
        if not date:
 
52
            date = time.strftime('%Y-%m-%d')
 
53
        copy_context = copy.copy(context)
 
54
        copy_context.update({'date':date})
 
55
            
49
56
        
50
57
        if amount_currency != 0 and currency_id:
51
58
            """3. Get amount_currency for today"""
52
59
            currency_selected = res_currency_obj.browse(cr, uid, currency_id, context=context)
53
 
            exchange_amount = res_currency_obj.get_exchange_rate(cr, uid, company_currency, currency_selected, now, context=context)
 
60
            exchange_amount = res_currency_obj.get_exchange_rate(cr, uid, company_currency, currency_selected, date, context=copy_context)
54
61
            
55
62
            """4. Asign values to debit or credit """
56
63
            if amount_currency > 0: