~jfb-tempo-consulting/unifield-wm/sync-env-py3

« back to all changes in this revision

Viewing changes to mkdb.py

  • Committer: Mallory MARCOT
  • Date: 2018-07-25 09:43:22 UTC
  • mto: This revision was merged to the branch mainline in revision 138.
  • Revision ID: mma@tempo-consulting.fr-20180725094322-78sw94kax6ujwvng
can now select currency for each HQ

Show diffs side-by-side

added added

removed removed

Lines of Context:
214
214
            'button' : 'action_stop',
215
215
        },
216
216
        'currency.setup' : {
217
 
            'functional_id' : config.currency,
 
217
            'functional_id' : config.default_currency,
218
218
        } 
219
219
    }
220
220
 
945
945
 
946
946
    def test_41_load_rates(self):
947
947
        cur_dir = os.path.dirname(os.path.realpath(__file__))
948
 
        rate_file = os.path.join(cur_dir, 'data', '%s.txt' % config.currency)
 
948
 
 
949
        cur_to_load = config.default_currency
 
950
        db_level_name = self.db.name.split('_')[-1] # e.g 'HQ1'
 
951
        if hasattr(config, 'currency_tree') and config.currency_tree.get(db_level_name, False):
 
952
            cur_to_load = config.currency_tree[db_level_name]
 
953
 
 
954
        rate_file = os.path.join(cur_dir, 'data', '%s.txt' % cur_to_load)
949
955
        if os.path.isfile(rate_file):
950
956
            rate_obj = self.db.get('res.currency')
951
957
            fx_rate_obj = self.db.get('res.currency.rate')
953
959
            rate_dict = {}
954
960
            for x in rate_obj.read(rate_ids, ['name']):
955
961
                rate_dict[x['name']] = x['id']
956
 
            fx_rate_obj.create({'currency_id': rate_dict[config.currency.upper()], 'rate': 1, 'name': '2016-01-01'})
 
962
            fx_rate_obj.create({'currency_id': rate_dict[cur_to_load.upper()], 'rate': 1, 'name': '2016-01-01'})
957
963
            f = open(rate_file, 'r')
958
964
            date = False
959
965
            for data in f: