From 323aa0e8ad1f932be0d2f1b8eecdcf99b4b600d8 Mon Sep 17 00:00:00 2001 From: skh Date: Wed, 11 May 2011 14:48:38 +0530 Subject: [PATCH 01/88] [IMP] base_vat: Validate the VAT Number using the python.vatnumber Library => remove the method to check vat numbers bzr revid: skh@tinyerp.com-20110511091838-jb4j7w5t29bpv04h --- addons/base_vat/base_vat.py | 1028 +---------------------------------- 1 file changed, 6 insertions(+), 1022 deletions(-) diff --git a/addons/base_vat/base_vat.py b/addons/base_vat/base_vat.py index 69b312ee62f..5e2712fc6fb 100644 --- a/addons/base_vat/base_vat.py +++ b/addons/base_vat/base_vat.py @@ -20,32 +20,9 @@ # ############################################################################## import string - from osv import osv, fields from tools.translate import _ - -_ref_vat = { - 'be': 'BE0477472701', 'at': 'ATU12345675', - 'bg': 'BG1234567892', 'cy': 'CY12345678F', - 'cz': 'CZ12345679', 'de': 'DE123456788', - 'dk': 'DK12345674', 'ee': 'EE123456780', - 'es': 'ESA12345674', 'fi': 'FI12345671', - 'fr': 'FR32123456789', 'gb': 'GB123456782', - 'gr': 'GR12345670', 'hu': 'HU12345676', - 'ie': 'IE1234567T', 'it': 'IT12345670017', - 'lt': 'LT123456715', 'lu': 'LU12345613', - 'lv': 'LV41234567891', 'mt': 'MT12345634', - 'nl': 'NL123456782B90', 'pl': 'PL1234567883', - 'pt': 'PT123456789', 'ro': 'RO1234567897', - 'se': 'SE123456789701', 'si': 'SI12345679', - 'sk': 'SK0012345675', 'el': 'EL12345670', - 'mx': 'MXABC123456T1B' - - } - -def mult_add(i, j): - """Sum each digits of the multiplication of i and j.""" - return reduce(lambda x, y: x + int(y), str(i*j), 0) +import vatnumber #User should install "python-vatnumber" package from the Synaptic Package Manager to check valid VAT NUMBER class res_partner(osv.osv): _inherit = 'res.partner' @@ -59,19 +36,15 @@ class res_partner(osv.osv): Check the VAT number depending of the country. http://sima-pc.com/nif.php ''' - country_obj = self.pool.get('res.country') for partner in self.browse(cr, uid, ids, context=context): if not partner.vat: continue vat_country, vat_number = self._split_vat(partner.vat) - if not hasattr(self, 'check_vat_' + vat_country): - #We didn't find the validation method for the country code. If that country code can be found in openerp, this means that it is a valid country code - #and we simply didn't have implemented that function. In that case we continue. - if country_obj.search(cr, uid, [('code', 'ilike', vat_country)], context=context): + if not hasattr(vatnumber, 'check_vat_' + vat_country): + if vat_country.upper() in vatnumber.countries(): continue - #Otherwise, it means that the country code isn't valid and we return False. return False - check = getattr(self, 'check_vat_' + vat_country) + check = getattr(vatnumber, 'check_vat_' + vat_country) if not check(vat_number): return False return True @@ -85,1004 +58,15 @@ class res_partner(osv.osv): def _construct_constraint_msg(self, cr, uid, ids, context=None): def default_vat_check(cn, vn): - # by default, a VAT number is valid if: - # it starts with 2 letters - # has more than 3 characters return cn[0] in string.ascii_lowercase and cn[1] in string.ascii_lowercase vat_country, vat_number = self._split_vat(self.browse(cr, uid, ids)[0].vat) if default_vat_check(vat_country, vat_number): - vat_no = vat_country in _ref_vat and _ref_vat[vat_country] or 'Country Code + Vat Number' + vat_no = vat_country in vatnumber.countries() and vatnumber.countries() or 'Country Code + Vat Number' return _('The Vat does not seems to be correct. You should have entered something like this %s'), (vat_no) return _('The VAT is invalid, It should begin with the country code'), () _constraints = [(check_vat, _construct_constraint_msg, ["vat"])] - - # code from the following methods come from Tryton (B2CK) - # http://www.tryton.org/hgwebdir.cgi/modules/relationship/file/544d1de586d9/party.py - def check_vat_at(self, vat): - ''' - Check Austria VAT number. - ''' - if len(vat) != 9: - return False - if vat[0] != 'U': - return False - num = vat[1:] - try: - int(num) - except: - return False - sum = int(num[0]) + mult_add(2, int(num[1])) + \ - int(num[2]) + mult_add(2, int(num[3])) + \ - int(num[4]) + mult_add(2, int(num[5])) + \ - int(num[6]) - check = 10 - ((sum + 4) % 10) - if check == 10: - check = 0 - if int(vat[-1:]) != check: - return False - return True - - def check_vat_be(self, vat): - ''' - Check Belgium VAT number. - ''' - if len(vat) != 10: - return False - try: - int(vat) - except: - return False - if int(vat[-2:]) != \ - 97 - (int(vat[:8]) % 97): - return False - return True - - def check_vat_bg(self, vat): - ''' - Check Bulgaria VAT number. - ''' - if len(vat) not in [9,10]: - return False - try: - int(vat) - except: - return False - if int(vat[0]) in (2, 3) and \ - int(vat[1:2]) != 22: - return False - sum = 4 * int(vat[0]) + 3 * int(vat[1]) + 2 * int(vat[2]) + \ - 7 * int(vat[3]) + 6 * int(vat[4]) + 5 * int(vat[5]) + \ - 4 * int(vat[6]) + 3 * int(vat[7]) + 2 * int(vat[8]) - check = 11 - (sum % 11) - if check == 11: - check = 0 - return True - - def check_vat_cy(self, vat): - ''' - Check Cyprus VAT number. - ''' - if len(vat) != 9: - return False - try: - int(vat[:8]) - except: - return False - n0 = int(vat[0]) - n1 = int(vat[1]) - n2 = int(vat[2]) - n3 = int(vat[3]) - n4 = int(vat[4]) - n5 = int(vat[5]) - n6 = int(vat[6]) - n7 = int(vat[7]) - - def conv(x): - if x == 0: - return 1 - elif x == 1: - return 0 - elif x == 2: - return 5 - elif x == 3: - return 7 - elif x == 4: - return 9 - elif x == 5: - return 13 - elif x == 6: - return 15 - elif x == 7: - return 17 - elif x == 8: - return 19 - elif x == 9: - return 21 - return x - n0 = conv(n0) - n2 = conv(n2) - n4 = conv(n4) - n6 = conv(n6) - - sum = n0 + n1 + n2 + n3 + n4 + n5 + n6 + n7 - check = chr(sum % 26 + 65) - if check != vat[8]: - return False - return True - - def check_vat_cz(self, vat): - ''' - Check Czech Republic VAT number. - ''' - if len(vat) not in (8, 9, 10): - return False - try: - int(vat) - except: - return False - - if len(vat) == 8: - if int(vat[0]) not in (0, 1, 2, 3, 4, 5, 6, 7, 8): - return False - sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \ - 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \ - 2 * int(vat[6]) - check = 11 - (sum % 11) - if check == 10: - check = 0 - if check == 11: - check = 1 - if check != int(vat[7]): - return False - elif len(vat) == 9 and int(vat[0]) == 6: - sum = 8 * int(vat[1]) + 7 * int(vat[2]) + 6 * int(vat[3]) + \ - 5 * int(vat[4]) + 4 * int(vat[5]) + 3 * int(vat[6]) + \ - 2 * int(vat[7]) - check = 9 - ((11 - (sum % 11)) % 10) - if check != int(vat[8]): - return False - elif len(vat) == 9: - if int(vat[0:2]) > 53 and int(vat[0:2]) < 80: - return False - if int(vat[2:4]) < 1: - return False - if int(vat[2:4]) > 12 and int(vat[2:4]) < 51: - return False - if int(vat[2:4]) > 62: - return False - if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 > 0: - if int(vat[4:6]) < 1: - return False - if int(vat[4:6]) > 28: - return False - if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 == 0: - if int(vat[4:6]) < 1: - return False - if int(vat[4:6]) > 29: - return False - if int(vat[2:4]) in (4, 6, 9, 11, 54, 56, 59, 61): - if int(vat[4:6]) < 1: - return False - if int(vat[4:6]) > 30: - return False - if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12, 51, - 53, 55, 57, 58, 60, 62): - if int(vat[4:6]) < 1: - return False - if int(vat[4:6]) > 31: - return False - elif len(vat) == 10: - if int(vat[0:2]) < 54: - return False - if int(vat[2:4]) < 1: - return False - if int(vat[2:4]) > 12 and int(vat[2:4]) < 51: - return False - if int(vat[2:4]) > 62: - return False - if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 > 0: - if int(vat[4:6]) < 1: - return False - if int(vat[4:6]) > 28: - return False - if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 == 0: - if int(vat[4:6]) < 1: - return False - if int(vat[4:6]) > 29: - return False - if int(vat[2:4]) in (4, 6, 9, 11, 54, 56, 59, 61): - if int(vat[4:6]) < 1: - return False - if int(vat[4:6]) > 30: - return False - if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12, 51, - 53, 55, 57, 58, 60, 62): - if int(vat[4:6]) < 1: - return False - if int(vat[4:6]) > 31: - return False - if (int(vat[0:2]) + int(vat[2:4]) + int(vat[4:6]) + int(vat[6:8]) + - int(vat[8:10])) % 11 != 0: - return False - if int(vat[0:10]) % 11 != 0: - return False - return True - - def check_vat_de(self, vat): - ''' - Check Germany VAT number. - ''' - if len(vat) != 9: - return False - try: - int(vat) - except: - return False - if int(vat[0:7]) <= 0: - return False - sum = 0 - for i in range(8): - sum = (2 * ((int(vat[i]) + sum + 9) % 10 + 1)) % 11 - check = 11 - sum - if check == 10: - check = 0 - if int(vat[8]) != check: - return False - return True - - def check_vat_dk(self, vat): - ''' - Check Denmark VAT number. - ''' - if len(vat) != 8: - return False - try: - int(vat) - except: - return False - if int(vat[0]) <= 0: - return False - sum = 2 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \ - 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \ - 2 * int(vat[6]) + int(vat[7]) - if sum % 11 != 0: - return False - return True - - def check_vat_ee(self, vat): - ''' - Check Estonia VAT number. - ''' - if len(vat) != 9: - return False - try: - int(vat) - except: - return False - sum = 3 * int(vat[0]) + 7 * int(vat[1]) + 1 * int(vat[2]) + \ - 3 * int(vat[3]) + 7 * int(vat[4]) + 1 * int(vat[5]) + \ - 3 * int(vat[6]) + 7 * int(vat[7]) - check = 10 - (sum % 10) - if check == 10: - check = 0 - if check != int(vat[8]): - return False - return True - - def check_vat_es(self, vat): - ''' - Check Spain VAT number. - ''' - if len(vat) != 9: - return False - - conv = { - 1: 'T', - 2: 'R', - 3: 'W', - 4: 'A', - 5: 'G', - 6: 'M', - 7: 'Y', - 8: 'F', - 9: 'P', - 10: 'D', - 11: 'X', - 12: 'B', - 13: 'N', - 14: 'J', - 15: 'Z', - 16: 'S', - 17: 'Q', - 18: 'V', - 19: 'H', - 20: 'L', - 21: 'C', - 22: 'K', - 23: 'E', - } - #Legal persons with profit aim - if vat[0] in ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'U', 'V'): - try: - int(vat[1:8]) - except: - return False - sum = mult_add(2, int(vat[1])) + int(vat[2]) + \ - mult_add(2, int(vat[3])) + int(vat[4]) + \ - mult_add(2, int(vat[5])) + int(vat[6]) + \ - mult_add(2, int(vat[7])) - check = 10 - (sum % 10) - if check == 10: - check = 0 - return True - #Legal persons with non-profit aim - elif vat[0] in ('N', 'P', 'Q', 'R', 'S', 'W'): - try: - int(vat[1:8]) - except: - return False - sum = mult_add(2, int(vat[1])) + int(vat[2]) + \ - mult_add(2, int(vat[3])) + int(vat[4]) + \ - mult_add(2, int(vat[5])) + int(vat[6]) + \ - mult_add(2, int(vat[7])) - check = 10 - (sum % 10) - check = chr(check + 64) - if check != vat[8]: - return False - return True - #Foreign natural persons, under age 14 or non-residents - elif vat[0] in ('K', 'L', 'M', 'X', 'Y', 'Z'): - if vat[0] == 'Y': - check_value = '1' + vat[1:8] - elif vat[0] == 'Z': - check_value = '2' + vat[1:8] - else: - check_value = vat[1:8] - - try: - int(check_value) - except: - return False - check = 1 + (int(check_value) % 23) - - check = conv[check] - if check != vat[8]: - return False - return True - #Spanish natural persons - else: - try: - int(vat[:8]) - except: - return False - check = 1 + (int(vat[:8]) % 23) - - check = conv[check] - if check != vat[8]: - return False - return True - - def check_vat_fi(self, vat): - ''' - Check Finland VAT number. - ''' - if len(vat) != 8: - return False - try: - int(vat) - except: - return False - sum = 7 * int(vat[0]) + 9 * int(vat[1]) + 10 * int(vat[2]) + \ - 5 * int(vat[3]) + 8 * int(vat[4]) + 4 * int(vat[5]) + \ - 2 * int(vat[6]) - check = 11 - (sum % 11) - if check == 11: - check = 0 - if check == 10: - return False - if check != int(vat[7]): - return False - return True - - def check_vat_fr(self, vat): - ''' - Check France VAT number. - ''' - if len(vat) != 11: - return False - - try: - int(vat[2:11]) - except: - return False - - system = None - try: - int(vat[0:2]) - system = 'old' - except: - system = 'new' - - if system == 'old': - check = ((int(vat[2:11]) * 100) + 12) % 97 - if check != int(vat[0:2]): - return False - return True - else: - conv = ['0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', - 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', - 'U', 'V', 'W', 'X', 'Y', 'Z'] - if vat[0] not in conv \ - or vat[1] not in conv: - return False - c1 = conv.index(vat[0]) - c2 = conv.index(vat[1]) - - if c1 < 10: - sum = c1 * 24 + c2 - 10 - else: - sum = c1 * 34 + c2 - 100 - - x = sum % 11 - sum = (int(sum) / 11) + 1 - y = (int(vat[2:11]) + sum) % 11 - if x != y: - return False - return True - - def check_vat_gb(self, vat): - ''' - Check United Kingdom VAT number. - ''' - - if len(vat) == 5: - try: - int(vat[2:5]) - except: - return False - - if vat[0:2] == 'GD': - if int(vat[2:5]) >= 500: - return False - return True - if vat[0:2] == 'HA': - if int(vat[2:5]) < 500: - return False - return True - return False - elif len(vat) in (9, 10): - try: - int(vat) - except: - return False - - if int(vat[0:7]) < 1: - return False - if int(vat[0:7]) > 19999 and int(vat[0:7]) < 1000000: - return False - if int(vat[7:9]) > 97: - return False - if len(vat) == 10 and int(vat[9]) != 3: - return False - - sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \ - 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \ - 2 * int(vat[6]) + 10 * int(vat[7]) + int(vat[8]) - if int(vat[0:3]) > 100: - if sum % 97 not in (0, 55, 42): - return False - else: - if sum % 97 != 0: - return False - return True - elif len(vat) in (12, 13): - try: - int(vat) - except: - return False - - if int(vat[0:3]) not in (0, 1): - return False - - if int(vat[3:10]) < 1: - return False - if int(vat[3:10]) > 19999 and int(vat[3:10]) < 1000000: - return False - if int(vat[10:12]) > 97: - return False - if len(vat) == 13 and int(vat[12]) != 3: - return False - - sum = 8 * int(vat[3]) + 7 * int(vat[4]) + 6 * int(vat[5]) + \ - 5 * int(vat[6]) + 4 * int(vat[7]) + 3 * int(vat[8]) + \ - 2 * int(vat[9]) + 10 * int(vat[10]) + int(vat[11]) - if sum % 97 != 0: - return False - return True - return False - - def check_vat_gr(self, vat): - ''' - Check Greece VAT number. - ''' - try: - int(vat) - except: - return False - if len(vat) == 8: - sum = 128 * int(vat[0]) + 64 * int(vat[1]) + 32 * int(vat[2]) + \ - 16 * int(vat[3]) + 8 * int(vat[4]) + 4 * int(vat[5]) + \ - 2 * int(vat[6]) - check = sum % 11 - if check == 10: - check = 0 - if check != int(vat[7]): - return False - return True - elif len(vat) == 9: - sum = 256 * int(vat[0]) + 128 * int(vat[1]) + 64 * int(vat[2]) + \ - 32 * int(vat[3]) + 16 * int(vat[4]) + 8 * int(vat[5]) + \ - 4 * int(vat[6]) + 2 * int(vat[7]) - check = sum % 11 - if check == 10: - check = 0 - if check != int(vat[8]): - return False - return True - return False - - def check_vat_el(self, vat): - return self.check_vat_gr(vat) - - def check_vat_hu(self, vat): - ''' - Check Hungary VAT number. - ''' - if len(vat) != 8: - return False - try: - int(vat) - except: - return False - if int(vat[0]) <= 0: - return False - sum = 9 * int(vat[0]) + 7 * int(vat[1]) + 3 * int(vat[2]) + \ - 1 * int(vat[3]) + 9 * int(vat[4]) + 7 * int(vat[5]) + \ - 3 * int(vat[6]) - check = 10 - (sum % 10) - if check == 10: - check = 0 - if check != int(vat[7]): - return False - return True - - def check_vat_ie(self, vat): - ''' - Check Ireland VAT number. - ''' - if len(vat) != 8: - return False - if (ord(vat[1]) >= 65 and ord(vat[1]) <= 90) \ - or vat[1] in ('+', '*'): - try: - int(vat[0]) - int(vat[2:7]) - except: - return False - - if int(vat[0]) <= 6: - return False - - sum = 7 * int(vat[2]) + 6 * int(vat[3]) + 5 * int(vat[4]) + \ - 4 * int(vat[5]) + 3 * int(vat[6]) + 2 * int(vat[0]) - check = sum % 23 - if check == 0: - check = 'W' - else: - check = chr(check + 64) - if check != vat[7]: - return False - return True - else: - try: - int(vat[0:7]) - except: - return False - - sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \ - 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \ - 2 * int(vat[6]) - check = sum % 23 - if check == 0: - check = 'W' - else: - check = chr(check + 64) - if check != vat[7]: - return False - return True - - def check_vat_it(self, vat): - ''' - Check Italy VAT number. - ''' - if len(vat) != 11: - return False - try: - int(vat) - except: - return False - if int(vat[0:7]) <= 0: - return False - if int(vat[7:10]) <= 0: - return False - if int(vat[7:10]) > 100 and int(vat[7:10]) < 120: - return False - - sum = int(vat[0]) + mult_add(2, int(vat[1])) + int(vat[2]) + \ - mult_add(2, int(vat[3])) + int(vat[4]) + \ - mult_add(2, int(vat[5])) + int(vat[6]) + \ - mult_add(2, int(vat[7])) + int(vat[8]) + \ - mult_add(2, int(vat[9])) - check = 10 - (sum % 10) - if check == 10: - check = 0 - if check != int(vat[10]): - return False - return True - - def check_vat_lt(self, vat): - ''' - Check Lithuania VAT number. - ''' - try: - int(vat) - except: - return False - - if len(vat) == 9: - if int(vat[7]) != 1: - return False - sum = 1 * int(vat[0]) + 2 * int(vat[1]) + 3 * int(vat[2]) + \ - 4 * int(vat[3]) + 5 * int(vat[4]) + 6 * int(vat[5]) + \ - 7 * int(vat[6]) + 8 * int(vat[7]) - if sum % 11 == 10: - sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 5 * int(vat[2]) + \ - 6 * int(vat[3]) + 7 * int(vat[4]) + 8 * int(vat[5]) + \ - 9 * int(vat[6]) + 1 * int(vat[7]) - check = sum % 11 - if check == 10: - check = 0 - if check != int(vat[8]): - return False - return True - elif len(vat) == 12: - if int(vat[10]) != 1: - return False - sum = 1 * int(vat[0]) + 2 * int(vat[1]) + 3 * int(vat[2]) + \ - 4 * int(vat[3]) + 5 * int(vat[4]) + 6 * int(vat[5]) + \ - 7 * int(vat[6]) + 8 * int(vat[7]) + 9 * int(vat[8]) + \ - 1 * int(vat[9]) + 2 * int(vat[10]) - if sum % 11 == 10: - sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 5 * int(vat[2]) + \ - 6 * int(vat[3]) + 7 * int(vat[4]) + 8 * int(vat[5]) + \ - 9 * int(vat[6]) + 1 * int(vat[7]) + 2 * int(vat[8]) + \ - 3 * int(vat[9]) + 4 * int(vat[10]) - check = sum % 11 - if check == 10: - check = 0 - if check != int(vat[11]): - return False - return True - return False - - def check_vat_lu(self, vat): - ''' - Check Luxembourg VAT number. - ''' - if len(vat) != 8: - return False - try: - int(vat) - except: - return False - if int(vat[0:6]) <= 0: - return False - check = int(vat[0:6]) % 89 - if check != int(vat[6:8]): - return False - return True - - def check_vat_lv(self, vat): - ''' - Check Latvia VAT number. - ''' - if len(vat) != 11: - return False - try: - int(vat) - except: - return False - if int(vat[0]) >= 4: - sum = 9 * int(vat[0]) + 1 * int(vat[1]) + 4 * int(vat[2]) + \ - 8 * int(vat[3]) + 3 * int(vat[4]) + 10 * int(vat[5]) + \ - 2 * int(vat[6]) + 5 * int(vat[7]) + 7 * int(vat[8]) + \ - 6 * int(vat[9]) - if sum % 11 == 4 and int(vat[0]) == 9: - sum = sum - 45 - if sum % 11 == 4: - check = 4 - (sum % 11) - elif sum % 11 > 4: - check = 14 - (sum % 11) - elif sum % 11 < 4: - check = 3 - (sum % 11) - if check != int(vat[10]): - return False - return True - else: - if int(vat[2:4]) == 2 and int(vat[4:6]) % 4 > 0: - if int(vat[0:2]) < 1 or int(vat[0:2]) > 28: - return False - if int(vat[2:4]) == 2 and int(vat[4:6]) % 4 == 0: - if int(vat[0:2]) < 1 or int(vat[0:2]) > 29: - return False - if int(vat[2:4]) in (4, 6, 9, 11): - if int(vat[0:2]) < 1 or int(vat[0:2]) > 30: - return False - if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12): - if int(vat[0:2]) < 1 or int(vat[0:2]) > 31: - return False - if int(vat[2:4]) < 1 or int(vat[2:4]) > 12: - return False - return True - - def check_vat_mt(self, vat): - ''' - Check Malta VAT number. - ''' - if len(vat) != 8: - return False - try: - int(vat) - except: - return False - - if int(vat[0:6]) < 100000: - return False - - sum = 3 * int(vat[0]) + 4 * int(vat[1]) + 6 * int(vat[2]) + \ - 7 * int(vat[3]) + 8 * int(vat[4]) + 9 * int(vat[5]) - check = 37 - (sum % 37) - if check != int(vat[6:8]): - return False - return True - - def check_vat_nl(self, vat): - ''' - Check Netherlands VAT number. - ''' - if len(vat) != 12: - return False - try: - int(vat[0:9]) - int(vat[10:12]) - except: - return False - if int(vat[0:8]) <= 0: - return False - if vat[9] != 'B': - return False - - sum = 9 * int(vat[0]) + 8 * int(vat[1]) + 7 * int(vat[2]) + \ - 6 * int(vat[3]) + 5 * int(vat[4]) + 4 * int(vat[5]) + \ - 3 * int(vat[6]) + 2 * int(vat[7]) - - check = sum % 11 - if check == 10: - return False - if check != int(vat[8]): - return False - return True - - def check_vat_pl(self, vat): - ''' - Check Poland VAT number. - ''' - if len(vat) != 10: - return False - try: - int(vat) - except: - return False - - sum = 6 * int(vat[0]) + 5 * int(vat[1]) + 7 * int(vat[2]) + \ - 2 * int(vat[3]) + 3 * int(vat[4]) + 4 * int(vat[5]) + \ - 5 * int(vat[6]) + 6 * int(vat[7]) + 7 * int(vat[8]) - check = sum % 11 - if check == 10: - return False - if check != int(vat[9]): - return False - return True - - def check_vat_pt(self, vat): - ''' - Check Portugal VAT number. - ''' - if len(vat) != 9: - return False - try: - int(vat) - except: - return False - - if int(vat[0]) <= 0: - return False - - sum = 9 * int(vat[0]) + 8 * int(vat[1]) + 7 * int(vat[2]) + \ - 6 * int(vat[3]) + 5 * int(vat[4]) + 4 * int(vat[5]) + \ - 3 * int(vat[6]) + 2 * int(vat[7]) - check = 11 - (sum % 11) - if check == 10 or check == 11: - check = 0 - return True - - def check_vat_ro(self, vat): - ''' - Check Romania VAT number. - ''' - try: - int(vat) - except: - return False - - if len(vat) >= 2 and len(vat) <= 10: - vat = (10 - len(vat)) * '0' + vat - sum = 7 * int(vat[0]) + 5 * int(vat[1]) + 3 * int(vat[2]) + \ - 2 * int(vat[3]) + 1 * int(vat[4]) + 7 * int(vat[5]) + \ - 5 * int(vat[6]) + 3 * int(vat[7]) + 2 * int(vat[8]) - check = (sum * 10) % 11 - if check == 10: - check = 0 - if check != int(vat[9]): - return False - return True - elif len(vat) == 13: - if int(vat[0]) not in (1, 2, 3, 4, 6): - return False - if int(vat[3:5]) < 1 or int(vat[3:5]) > 12: - return False - if int(vat[3:5]) == 2 and int(vat[1:3]) % 4 > 0: - if int(vat[5:7]) < 1 or int(vat[5:7]) > 28: - return False - if int(vat[3:5]) == 2 and int(vat[1:3]) % 4 == 0: - if int(vat[5:7]) < 1 or int(vat[5:7]) > 29: - return False - if int(vat[3:5]) in (4, 6, 9, 11): - if int(vat[5:7]) < 1 or int(vat[5:7]) > 30: - return False - if int(vat[3:5]) in (1, 3, 5, 7, 8, 10, 12): - if int(vat[5:7]) < 1 or int(vat[5:7]) > 31: - return False - - sum = 2 * int(vat[0]) + 7 * int(vat[1]) + 9 * int(vat[2]) + \ - 1 * int(vat[3]) + 4 * int(vat[4]) + 6 * int(vat[5]) + \ - 3 * int(vat[6]) + 5 * int(vat[7]) + 8 * int(vat[8]) + \ - 2 * int(vat[9]) + 7 * int(vat[10]) + 9 * int(vat[11]) - check = sum % 11 - if check == 10: - check = 1 - if check != int(vat[12]): - return False - return True - return False - - def check_vat_se(self, vat): - ''' - Check Sweden VAT number. - ''' - if len(vat) != 12: - return False - try: - int(vat) - except: - return False - - if int(vat[9:11]) < 0: - return False - - sum = mult_add(2, int(vat[0])) + int(vat[1]) + \ - mult_add(2, int(vat[2])) + int(vat[3]) + \ - mult_add(2, int(vat[4])) + int(vat[5]) + \ - mult_add(2, int(vat[6])) + int(vat[7]) + \ - mult_add(2, int(vat[8])) - check = 10 - (sum % 10) - if check == 10: - check = 0 - if check != int(vat[9]): - return False - return True - - def check_vat_si(self, vat): - ''' - Check Slovenia VAT number. - ''' - if len(vat) != 8: - return False - try: - int(vat) - except: - return False - if int(vat[0:7]) <= 999999: - return False - - sum = 8 * int(vat[0]) + 7 * int(vat[1]) + 6 * int(vat[2]) + \ - 5 * int(vat[3]) + 4 * int(vat[4]) + 3 * int(vat[5]) + \ - 2 * int(vat[6]) - check = 11 - (sum % 11) - if check == 10: - check = 0 - if check == 11: - check = 1 - if check != int(vat[7]): - return False - return True - - def check_vat_sk(self, vat): - ''' - Check Slovakia VAT number. - ''' - try: - int(vat) - except: - return False - if len(vat) not in(9, 10): - return False - - if int(vat[0:2]) in (0, 10, 20) and len(vat) == 10: - return True - - if len(vat) == 10: - if int(vat[0:2]) < 54 or int(vat[0:2]) > 99: - return False - - if len(vat) == 9: - if int(vat[0:2]) > 53 : - return False - - if int(vat[2:4]) < 1: - return False - if int(vat[2:4]) > 12 and int(vat[2:4]) < 51: - return False - if int(vat[2:4]) > 62: - return False - if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 > 0: - if int(vat[4:6]) < 1 or int(vat[4:6]) > 28: - return False - if int(vat[2:4]) in (2, 52) and int(vat[0:2]) % 4 == 0: - if int(vat[4:6]) < 1 or int(vat[4:6]) > 29: - return False - if int(vat[2:4]) in (4, 6, 9, 11, 54, 56, 59, 61): - if int(vat[4:6]) < 1 or int(vat[4:6]) > 30: - return False - if int(vat[2:4]) in (1, 3, 5, 7, 8, 10, 12, - 51, 53, 55, 57, 58, 60, 62): - if int(vat[4:6]) < 1 or int(vat[4:6]) > 31: - return False - return True - - def check_vat_mx(self, vat): - ''' - Verificar RFC méxico - ''' - if not 12 <= len(vat) <= 13: - return False - elif len(vat)==12 and not vat[:3].isalpha() | vat[3:9].isdigit() | vat[-3:].isalnum(): - return False - elif len(vat)==13 and not vat[:4].isalpha() | vat[4:10].isdigit() | vat[-3:].isalnum(): - return False - return True + res_partner() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From e95c182608bfd40f72bac16e25de937c3824b951 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Wed, 18 May 2011 18:22:34 +0530 Subject: [PATCH 02/88] [FIX]procurement:Fixed:procurement scheduling report=>not Translation properly lp bug: https://launchpad.net/bugs/783135 fixed bzr revid: ron@tinyerp.com-20110518125234-9cea4larl1uub313 --- addons/procurement/schedulers.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/addons/procurement/schedulers.py b/addons/procurement/schedulers.py index 3a6e3336472..8bc2fef615b 100644 --- a/addons/procurement/schedulers.py +++ b/addons/procurement/schedulers.py @@ -100,7 +100,7 @@ class procurement_order(osv.osv): report_total += 1 for proc in procurement_obj.browse(cr, uid, report_ids, context=context): if proc.state == 'exception': - report.append('PROC %d: from stock - %3.2f %-5s - %s' % \ + report.append(_('PROC %d: from stock - %3.2f %-5s - %s') % \ (proc.id, proc.product_qty, proc.product_uom.name, proc.product_id.name,)) report_except += 1 @@ -111,15 +111,15 @@ class procurement_order(osv.osv): end_date = time.strftime('%Y-%m-%d, %Hh %Mm %Ss') if uid: request = self.pool.get('res.request') - summary = '''Here is the procurement scheduling report. - - Start Time: %s - End Time: %s - Total Procurements processed: %d - Procurements with exceptions: %d - Skipped Procurements (scheduled date outside of scheduler range) %d - - Exceptions:\n'''% (start_date, end_date, report_total, report_except, report_later) + summary = _("Here is the procurement scheduling report. \ +\ + Start Time: %s \ + End Time: %s \ + Total Procurements processed: %d \ + Procurements with exceptions: %d \ + Skipped Procurements (scheduled date outside of scheduler range) %d \ +\ + Exceptions:\n") % (start_date, end_date, report_total, report_except, report_later) summary += '\n'.join(report) request.create(cr, uid, {'name': "Procurement Processing Report.", From db63cecdcbf119691fb8ad1767e299087fff6035 Mon Sep 17 00:00:00 2001 From: "mayur maheshwari (Open ERP)" Date: Tue, 24 May 2011 17:34:42 +0530 Subject: [PATCH 03/88] [FIX]stock_planning_:Now edit generated Sales Forecasts in Form View By wizard lp bug: https://launchpad.net/bugs/781655 fixed bzr revid: mma@tinyerp.com-20110524120442-xcvn3e0mslp5mdfo --- addons/stock_planning/wizard/stock_planning_forecast.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock_planning/wizard/stock_planning_forecast.py b/addons/stock_planning/wizard/stock_planning_forecast.py index 60b3de62243..cee44d7bd6f 100644 --- a/addons/stock_planning/wizard/stock_planning_forecast.py +++ b/addons/stock_planning/wizard/stock_planning_forecast.py @@ -102,7 +102,7 @@ class stock_sale_forecast_createlines(osv.osv_memory): return { 'domain': "[('id','in', ["+','.join(map(str, forecast_lines))+"])]", 'view_type': 'form', - "view_mode": 'tree, form', + "view_mode": 'tree,form', 'res_model': 'stock.sale.forecast', 'type': 'ir.actions.act_window', 'search_view_id': id['res_id'], From 9c1d85e2985de335043217caddf9e9827e73bc12 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 30 May 2011 16:36:21 +0530 Subject: [PATCH 04/88] [FIX] method __str__ returns floating point value instead of string in report_sxw.py file lp bug: https://launchpad.net/bugs/723662 fixed bzr revid: ysa@tinyerp.com-20110530110621-2bgxi79fyx6e9y0g --- openerp/report/report_sxw.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/report/report_sxw.py b/openerp/report/report_sxw.py index f5e65e26766..79f4d32639f 100644 --- a/openerp/report/report_sxw.py +++ b/openerp/report/report_sxw.py @@ -86,7 +86,7 @@ class _float_format(float, _format): digits = self._field.digits[1] if hasattr(self, 'lang_obj'): return self.lang_obj.format('%.' + str(digits) + 'f', self.name, True) - return self.val + return str(self.val) class _int_format(int, _format): def __init__(self,value): From a5e9795ed1a574d7948d6da8ad888b3167b1bce0 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 30 May 2011 17:13:50 +0530 Subject: [PATCH 05/88] [FIX] __init__ metho store value in string format in float_format class. bzr revid: ysa@tinyerp.com-20110530114350-lp27vh30y45zsmp8 --- openerp/report/report_sxw.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/report/report_sxw.py b/openerp/report/report_sxw.py index 79f4d32639f..1ceb73e18b6 100644 --- a/openerp/report/report_sxw.py +++ b/openerp/report/report_sxw.py @@ -78,7 +78,7 @@ class _format(object): class _float_format(float, _format): def __init__(self,value): super(_float_format, self).__init__() - self.val = value + self.val = value and str(value) or str(0.0) def __str__(self): digits = 2 @@ -86,7 +86,7 @@ class _float_format(float, _format): digits = self._field.digits[1] if hasattr(self, 'lang_obj'): return self.lang_obj.format('%.' + str(digits) + 'f', self.name, True) - return str(self.val) + return self.val class _int_format(int, _format): def __init__(self,value): From f16882604442c2e7bc02f326fa2fd623937f0538 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 30 May 2011 17:29:41 +0530 Subject: [PATCH 06/88] [IMP] improve code. bzr revid: ysa@tinyerp.com-20110530115941-kur59d11l6d4xq3h --- openerp/report/report_sxw.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openerp/report/report_sxw.py b/openerp/report/report_sxw.py index 1ceb73e18b6..451e41e7032 100644 --- a/openerp/report/report_sxw.py +++ b/openerp/report/report_sxw.py @@ -78,7 +78,7 @@ class _format(object): class _float_format(float, _format): def __init__(self,value): super(_float_format, self).__init__() - self.val = value and str(value) or str(0.0) + self.val = value def __str__(self): digits = 2 @@ -86,17 +86,17 @@ class _float_format(float, _format): digits = self._field.digits[1] if hasattr(self, 'lang_obj'): return self.lang_obj.format('%.' + str(digits) + 'f', self.name, True) - return self.val + return str(self.val) class _int_format(int, _format): def __init__(self,value): super(_int_format, self).__init__() - self.val = value and str(value) or str(0) + self.val = value def __str__(self): if hasattr(self,'lang_obj'): return self.lang_obj.format('%.d', self.name, True) - return self.val + return str(self.val) class _date_format(str, _format): def __init__(self,value): From af3779a9e233270c8909c29344681ac7791f9fbd Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 30 May 2011 17:36:38 +0530 Subject: [PATCH 07/88] [IMP] improve code. bzr revid: ysa@tinyerp.com-20110530120638-g2m63j8fnrgt1q0t --- openerp/report/report_sxw.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/report/report_sxw.py b/openerp/report/report_sxw.py index 451e41e7032..261c43fb54f 100644 --- a/openerp/report/report_sxw.py +++ b/openerp/report/report_sxw.py @@ -78,7 +78,7 @@ class _format(object): class _float_format(float, _format): def __init__(self,value): super(_float_format, self).__init__() - self.val = value + self.val = value or 0.0 def __str__(self): digits = 2 @@ -91,7 +91,7 @@ class _float_format(float, _format): class _int_format(int, _format): def __init__(self,value): super(_int_format, self).__init__() - self.val = value + self.val = value or 0 def __str__(self): if hasattr(self,'lang_obj'): From 331760830f64b9702f0f12edf1c997f646000a07 Mon Sep 17 00:00:00 2001 From: "mayur maheshwari (Open ERP)" Date: Thu, 2 Jun 2011 15:15:33 +0530 Subject: [PATCH 08/88] [FIX]stock_planning_:Now edit Sales planning lines in Form View By wizard lp bug: https://launchpad.net/bugs/781655 fixed bzr revid: mma@tinyerp.com-20110602094533-impg0p3sw69uz33i --- addons/stock_planning/wizard/stock_planning_createlines.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock_planning/wizard/stock_planning_createlines.py b/addons/stock_planning/wizard/stock_planning_createlines.py index 7abb15b6e7d..d5a9a0ddc74 100644 --- a/addons/stock_planning/wizard/stock_planning_createlines.py +++ b/addons/stock_planning/wizard/stock_planning_createlines.py @@ -133,7 +133,7 @@ class stock_planning_createlines(osv.osv_memory): return { 'domain': "[('id','in', ["+','.join(map(str, planning_lines))+"])]", 'view_type': 'form', - "view_mode": 'tree, form', + "view_mode": 'tree,form', 'res_model': 'stock.planning', 'type': 'ir.actions.act_window', 'search_view_id': id['res_id'], From 48871849770800f1fd7d5fe6686e543951c49e6b Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Thu, 2 Jun 2011 17:34:55 +0530 Subject: [PATCH 09/88] [IMP]procurement:Improvement in Traslation string bzr revid: ron@tinyerp.com-20110602120455-lgadptlti782btgm --- addons/procurement/schedulers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/procurement/schedulers.py b/addons/procurement/schedulers.py index 8bc2fef615b..0c0372660d9 100644 --- a/addons/procurement/schedulers.py +++ b/addons/procurement/schedulers.py @@ -77,7 +77,7 @@ class procurement_order(osv.osv): report_later += 1 for proc in procurement_obj.browse(cr, uid, ids, context=context): if proc.state == 'exception': - report.append('PROC %d: on order - %3.2f %-5s - %s' % \ + report.append(_('PROC %d: on order - %3.2f %-5s - %s') % \ (proc.id, proc.product_qty, proc.product_uom.name, proc.product_id.name)) report_except += 1 From bcb551f338919368265b8f5835f696fce77b22e3 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Mon, 6 Jun 2011 15:42:33 +0530 Subject: [PATCH 10/88] [IMP]procurement:fixed=>Lines breaks in Traslation string bzr revid: ron@tinyerp.com-20110606101233-o3hi56uin99gdj60 --- addons/procurement/schedulers.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/procurement/schedulers.py b/addons/procurement/schedulers.py index 0c0372660d9..62fcf652b47 100644 --- a/addons/procurement/schedulers.py +++ b/addons/procurement/schedulers.py @@ -111,15 +111,15 @@ class procurement_order(osv.osv): end_date = time.strftime('%Y-%m-%d, %Hh %Mm %Ss') if uid: request = self.pool.get('res.request') - summary = _("Here is the procurement scheduling report. \ -\ - Start Time: %s \ - End Time: %s \ - Total Procurements processed: %d \ - Procurements with exceptions: %d \ - Skipped Procurements (scheduled date outside of scheduler range) %d \ -\ - Exceptions:\n") % (start_date, end_date, report_total, report_except, report_later) + summary = _("""Here is the procurement scheduling report. \n\ +\n\ + Start Time: %s \n\ + End Time: %s \n\ + Total Procurements processed: %d \n\ + Procurements with exceptions: %d \n\ + Skipped Procurements (scheduled date outside of scheduler range) %d \n\ +\n\ + Exceptions:\n""") % (start_date, end_date, report_total, report_except, report_later) summary += '\n'.join(report) request.create(cr, uid, {'name': "Procurement Processing Report.", From fecd5e29f41132c8d9df5600ad57c0d0e95d88da Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Mon, 6 Jun 2011 16:06:04 +0530 Subject: [PATCH 11/88] [IMP]procurement:improvements in lines breack code bzr revid: ron@tinyerp.com-20110606103604-gh7o9jpm5lfnc3ay --- addons/procurement/schedulers.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/procurement/schedulers.py b/addons/procurement/schedulers.py index 62fcf652b47..d72651ed55a 100644 --- a/addons/procurement/schedulers.py +++ b/addons/procurement/schedulers.py @@ -111,14 +111,14 @@ class procurement_order(osv.osv): end_date = time.strftime('%Y-%m-%d, %Hh %Mm %Ss') if uid: request = self.pool.get('res.request') - summary = _("""Here is the procurement scheduling report. \n\ -\n\ - Start Time: %s \n\ - End Time: %s \n\ - Total Procurements processed: %d \n\ - Procurements with exceptions: %d \n\ - Skipped Procurements (scheduled date outside of scheduler range) %d \n\ -\n\ + summary = _("""Here is the procurement scheduling report. + + Start Time: %s + End Time: %s + Total Procurements processed: %d + Procurements with exceptions: %d + Skipped Procurements (scheduled date outside of scheduler range) %d + Exceptions:\n""") % (start_date, end_date, report_total, report_except, report_later) summary += '\n'.join(report) request.create(cr, uid, From dee5a0dc6e179b5ce319893b0e58524038428ac5 Mon Sep 17 00:00:00 2001 From: "Nimesh (Open ERP)" Date: Thu, 9 Jun 2011 12:01:20 +0530 Subject: [PATCH 12/88] [FIX] chance the rete and rounding of Venezuelan currency exchange bzr revid: nco@tinyerp.com-20110609063120-vw1pqaxyhlaov0yy --- openerp/addons/base/base_data.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/base_data.xml b/openerp/addons/base/base_data.xml index 3f8208b8ec4..5f1feb8f14b 100644 --- a/openerp/addons/base/base_data.xml +++ b/openerp/addons/base/base_data.xml @@ -1088,12 +1088,12 @@ VEB Bs - 2.95 + 0.0001 4 - 2768.45 + 5.864 From 0d6ff068d2ec63126231ba18fcfa2122c54afac2 Mon Sep 17 00:00:00 2001 From: "Nimesh (Open ERP)" Date: Fri, 10 Jun 2011 15:52:03 +0530 Subject: [PATCH 13/88] change in name and symbol of Venezuelan currency lp bug: https://launchpad.net/bugs/715646 fixed bzr revid: nco@tinyerp.com-20110610102203-v1wkla7d226stfas --- openerp/addons/base/base_data.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openerp/addons/base/base_data.xml b/openerp/addons/base/base_data.xml index 5f1feb8f14b..14b00ec2aa7 100644 --- a/openerp/addons/base/base_data.xml +++ b/openerp/addons/base/base_data.xml @@ -1085,16 +1085,16 @@ - - VEB - Bs + + VEF + Bs.F 0.0001 4 - + 5.864 - + From 694693905a78a63e609b8bbd00db59d49e4ef536 Mon Sep 17 00:00:00 2001 From: "Nimesh (Open ERP)" Date: Fri, 10 Jun 2011 19:06:58 +0530 Subject: [PATCH 14/88] add yml test-case for =like and =ilike operator lp bug: https://launchpad.net/bugs/788106 fixed bzr revid: nco@tinyerp.com-20110610133658-z4avh4z60moecyde --- .../addons/base/test/test_osv_expression.yml | 26 +++++++++++++++++++ openerp/osv/expression.py | 8 +++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/openerp/addons/base/test/test_osv_expression.yml b/openerp/addons/base/test/test_osv_expression.yml index 4916fe06203..0e88f1ac022 100644 --- a/openerp/addons/base/test/test_osv_expression.yml +++ b/openerp/addons/base/test/test_osv_expression.yml @@ -111,3 +111,29 @@ res_ids.sort() assert res_ids == all_ids, "Searching against empty set failed, returns %r" % res_ids +- + Check that =like expressions is working without translation field +- + !python {model: res.partner }: | + all_ids = self.search(cr, uid, [('name', '=like', 'Ax')]) + assert len(all_ids) <= 1,"with =like operator without translation field, returns" + +- + Check that =ilike expression is working without translation field +- + !python {model: res.partner }: | + all_ids = self.search(cr, uid, [('name', '=ilike', 'Ax')]) + assert len(all_ids) <= 2,"with =ilike operator without translation field, returns" +- + Check that =like expression is working with translation field +- + !python {model: res.country }: | + all_ids = self.search(cr, uid, [('name', '=like', 'Ind')]) + assert len(all_ids) <= 3,"with =like operator with translation field, returns" + +- + Check that =ilike expression is working with translation field +- + !python {model: res.country }: | + all_ids = self.search(cr, uid, [('name', '=ilike', 'Ind')]) + assert len(all_ids) <= 3,"with =ilike operator with translation field, returns" \ No newline at end of file diff --git a/openerp/osv/expression.py b/openerp/osv/expression.py index 1922d5e8388..515f1390491 100644 --- a/openerp/osv/expression.py +++ b/openerp/osv/expression.py @@ -353,11 +353,10 @@ class expression(object): self.__exp[i] = tuple(self.__exp[i]) if field.translate: + operator = {'=like':'like','=ilike':'ilike'}.get(operator,operator) if operator in ('like', 'ilike', 'not like', 'not ilike'): right = '%%%s%%' % right - - operator = operator == '=like' and 'like' or operator - + query1 = '( SELECT res_id' \ ' FROM ir_translation' \ ' WHERE name = %s' \ @@ -451,8 +450,9 @@ class expression(object): query = '%s.id %s %%s' % (table._table, operator) params = right else: + operator = {'=like':'like','=ilike':'ilike'}.get(operator,operator) like = operator in ('like', 'ilike', 'not like', 'not ilike') - + op = {'=like':'like','=ilike':'ilike'}.get(operator,operator) if left in table._columns: format = like and '%s' or table._columns[left]._symbol_set[0] From 6964f67569348755e612ee2285f8f7a1997d0ad0 Mon Sep 17 00:00:00 2001 From: "Nimesh (Open ERP)" Date: Mon, 13 Jun 2011 12:23:06 +0530 Subject: [PATCH 15/88] improve the yml test-case lp bug: https://launchpad.net/bugs/788106 fixed bzr revid: nco@tinyerp.com-20110613065306-g0p5hsw84qa8bvtd --- openerp/addons/base/test/test_osv_expression.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/openerp/addons/base/test/test_osv_expression.yml b/openerp/addons/base/test/test_osv_expression.yml index 0e88f1ac022..fac5454d7bb 100644 --- a/openerp/addons/base/test/test_osv_expression.yml +++ b/openerp/addons/base/test/test_osv_expression.yml @@ -116,24 +116,25 @@ - !python {model: res.partner }: | all_ids = self.search(cr, uid, [('name', '=like', 'Ax')]) - assert len(all_ids) <= 1,"with =like operator without translation field, returns" + print all_ids,' Len is : ',len(all_ids) + assert len(all_ids) <= 1,"It should have 1 record !" - Check that =ilike expression is working without translation field - !python {model: res.partner }: | all_ids = self.search(cr, uid, [('name', '=ilike', 'Ax')]) - assert len(all_ids) <= 2,"with =ilike operator without translation field, returns" + assert len(all_ids) <= 2,"It should have 2 records !" - Check that =like expression is working with translation field - !python {model: res.country }: | all_ids = self.search(cr, uid, [('name', '=like', 'Ind')]) - assert len(all_ids) <= 3,"with =like operator with translation field, returns" + assert len(all_ids) <= 3,"It should have 3 records !" - Check that =ilike expression is working with translation field - !python {model: res.country }: | all_ids = self.search(cr, uid, [('name', '=ilike', 'Ind')]) - assert len(all_ids) <= 3,"with =ilike operator with translation field, returns" \ No newline at end of file + assert len(all_ids) <= 3,"It should have 3 records !" \ No newline at end of file From e0b1e6724ebe78c4dd79b8b1c1c44e28380f81cd Mon Sep 17 00:00:00 2001 From: "Nimesh (Open ERP)" Date: Mon, 13 Jun 2011 12:32:18 +0530 Subject: [PATCH 16/88] remove print statement lp bug: https://launchpad.net/bugs/788106 fixed bzr revid: nco@tinyerp.com-20110613070218-3uvgnpefavl95cmv --- openerp/addons/base/test/test_osv_expression.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/openerp/addons/base/test/test_osv_expression.yml b/openerp/addons/base/test/test_osv_expression.yml index fac5454d7bb..3d39521a718 100644 --- a/openerp/addons/base/test/test_osv_expression.yml +++ b/openerp/addons/base/test/test_osv_expression.yml @@ -116,7 +116,6 @@ - !python {model: res.partner }: | all_ids = self.search(cr, uid, [('name', '=like', 'Ax')]) - print all_ids,' Len is : ',len(all_ids) assert len(all_ids) <= 1,"It should have 1 record !" - From 7779f83e4a1b0745e890e4cb0d5861d77f050a55 Mon Sep 17 00:00:00 2001 From: "Nimesh (Open ERP)" Date: Mon, 13 Jun 2011 18:42:02 +0530 Subject: [PATCH 17/88] Improving error messages when writing invalid values to reference/selection fields lp bug: https://launchpad.net/bugs/777472 fixed bzr revid: nco@tinyerp.com-20110613131202-30bic6891ezlnq2e --- openerp/osv/orm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 52b1dbbd017..6dd01ecbc4f 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -2511,7 +2511,7 @@ class orm(orm_template): pass if not val_id: raise except_orm(_('ValidateError'), - _('Invalid value for reference field "%s" (last part must be a non-zero integer): "%s"') % (field, value)) + _('Invalid value for reference field "%s" of table "%s" (last part must be a non-zero integer): "%s"') % (field, self._table, value)) val = val_model else: val = value @@ -2521,7 +2521,7 @@ class orm(orm_template): elif val in dict(self._columns[field].selection(self, cr, uid, context=context)): return raise except_orm(_('ValidateError'), - _('The value "%s" for the field "%s" is not in the selection') % (value, field)) + _('The value "%s" for the field "%s" of table "%s" is not in the selection') % (value, field, self._table)) def _check_removed_columns(self, cr, log=False): # iterate on the database columns to drop the NOT NULL constraints From 45ca41f9b1c166456cbf7b5f12412fe07ea5811d Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Wed, 6 Jul 2011 12:30:52 +0530 Subject: [PATCH 18/88] [IMP] base_vat: Override italian, sweden vat validate method in base_vat bzr revid: psi@tinyerp.co.in-20110706070052-ubky9wywot6rni3n --- addons/base_vat/__init__.py | 3 +- addons/base_vat/__openerp__.py | 5 ++ addons/base_vat/base_vat.py | 135 ++++++++++++++++++++++++++++-- addons/base_vat/base_vat_view.xml | 18 ++-- 4 files changed, 143 insertions(+), 18 deletions(-) diff --git a/addons/base_vat/__init__.py b/addons/base_vat/__init__.py index e1999d38b87..43dbd0c1418 100644 --- a/addons/base_vat/__init__.py +++ b/addons/base_vat/__init__.py @@ -21,5 +21,4 @@ import base_vat -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/base_vat/__openerp__.py b/addons/base_vat/__openerp__.py index 1de5a94fabd..dda64ed584d 100644 --- a/addons/base_vat/__openerp__.py +++ b/addons/base_vat/__openerp__.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # ############################################################################## + { 'name': 'Base VAT', 'version': '1.0', @@ -38,5 +39,9 @@ checking the validity of VAT Number assigned to partners in European countries. 'active': False, 'certificate': '0084849360989', 'images': ['images/1_partner_vat.jpeg'], + 'external_dependencies': { + 'python' : ['vatnumber'], + } } + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_vat/base_vat.py b/addons/base_vat/base_vat.py index 5e2712fc6fb..114620acdce 100644 --- a/addons/base_vat/base_vat.py +++ b/addons/base_vat/base_vat.py @@ -19,10 +19,33 @@ # along with this program. If not, see . # ############################################################################## + import string +import vatnumber +import re +import datetime + from osv import osv, fields +from tools.misc import ustr from tools.translate import _ -import vatnumber #User should install "python-vatnumber" package from the Synaptic Package Manager to check valid VAT NUMBER + +_ref_vat = { + 'be': 'BE0477472701', 'at': 'ATU12345675', + 'bg': 'BG1234567892', 'cy': 'CY12345678F', + 'cz': 'CZ12345679', 'de': 'DE123456788', + 'dk': 'DK12345674', 'ee': 'EE123456780', + 'es': 'ESA12345674', 'fi': 'FI12345671', + 'fr': 'FR32123456789', 'gb': 'GB123456782', + 'gr': 'GR12345670', 'hu': 'HU12345676', + 'ie': 'IE1234567T', 'it': 'IT12345670017', + 'lt': 'LT123456715', 'lu': 'LU12345613', + 'lv': 'LV41234567891', 'mt': 'MT12345634', + 'nl': 'NL123456782B90', 'pl': 'PL1234567883', + 'pt': 'PT123456789', 'ro': 'RO1234567897', + 'se': 'SE123456789701', 'si': 'SI12345679', + 'sk': 'SK0012345675', 'el': 'EL12345670', + 'mx': 'MXABCD831230T1B', +} class res_partner(osv.osv): _inherit = 'res.partner' @@ -36,15 +59,19 @@ class res_partner(osv.osv): Check the VAT number depending of the country. http://sima-pc.com/nif.php ''' + country_obj = self.pool.get('res.country') for partner in self.browse(cr, uid, ids, context=context): if not partner.vat: continue vat_country, vat_number = self._split_vat(partner.vat) - if not hasattr(vatnumber, 'check_vat_' + vat_country): - if vat_country.upper() in vatnumber.countries(): + if not hasattr(self, 'check_vat_' + vat_country) and not hasattr(vatnumber, 'check_vat_' + vat_country): + #We didn't find the validation method for the country code. If that country code can be found in openerp, this means that it is a valid country code + #and we simply didn't have implemented that function. In that case we continue. + if country_obj.search(cr, uid, [('code', 'ilike', vat_country)], context=context): continue + #Otherwise, it means that the country code isn't valid and we return False. return False - check = getattr(vatnumber, 'check_vat_' + vat_country) + check = getattr(self, 'check_vat_' + vat_country, False) or getattr(vatnumber, 'check_vat_' + vat_country, False) if not check(vat_number): return False return True @@ -58,15 +85,109 @@ class res_partner(osv.osv): def _construct_constraint_msg(self, cr, uid, ids, context=None): def default_vat_check(cn, vn): + # by default, a VAT number is valid if: + # it starts with 2 letters + # has more than 3 characters return cn[0] in string.ascii_lowercase and cn[1] in string.ascii_lowercase vat_country, vat_number = self._split_vat(self.browse(cr, uid, ids)[0].vat) if default_vat_check(vat_country, vat_number): - vat_no = vat_country in vatnumber.countries() and vatnumber.countries() or 'Country Code + Vat Number' + vat_no = vat_country in _ref_vat and _ref_vat[vat_country] or 'Country Code + Vat Number' return _('The Vat does not seems to be correct. You should have entered something like this %s'), (vat_no) return _('The VAT is invalid, It should begin with the country code'), () _constraints = [(check_vat, _construct_constraint_msg, ["vat"])] - + + __check_vat_mx_re = re.compile(r"(?P[A-Za-z\xd1\xf1&]{3,4})" \ + r"[ \-_]?" \ + r"(?P[0-9]{2})(?P[01][0-9])(?P[0-3][0-9])" \ + r"[ \-_]?" \ + r"(?P[A-Za-z0-9&\xd1\xf1]{3})$") + + # Mexican VAT verification is not define in vatnumber library, so we need to define it here + def check_vat_mx(self, vat): + ''' Mexican VAT verification + + Verificar RFC México + ''' + # we convert to 8-bit encoding, to help the regex parse only bytes + vat = ustr(vat).encode('iso8859-1') + m = self.__check_vat_mx_re.match(vat) + if not m: + #No valid format + return False + try: + ano = int(m.group('ano')) + if ano > 30: + ano = 1900 + ano + else: + ano = 2000 + ano + datetime.date(ano, int(m.group('mes')), int(m.group('dia'))) + except ValueError: + return False + + #Valid format and valid date + return True + + # Sweden VAT number check fails is some cases from vatnumber library..so override this check method here + def check_vat_se(self, vat): + ''' + Check Sweden VAT number. + ''' + if len(vat) != 12: + return False + try: + int(vat) + except: + return False + #if int(vat[9:11]) <= 0: Fixed in OpenERP + if int(vat[9:11]) < 0: + return False + + sum = vatnumber.mult_add(2, int(vat[0])) + int(vat[1]) + \ + vatnumber.mult_add(2, int(vat[2])) + int(vat[3]) + \ + vatnumber.mult_add(2, int(vat[4])) + int(vat[5]) + \ + vatnumber.mult_add(2, int(vat[6])) + int(vat[7]) + \ + vatnumber.mult_add(2, int(vat[8])) + check = 10 - (sum % 10) + if check == 10: + check = 0 + if check != int(vat[9]): + return False + return True + + # Italy VAT number check fails is some cases from vatnumber library..so override this check method here + def check_vat_it(self, vat): + ''' + Check Italy VAT number. + ''' + if len(vat) != 11: + return False + try: + int(vat) + except: + return False + if int(vat[0:7]) <= 0: + return False + if int(vat[7:10]) <= 0: + return False + if int(vat[7:10]) > 100 and int(vat[7:10]) < 120: + return False +# Fixed in OpenERP +# if int(vat[7:10]) > 121: +# return False + + sum = int(vat[0]) + vatnumber.mult_add(2, int(vat[1])) + int(vat[2]) + \ + vatnumber.mult_add(2, int(vat[3])) + int(vat[4]) + \ + vatnumber.mult_add(2, int(vat[5])) + int(vat[6]) + \ + vatnumber.mult_add(2, int(vat[7])) + int(vat[8]) + \ + vatnumber.mult_add(2, int(vat[9])) + check = 10 - (sum % 10) + if check == 10: + check = 0 + if check != int(vat[10]): + return False + return True + res_partner() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/base_vat/base_vat_view.xml b/addons/base_vat/base_vat_view.xml index 325c2c1ea4c..ab1d02d34ac 100644 --- a/addons/base_vat/base_vat_view.xml +++ b/addons/base_vat/base_vat_view.xml @@ -1,21 +1,21 @@ - + - res.partner.vat.inherit - res.partner - - + res.partner.vat.inherit + res.partner + + - - + + - + - + From a30138475f4f2a5d2f9ccf356ee448c0945f87b0 Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Wed, 6 Jul 2011 14:44:48 +0530 Subject: [PATCH 19/88] [IMP] base_vat: modification in import and remove external_dependencies bzr revid: psi@tinyerp.co.in-20110706091448-txl7skwpm10vuk3c --- addons/base_vat/__openerp__.py | 3 --- addons/base_vat/base_vat.py | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/addons/base_vat/__openerp__.py b/addons/base_vat/__openerp__.py index dda64ed584d..c538a419241 100644 --- a/addons/base_vat/__openerp__.py +++ b/addons/base_vat/__openerp__.py @@ -39,9 +39,6 @@ checking the validity of VAT Number assigned to partners in European countries. 'active': False, 'certificate': '0084849360989', 'images': ['images/1_partner_vat.jpeg'], - 'external_dependencies': { - 'python' : ['vatnumber'], - } } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_vat/base_vat.py b/addons/base_vat/base_vat.py index 4909afceb2f..e02a4c8d5b9 100644 --- a/addons/base_vat/base_vat.py +++ b/addons/base_vat/base_vat.py @@ -21,16 +21,13 @@ ############################################################################## import string +import datetime import vatnumber import re -import datetime from osv import osv, fields from tools.misc import ustr from tools.translate import _ -from tools.misc import ustr -import re -import datetime _ref_vat = { 'be': 'BE0477472701', 'at': 'ATU12345675', From da6ca2f3fe4309554f037c881eaf8272b4c96590 Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Wed, 6 Jul 2011 15:06:18 +0530 Subject: [PATCH 20/88] [IMP] base_vat: remove italian vat validation method from base_vat as it is now available in vatnumber library bzr revid: psi@tinyerp.co.in-20110706093618-fugp4zjdd1kueh1f --- addons/base_vat/base_vat.py | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/addons/base_vat/base_vat.py b/addons/base_vat/base_vat.py index e02a4c8d5b9..2bdd5c8e6ea 100644 --- a/addons/base_vat/base_vat.py +++ b/addons/base_vat/base_vat.py @@ -155,39 +155,6 @@ class res_partner(osv.osv): return False return True - # Italy VAT number check fails is some cases from vatnumber library..so override this check method here - def check_vat_it(self, vat): - ''' - Check Italy VAT number. - ''' - if len(vat) != 11: - return False - try: - int(vat) - except: - return False - if int(vat[0:7]) <= 0: - return False - if int(vat[7:10]) <= 0: - return False - if int(vat[7:10]) > 100 and int(vat[7:10]) < 120: - return False -# Fixed in OpenERP -# if int(vat[7:10]) > 121: -# return False - - sum = int(vat[0]) + vatnumber.mult_add(2, int(vat[1])) + int(vat[2]) + \ - vatnumber.mult_add(2, int(vat[3])) + int(vat[4]) + \ - vatnumber.mult_add(2, int(vat[5])) + int(vat[6]) + \ - vatnumber.mult_add(2, int(vat[7])) + int(vat[8]) + \ - vatnumber.mult_add(2, int(vat[9])) - check = 10 - (sum % 10) - if check == 10: - check = 0 - if check != int(vat[10]): - return False - return True - res_partner() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file From 37f65bc8bf0145881cc5b2bdf8cf87d6d4532931 Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Wed, 6 Jul 2011 15:21:49 +0530 Subject: [PATCH 21/88] [IMP] include vatnumber in package list as the base_vat module will use this package for vat validation bzr revid: psi@tinyerp.co.in-20110706095149-waba2fbq4imy9825 --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 930b266e66b..044a5888c61 100755 --- a/setup.py +++ b/setup.py @@ -89,7 +89,7 @@ if os.name == 'nt': "pydot", "asyncore","asynchat", "reportlab", "vobject", "HTMLParser", "select", "mako", "poplib", "imaplib", "smtplib", "email", "yaml", "DAV", - "uuid", "commands", "openerp", + "uuid", "commands", "openerp", "vatnumber" ], "excludes" : ["Tkconstants","Tkinter","tcl"], } @@ -164,6 +164,7 @@ setup(name = name, 'pyyaml', 'pywebdav', 'feedparser', + 'vatnumber', ], extras_require = { 'SSL' : ['pyopenssl'], From cc758b3c78424f15ced79a448d0f449b1920a083 Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Mon, 18 Jul 2011 15:14:51 +0530 Subject: [PATCH 22/88] [IMP] base_vat: remove sweden vat validation method from base_vat as it is now improved in vatnumber library bzr revid: psi@tinyerp.co.in-20110718094451-xuzeenufge64j7p4 --- addons/base_vat/base_vat.py | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/addons/base_vat/base_vat.py b/addons/base_vat/base_vat.py index 2bdd5c8e6ea..9f40f656d4e 100644 --- a/addons/base_vat/base_vat.py +++ b/addons/base_vat/base_vat.py @@ -128,33 +128,6 @@ class res_partner(osv.osv): #Valid format and valid date return True - # Sweden VAT number check fails is some cases from vatnumber library..so override this check method here - def check_vat_se(self, vat): - ''' - Check Sweden VAT number. - ''' - if len(vat) != 12: - return False - try: - int(vat) - except: - return False - #if int(vat[9:11]) <= 0: Fixed in OpenERP - if int(vat[9:11]) < 0: - return False - - sum = vatnumber.mult_add(2, int(vat[0])) + int(vat[1]) + \ - vatnumber.mult_add(2, int(vat[2])) + int(vat[3]) + \ - vatnumber.mult_add(2, int(vat[4])) + int(vat[5]) + \ - vatnumber.mult_add(2, int(vat[6])) + int(vat[7]) + \ - vatnumber.mult_add(2, int(vat[8])) - check = 10 - (sum % 10) - if check == 10: - check = 0 - if check != int(vat[9]): - return False - return True - res_partner() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file From 62ba542130f9152dae21319c31624d941cf187dc Mon Sep 17 00:00:00 2001 From: Viktor Nagy Date: Fri, 22 Jul 2011 08:27:48 +0200 Subject: [PATCH 23/88] fixed repeatIn with specified tag bug lp bug: https://launchpad.net/bugs/592584 fixed bzr revid: viktor.nagy@toolpart.hu-20110722062748-pz8bp77myr4j3ge0 --- openerp/report/preprocess.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openerp/report/preprocess.py b/openerp/report/preprocess.py index c84ce66b472..78703cb1e78 100644 --- a/openerp/report/preprocess.py +++ b/openerp/report/preprocess.py @@ -66,10 +66,12 @@ class report(object): match = html_parents if txt.group(3): match = [txt.group(3)] - n = node - while n.tag not in match: - n = n.getparent() - n.set('rml_loop', txt.group(2)) + if match[0].startswith("'"): + match[0] = match[0][1:-1] + n2= node + while n2.tag not in match: + n2 = n2.getparent() + n2.set('rml_loop', txt.group(2)) return '[['+txt.group(1)+"''"+txt.group(4)+']]' t = _regex1.sub(_sub1, node.text or node.tail) if t == " ": From f25e0e9f485bf678dfc0e51a2d8ecfd702859ad2 Mon Sep 17 00:00:00 2001 From: Viktor Nagy Date: Fri, 22 Jul 2011 08:47:49 +0200 Subject: [PATCH 24/88] Added documentation to workflow_service methods. bzr revid: viktor.nagy@toolpart.hu-20110722064749-ovx9biphwz50tizd --- openerp/workflow/wkf_service.py | 66 +++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/openerp/workflow/wkf_service.py b/openerp/workflow/wkf_service.py index 6f5059e6817..eeccb4b7e77 100644 --- a/openerp/workflow/wkf_service.py +++ b/openerp/workflow/wkf_service.py @@ -27,6 +27,16 @@ import openerp.netsvc as netsvc import openerp.pooler as pooler class workflow_service(netsvc.Service): + """ + Sometimes you might want to fire a signal or re-evaluate the current state + of a workflow using the service's API. You can access the workflow services + using: + + >>> import netsvc + >>> wf_service = netsvc.LocalService("workflow") + + Then you can use the following methods. + """ def __init__(self, name='workflow', audience='*'): netsvc.Service.__init__(self, name, audience) self.exportMethod(self.trg_write) @@ -42,12 +52,31 @@ class workflow_service(netsvc.Service): self.wkf_on_create_cache[cr.dbname]={} def trg_write(self, uid, res_type, res_id, cr): + """ + Reevaluates the specified workflow instance. Thus if any condition for + a transition have been changed in the backend, then running ``trg_write`` + will move the workflow over that transition. + + :param res_type: the model name + :param res_id: the model instance id the workflow belongs to + :param cr: a database cursor + """ ident = (uid,res_type,res_id) cr.execute('select id from wkf_instance where res_id=%s and res_type=%s and state=%s', (res_id or None,res_type or None, 'active')) for (id,) in cr.fetchall(): instance.update(cr, id, ident) def trg_trigger(self, uid, res_type, res_id, cr): + """ + Activate a trigger. + + If a workflow instance is waiting for a trigger from another model, then this + trigger can be activated if its conditions are met. + + :param res_type: the model name + :param res_id: the model instance id the workflow belongs to + :param cr: a database cursor + """ cr.execute('select instance_id from wkf_triggers where res_id=%s and model=%s', (res_id,res_type)) res = cr.fetchall() for (instance_id,) in res: @@ -56,10 +85,24 @@ class workflow_service(netsvc.Service): instance.update(cr, instance_id, ident) def trg_delete(self, uid, res_type, res_id, cr): + """ + Delete a workflow instance + + :param res_type: the model name + :param res_id: the model instance id the workflow belongs to + :param cr: a database cursor + """ ident = (uid,res_type,res_id) instance.delete(cr, ident) def trg_create(self, uid, res_type, res_id, cr): + """ + Create a new workflow instance + + :param res_type: the model name + :param res_id: the model instance id to own the created worfklow instance + :param cr: a database cursor + """ ident = (uid,res_type,res_id) self.wkf_on_create_cache.setdefault(cr.dbname, {}) if res_type in self.wkf_on_create_cache[cr.dbname]: @@ -72,6 +115,14 @@ class workflow_service(netsvc.Service): instance.create(cr, ident, wkf_id) def trg_validate(self, uid, res_type, res_id, signal, cr): + """ + Fire a signal on a given workflow instance + + :param res_type: the model name + :param res_id: the model instance id the workflow belongs to + :signal: the signal name to be fired + :param cr: a database cursor + """ result = False ident = (uid,res_type,res_id) # ids of all active workflow instances for a corresponding resource (id, model_nam) @@ -81,10 +132,19 @@ class workflow_service(netsvc.Service): result = result or res2 return result - # make all workitems which are waiting for a (subflow) workflow instance - # for the old resource point to the (first active) workflow instance for - # the new resource def trg_redirect(self, uid, res_type, res_id, new_rid, cr): + """ + Re-bind a workflow instance to another instance of the same model. + + Make all workitems which are waiting for a (subflow) workflow instance + for the old resource point to the (first active) workflow instance for + the new resource. + + :param res_type: the model name + :param res_id: the model instance id the workflow belongs to + :param new_rid: the model instance id to own the worfklow instance + :param cr: a database cursor + """ # get ids of wkf instances for the old resource (res_id) #CHECKME: shouldn't we get only active instances? cr.execute('select id, wkf_id from wkf_instance where res_id=%s and res_type=%s', (res_id, res_type)) From 7d7ae4b0fea22b16a140c0c83e8f54dd7ce07623 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Mon, 25 Jul 2011 14:14:16 +0530 Subject: [PATCH 25/88] [FIX] Invoice company change (Multi-company) lp bug: https://launchpad.net/bugs/812843 fixed bzr revid: ara@tinyerp.com-20110725084416-ct30t2i2s2feze0k --- openerp/addons/base/ir/ir.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/addons/base/ir/ir.xml b/openerp/addons/base/ir/ir.xml index 1280ad5f5e7..ea3103f9b9a 100644 --- a/openerp/addons/base/ir/ir.xml +++ b/openerp/addons/base/ir/ir.xml @@ -1748,7 +1748,7 @@ Property multi-company - ['|',('company_id','=',user.company_id.id),('company_id','=',False)] + ['|',('company_id','child_of',[user.company_id.id]),('company_id','=',False)] From 432931dda597f72261f2d68c9252b41f3d50791d Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 24 Aug 2011 23:19:43 +0200 Subject: [PATCH 26/88] Add active field on account.fiscal.position. Fixes LP bug #768847 lp bug: https://launchpad.net/bugs/768847 fixed bzr revid: alexis@via.ecp.fr-20110824211943-kcfp6133556zropc --- addons/account/partner.py | 5 +++++ addons/account/partner_view.xml | 1 + 2 files changed, 6 insertions(+) diff --git a/addons/account/partner.py b/addons/account/partner.py index 6ff3879889c..36fd88183f2 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -28,12 +28,17 @@ class account_fiscal_position(osv.osv): _description = 'Fiscal Position' _columns = { 'name': fields.char('Fiscal Position', size=64, required=True), + 'active': fields.boolean('Active', help="By unchecking the active field, you may hide a fiscal position without deleting it."), 'company_id': fields.many2one('res.company', 'Company'), 'account_ids': fields.one2many('account.fiscal.position.account', 'position_id', 'Account Mapping'), 'tax_ids': fields.one2many('account.fiscal.position.tax', 'position_id', 'Tax Mapping'), 'note': fields.text('Notes', translate=True), } + _defaults = { + 'active': True, + } + def map_tax(self, cr, uid, fposition_id, taxes, context=None): if not taxes: return [] diff --git a/addons/account/partner_view.xml b/addons/account/partner_view.xml index fbee97875ae..6051e2bc943 100644 --- a/addons/account/partner_view.xml +++ b/addons/account/partner_view.xml @@ -9,6 +9,7 @@
+ From 8d0cf999ac4763570d431d5329f32a1cabfa0c19 Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Fri, 26 Aug 2011 16:05:16 +0530 Subject: [PATCH 27/88] [FIX]:_inherits for multilevel inheritence lp bug: https://launchpad.net/bugs/823691 fixed bzr revid: nch@tinyerp.com-20110826103516-o220jqwqdr3uwjhn --- openerp/osv/fields.py | 10 +++++--- openerp/osv/orm.py | 54 ++++++++++++++++++++++--------------------- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py index 782cc8e796a..181be7547d2 100644 --- a/openerp/osv/fields.py +++ b/openerp/osv/fields.py @@ -53,7 +53,7 @@ def _symbol_set(symb): class _column(object): """ Base of all fields, a database column - + An instance of this object is a *description* of a database column. It will not hold any data, but only provide the methods to manipulate data of an ORM record or even prepare/update the database to hold such a field of data. @@ -1285,7 +1285,7 @@ class property(function): def _fnct_read(self, obj, cr, uid, ids, prop_names, obj_dest, context=None): prop = obj.pool.get('ir.property') - # get the default values (for res_id = False) for the property fields + # get the default values (for res_id = False) for the property fields default_val = self._get_defaults(obj, cr, uid, prop_names, context) # build the dictionary that will be returned @@ -1407,12 +1407,16 @@ class column_info(object): :attr parent_column: the name of the column containing the m2o relationship to the parent model that contains this column, None for local columns. + :attr original_parent: if the column is inherited, name of the original + parent model that contains it i.e in case of multilevel + inheritence, None for local columns. """ - def __init__(self, name, column, parent_model=None, parent_column=None): + def __init__(self, name, column, parent_model=None, parent_column=None, original_parent=None): self.name = name self.column = column self.parent_model = parent_model self.parent_column = parent_column + self.original_parent = original_parent # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index d4a5d808990..c87446f5d85 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -38,7 +38,7 @@ - classicals (varchar, integer, boolean, ...) - relations (one2many, many2one, many2many) - functions - + """ import calendar @@ -168,7 +168,7 @@ def modifiers_tests(): test_modifiers({}, '{}') test_modifiers({"invisible": True}, '{"invisible": true}') test_modifiers({"invisible": False}, '{}') - + def check_object_name(name): """ Check if the given name is a valid openerp object name. @@ -255,7 +255,7 @@ class browse_null(object): # class browse_record_list(list): """ Collection of browse objects - + Such an instance will be returned when doing a ``browse([ids..])`` and will be iterable, yielding browse() objects """ @@ -270,9 +270,9 @@ class browse_record_list(list): class browse_record(object): """ An object that behaves like a row of an object's table. It has attributes after the columns of the corresponding object. - + Examples:: - + uobj = pool.get('res.users') user_rec = uobj.browse(cr, uid, 104) name = user_rec.name @@ -1093,7 +1093,7 @@ class orm_template(object): if line[i] and skip: return False continue - + #set the mode for m2o, o2m, m2m : xml_id/id/name if len(field) == len(prefix)+1: mode = False @@ -1106,7 +1106,7 @@ class orm_template(object): for db_id in line.split(config.get('csv_internal_sep')): res.append(_get_id(relation, db_id, current_module, mode)) return [(6,0,res)] - + # ID of the record using a XML ID if field[len(prefix)]=='id': try: @@ -1130,9 +1130,9 @@ class orm_template(object): relation_obj = self.pool.get(relation) newfd = relation_obj.fields_get( cr, uid, context=context ) pos = position - + res = many_ids(line[i], relation, current_module, mode) - + first = 0 while pos < len(datas): res2 = process_liness(self, datas, prefix + [field[len(prefix)]], current_module, relation_obj._name, newfd, pos, first) @@ -1142,15 +1142,15 @@ class orm_template(object): nbrmax = max(nbrmax, pos) warning += w2 first += 1 - + if data_res_id2: res.append((4, data_res_id2)) - + if (not newrow) or not reduce(lambda x, y: x or y, newrow.values(), 0): break res.append( (data_res_id2 and 1 or 0, data_res_id2 or 0, newrow) ) - + elif fields_def[field[len(prefix)]]['type']=='many2one': relation = fields_def[field[len(prefix)]]['relation'] @@ -1179,7 +1179,7 @@ class orm_template(object): else: res = line[i] - + row[field[len(prefix)]] = res or False result = (row, nbrmax, warning, data_res_id, xml_id) @@ -1193,7 +1193,7 @@ class orm_template(object): position = 0 while position Date: Mon, 12 Sep 2011 14:44:18 +0530 Subject: [PATCH 28/88] [FIX]:problem when coping the _inherits record the base class record was not created resulting the new record to refer the same parent that the old record is referring bzr revid: nch@tinyerp.com-20110912091418-l71l0xj5lovrf8f1 --- openerp/osv/orm.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index c87446f5d85..086e9a153d8 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -4053,7 +4053,7 @@ class orm(orm_template): upd_todo = [] for v in vals.keys(): if v in self._inherit_fields: - (table, col, col_detail) = self._inherit_fields[v] + (table, col, col_detail, original_parent) = self._inherit_fields[v] tocreate[table][v] = vals[v] del vals[v] else: @@ -4608,9 +4608,12 @@ class orm(orm_template): # force a clean recompute! for parent_column in ['parent_left', 'parent_right']: data.pop(parent_column, None) - - for v in self._inherits: - del data[self._inherits[v]] + # remove _inherits field's from data recursively + def remove_ids(inherits_dict): + for parent_table in inherits_dict: + del data[inherits_dict[parent_table]] + remove_ids(self.pool.get(parent_table)._inherits) + remove_ids(self._inherits) return data def copy_translations(self, cr, uid, old_id, new_id, context=None): From b9c10b045cf1406a4f65d9060ce4c52295f8ff18 Mon Sep 17 00:00:00 2001 From: "Dhara (OpenERP)" <> Date: Mon, 12 Sep 2011 21:38:09 -0700 Subject: [PATCH 29/88] [IMP] currency position for report bzr revid: dhara_openerp-20110913043809-2gq0chqs4m0yq1nq --- openerp/addons/base/res/res_currency.py | 7 ++++--- openerp/addons/base/res/res_currency_view.xml | 1 + openerp/report/report_sxw.py | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/openerp/addons/base/res/res_currency.py b/openerp/addons/base/res/res_currency.py index 3b7e427a923..271c7dd68c0 100644 --- a/openerp/addons/base/res/res_currency.py +++ b/openerp/addons/base/res/res_currency.py @@ -62,12 +62,13 @@ class res_currency(osv.osv): 'active': fields.boolean('Active'), 'company_id':fields.many2one('res.company', 'Company'), 'date': fields.date('Date'), - 'base': fields.boolean('Base') - + 'base': fields.boolean('Base'), + 'position_on_report': fields.selection([('after','After Amount'),('before','Before Amount')], 'Symbol position in reports', help="Determines where the currency symbol is printed within reports, after or before the amount.") } _defaults = { 'active': lambda *a: 1, - 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'res.currency', context=c) + 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'res.currency', context=c), + 'position_on_report' : 'after', } _order = "name" diff --git a/openerp/addons/base/res/res_currency_view.xml b/openerp/addons/base/res/res_currency_view.xml index 8d747c882b1..efd9f8043bb 100644 --- a/openerp/addons/base/res/res_currency_view.xml +++ b/openerp/addons/base/res/res_currency_view.xml @@ -42,6 +42,7 @@ + diff --git a/openerp/report/report_sxw.py b/openerp/report/report_sxw.py index 210a54760c4..81d83026543 100644 --- a/openerp/report/report_sxw.py +++ b/openerp/report/report_sxw.py @@ -264,7 +264,7 @@ class rml_parse(object): d = obj._field.digits[1] or DEFAULT_DIGITS return d - def formatLang(self, value, digits=None, date=False, date_time=False, grouping=True, monetary=False, dp=False): + def formatLang(self, value, digits=None, date=False, date_time=False, grouping=True, monetary=False, dp=False, currency_obj=False): """ Assuming 'Account' decimal.precision=3: formatLang(value) -> digits=2 (default) @@ -302,7 +302,9 @@ class rml_parse(object): date = datetime(*value.timetuple()[:6]) return date.strftime(date_format) - return self.lang_dict['lang_obj'].format('%.' + str(digits) + 'f', value, grouping=grouping, monetary=monetary) + res = self.lang_dict['lang_obj'].format('%.' + str(digits) + 'f', value, grouping=grouping, monetary=monetary) + res = currency_obj and currency_obj.position_on_report and (currency_obj.position_on_report == 'after' and '%s %s'%(res,currency_obj.symbol) or '%s %s'%(currency_obj.symbol, res) ) or res + return res def repeatIn(self, lst, name,nodes_parent=False): ret_lst = [] From 51d48726073de3f65a2a46574446a4573cbc56aa Mon Sep 17 00:00:00 2001 From: "Dhara (OpenERP)" <> Date: Mon, 12 Sep 2011 21:39:47 -0700 Subject: [PATCH 30/88] [IMP] currency position for report bzr revid: dhara_openerp-20110913043947-u7h84s12f6iel79y --- .../report/account_aged_partner_balance.rml | 42 +++++++++---------- addons/account/report/account_balance.rml | 2 +- .../account/report/account_balance_sheet.rml | 12 +++--- .../account_balance_sheet_horizontal.rml | 8 ++-- .../report/account_central_journal.rml | 8 ++-- .../report/account_general_journal.rml | 12 +++--- .../account/report/account_general_ledger.rml | 10 ++--- .../account_general_ledger_landscape.rml | 10 ++--- addons/account/report/account_journal.rml | 18 ++++---- .../report/account_partner_balance.rml | 8 ++-- .../account/report/account_partner_ledger.rml | 12 +++--- .../report/account_partner_ledger_other.rml | 12 +++--- .../account/report/account_print_invoice.rml | 12 +++--- .../account/report/account_print_overdue.rml | 10 ++--- .../report/account_profit_horizontal.rml | 12 +++--- addons/account/report/account_profit_loss.rml | 16 +++---- addons/account/report/account_tax_code.rml | 6 +-- addons/account/report/account_tax_report.rml | 2 +- .../report/crossovered_analytic.rml | 4 +- .../report/analytic_account_budget_report.rml | 14 +++---- .../account_budget/report/budget_report.rml | 12 +++--- .../report/crossovered_budget_report.rml | 12 +++--- addons/purchase/report/order.rml | 8 ++-- addons/sale/report/sale_order.rml | 8 ++-- 24 files changed, 135 insertions(+), 135 deletions(-) diff --git a/addons/account/report/account_aged_partner_balance.rml b/addons/account/report/account_aged_partner_balance.rml index c76aba31763..3f2a05b7652 100644 --- a/addons/account/report/account_aged_partner_balance.rml +++ b/addons/account/report/account_aged_partner_balance.rml @@ -196,25 +196,25 @@ Account Total - [[ formatLang(get_direction('6')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(get_direction('6'), currency_obj=company.currency_id) ]] - [[ formatLang(get_for_period('4')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(get_for_period('4'), currency_obj=company.currency_id) ]] - [[ formatLang(get_for_period('3')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(get_for_period('3'), currency_obj=company.currency_id) ]] - [[ formatLang(get_for_period('2')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(get_for_period('2'), currency_obj=company.currency_id) ]] - [[ formatLang(get_for_period('1')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(get_for_period('1'), currency_obj=company.currency_id) ]] - [[ formatLang(get_for_period('0')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(get_for_period('0'), currency_obj=company.currency_id) ]] - [[ formatLang(get_total('5')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(get_total('5'), currency_obj=company.currency_id) ]] @@ -224,25 +224,25 @@ [[ partner['name'] ]] - [[ formatLang(partner['direction']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(partner['direction'], currency_obj=company.currency_id) ]] - [[ formatLang(partner['4'])]] [[ company.currency_id.symbol ]] + [[ formatLang(partner['4'], currency_obj=company.currency_id) ]] - [[ formatLang(partner['3'])]] [[ company.currency_id.symbol ]] + [[ formatLang(partner['3'], currency_obj=company.currency_id) ]] - [[ formatLang(partner['2']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(partner['2'], currency_obj=company.currency_id) ]] - [[ formatLang(partner['1']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(partner['1'], currency_obj=company.currency_id) ]] - [[ formatLang(partner['0']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(partner['0'], currency_obj=company.currency_id) ]] - [[ formatLang(partner['total']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(partner['total'], currency_obj=company.currency_id) ]] @@ -251,25 +251,25 @@ [[ not_partner['name'] ]] - [[ formatLang(not_partner['direction']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(not_partner['direction'], currency_obj=company.currency_id) ]] - [[ formatLang(not_partner['4'])]] [[ company.currency_id.symbol ]] + [[ formatLang(not_partner['4'], currency_obj=company.currency_id) ]] - [[ formatLang(not_partner['3'])]] [[ company.currency_id.symbol ]] + [[ formatLang(not_partner['3'], currency_obj=company.currency_id) ]] - [[ formatLang(not_partner['2']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(not_partner['2'], currency_obj=company.currency_id) ]] - [[ formatLang(not_partner['1']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(not_partner['1'], currency_obj=company.currency_id) ]] - [[ formatLang(not_partner['0']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(not_partner['0'], currency_obj=company.currency_id) ]] - [[ formatLang(not_partner['total']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(not_partner['total'], currency_obj=company.currency_id) ]] diff --git a/addons/account/report/account_balance.rml b/addons/account/report/account_balance.rml index 3d971862bdc..491740b4673 100644 --- a/addons/account/report/account_balance.rml +++ b/addons/account/report/account_balance.rml @@ -296,7 +296,7 @@ [[ (a['type']<>'view' and setTag('para','para',{'fontName':"Helvetica"})) or removeParentNode('font') ]][[ '..'*(a['level']-1) ]][[ a['name'] ]] [[ (a['type']<>'view' and setTag('para','para',{'fontName':"Helvetica"})) or removeParentNode('font') ]][[ a['type']=='view' and removeParentNode('font') ]][[ formatLang(a['debit']) ]][[ a['type']<>'view' and removeParentNode('font') ]] [[formatLang(a['debit']) ]] [[ (a['type']<>'view' and setTag('para','para',{'fontName':"Helvetica"})) or removeParentNode('font')]][[ a['type']=='view' and removeParentNode('font') ]][[ formatLang(a['credit']) ]][[ a['type']<>'view' and removeParentNode('font') ]] [[ formatLang(a['credit']) ]] - [[ (a['type']<>'view' and setTag('para','para',{'fontName':"Helvetica"})) or removeParentNode('font') ]][[ a['type']=='view' and removeParentNode('font') ]][[ formatLang(a['balance']) ]] [[ company.currency_id.symbol ]][[ a['type']<>'view' and removeParentNode('font') ]] [[ formatLang(a['balance']) ]] [[ company.currency_id.symbol ]] + [[ (a['type']<>'view' and setTag('para','para',{'fontName':"Helvetica"})) or removeParentNode('font') ]][[ a['type']=='view' and removeParentNode('font') ]][[ formatLang(a['balance'], currency_obj=company.currency_id) ]][[ a['type']<>'view' and removeParentNode('font') ]] [[ formatLang(a['balance'], currency = company.currency_id) ]] diff --git a/addons/account/report/account_balance_sheet.rml b/addons/account/report/account_balance_sheet.rml index 205bfff497b..d72376c4f1a 100644 --- a/addons/account/report/account_balance_sheet.rml +++ b/addons/account/report/account_balance_sheet.rml @@ -240,8 +240,8 @@ [[ setTag('tr','tr',{'style': 'Table'+str(min(3,a['level']))}) ]] [[ (a['type'] =='view' and a['level'] >= 3) and setTag('para','para',{'style': 'terp_level_3_code_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a['level']))+'_code'}) ]][[ a['code'] ]] [[ (a['type'] =='view' and a['level'] >= 3) and setTag('para','para',{'style': 'terp_level_'+str(min(3,a['level']))+'_name_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(4,a['level']))+'_name'}) ]][[ a['name'] ]] - [[ (a['level'] <>2) or removeParentNode('td') ]][[ (a['type'] =='view' and a['level'] >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a['level']))+'_balance'}) ]][[ formatLang(a['balance']) ]] [[company.currency_id.symbol ]] - [[ a['level'] == 2 or removeParentNode('td') ]][[ formatLang(a['balance']) ]] [[company.currency_id.symbol ]] + [[ (a['level'] <>2) or removeParentNode('td') ]][[ (a['type'] =='view' and a['level'] >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a['level']))+'_balance'}) ]][[ formatLang(a['balance'], currency = company.currency_id) ]] + [[ a['level'] == 2 or removeParentNode('td') ]][[ formatLang(a['balance'], currency = company.currency_id) ]] @@ -250,7 +250,7 @@ Balance: - [[ formatLang(sum_cr()) ]] [[ company.currency_id.symbol ]] + [[ formatLang(sum_cr(), currency = company.currency_id) ]] @@ -282,8 +282,8 @@ [[ setTag('tr','tr',{'style': 'Table'+str(min(3,a['level']))}) ]] [[ (a['type'] =='view' and a['level'] >= 3) and setTag('para','para',{'style': 'terp_level_3_code_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a['level']))+'_code'}) ]][[ a['code'] ]] [[ (a['type'] =='view' and a['level'] >= 3) and setTag('para','para',{'style': 'terp_level_'+str(min(3,a['level']))+'_name_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(4,a['level']))+'_name'}) ]][[ a['name'] ]] - [[ (a['level'] <>2) or removeParentNode('td') ]][[ (a['type'] =='view' and a['level'] >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a['level']))+'_balance'}) ]][[ formatLang(a['balance']) ]] [[company.currency_id.symbol ]] - [[ a['level'] == 2 or removeParentNode('td') ]][[ formatLang(a['balance']) ]] [[company.currency_id.symbol ]] + [[ (a['level'] <>2) or removeParentNode('td') ]][[ (a['type'] =='view' and a['level'] >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a['level']))+'_balance'}) ]][[ formatLang(a['balance'], currency = company.currency_id) ]] + [[ a['level'] == 2 or removeParentNode('td') ]][[ formatLang(a['balance'], currency = company.currency_id) ]] @@ -292,7 +292,7 @@ Balance: - [[ formatLang(sum_dr()) ]] [[ company.currency_id.symbol ]] + [[ formatLang(sum_dr(), currency = company.currency_id) ]] diff --git a/addons/account/report/account_balance_sheet_horizontal.rml b/addons/account/report/account_balance_sheet_horizontal.rml index 7e4f9f844a5..8f902352498 100644 --- a/addons/account/report/account_balance_sheet_horizontal.rml +++ b/addons/account/report/account_balance_sheet_horizontal.rml @@ -202,7 +202,7 @@ [[ '. '*(a['level1']-1) ]][[ a['level1']<4 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) or removeParentNode('font') ]][[ a['name1'] ]] - [[ a['level1']<4 and ( setTag('para','para',{'style':'terp_default_Right_9_Bold'})) or removeParentNode('font') ]][[ formatLang(a['balance1']) ]] [[ company.currency_id.symbol ]] + [[ a['level1']<4 and ( setTag('para','para',{'style':'terp_default_Right_9_Bold'})) or removeParentNode('font') ]][[ formatLang(a['balance1'], currency_obj=company.currency_id) ]] [[ repeatIn(get_lines(), 'a') ]] [[ a['level']<4 and ( setTag('para','para',{'style':'terp_default_Bold_9'})) or removeParentNode('font') ]][[ a['code'] ]][[ a['name']=='Net Profit' and setTag('para','para',{'style':'terp_default_Bold_9'}) or removeParentNode('font') ]] @@ -213,7 +213,7 @@ [[ a['level1']<4 and ( setTag('para','para',{'style':'terp_default_Right_9_Bold'})) or removeParentNode('font') ]] [[ a['name']=='Net Profit' and setTag('para','para',{'style':'terp_default_Right_9_Bold'}) or removeParentNode('font') ]] - [[(a['code'] and a['name']) and formatLang(a['balance']) or removeParentNode('font')]] [[ company.currency_id.symbol ]] + [[(a['code'] and a['name']) and formatLang(a['balance'], currency_obj=company.currency_id) or removeParentNode('font')]] @@ -223,13 +223,13 @@ Balance: - [[ formatLang(sum_cr()) ]] [[ company.currency_id.symbol ]] + [[ formatLang(sum_cr(), currency_obj=company.currency_id) ) ]] Balance: - [[ formatLang(sum_dr()) ]] [[ company.currency_id.symbol ]] + [[ formatLang(sum_dr(), currency_obj=company.currency_id) ) ]] diff --git a/addons/account/report/account_central_journal.rml b/addons/account/report/account_central_journal.rml index 33566083652..2233ddb3f2e 100644 --- a/addons/account/report/account_central_journal.rml +++ b/addons/account/report/account_central_journal.rml @@ -299,7 +299,7 @@ [[ formatLang( sum_debit(o.period_id.id, o.journal_id.id)) ]] [[ formatLang( sum_credit(o.period_id.id, o.journal_id.id)) ]] - [[ formatLang( sum_credit(o.period_id.id, o.journal_id.id)-sum_debit(o.period_id.id, o.journal_id.id) ) ]] [[ company.currency_id.symbol ]] + [[ formatLang( sum_credit(o.period_id.id, o.journal_id.id)-sum_debit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id ) ]] [[ display_currency(data) or removeParentNode('blockTable') ]] @@ -308,7 +308,7 @@ [[ formatLang( sum_debit(o.period_id.id, o.journal_id.id)) ]] [[ formatLang( sum_credit(o.period_id.id, o.journal_id.id)) ]] - [[ formatLang( sum_credit(o.period_id.id, o.journal_id.id)-sum_debit(o.period_id.id, o.journal_id.id) ) ]] [[ company.currency_id.symbol ]] + [[ formatLang( sum_credit(o.period_id.id, o.journal_id.id)-sum_debit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id ) ]] @@ -320,7 +320,7 @@ [[ line['name'] ]] [[ formatLang(line['debit']) ]] [[ formatLang(line['credit'])]] - [[ formatLang(line['credit']-line['debit']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(line['credit']-line['debit'], currency_obj=company.currency_id ) ]] [[ display_currency(data) or removeParentNode('blockTable') ]] @@ -329,7 +329,7 @@ [[ line['name'] ]] [[ formatLang(line['debit']) ]] [[ formatLang(line['credit'])]] - [[ formatLang(line['credit']-line['debit']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(line['credit']-line['debit'], currency_obj=company.currency_id ) ]] [[ (line['currency_id']==None or line['amount_currency']==None) and removeParentNode('font') ]] [[ formatLang(line['amount_currency'] ) ]] [[ line['currency_code'] or '' ]] diff --git a/addons/account/report/account_general_journal.rml b/addons/account/report/account_general_journal.rml index f4cc13069c8..0af13022a07 100644 --- a/addons/account/report/account_general_journal.rml +++ b/addons/account/report/account_general_journal.rml @@ -273,7 +273,7 @@ [[ formatLang(sum_debit()) ]] [[ formatLang( sum_credit()) ]] - [[ formatLang( sum_debit()- sum_credit()) ]] [[ company.currency_id.symbol ]] + [[ formatLang( sum_debit()- sum_credit(), currency_obj=company.currency_id) ]] [[ display_currency(data) or removeParentNode('blockTable') ]] @@ -290,7 +290,7 @@ [[ formatLang(sum_debit()) ]] [[ formatLang( sum_credit()) ]] - [[ formatLang( sum_credit()- sum_debit()) ]] [[ company.currency_id.symbol ]] + [[ formatLang( sum_credit()- sum_debit(), currency_obj=company.currency_id) ]] @@ -311,7 +311,7 @@ [[ formatLang(sum_credit_period(o.id)) ]] - [[ formatLang(sum_credit_period(o.id)-sum_debit_period(o.id)) ]] [[ company.currency_id.symbol ]] + [[ formatLang(sum_credit_period(o.id)-sum_debit_period(o.id), currency_obj=company.currency_id) ]] @@ -337,7 +337,7 @@ [[ formatLang(sum_credit_period(o.id)) ]] - [[ formatLang(sum_credit_period(o.id)-sum_debit_period(o.id)) ]] [[ company.currency_id.symbol ]] + [[ formatLang(sum_credit_period(o.id)-sum_debit_period(o.id), currency_obj=company.currency_id) ]] @@ -358,7 +358,7 @@ [[ formatLang(line['credit']) ]] - [[ formatLang(line['credit']-line['debit'] ) ]] [[ company.currency_id.symbol ]] + [[ formatLang(line['credit']-line['debit'], currency_obj=company.currency_id ) ]] @@ -371,7 +371,7 @@ [[ line['name'] ]] [[ formatLang(line['debit'] )]] [[ formatLang(line['credit']) ]] - [[ formatLang(line['credit']-line['debit'] ) ]] [[ company.currency_id.symbol ]] + [[ formatLang(line['credit']-line['debit'], currency_obj=company.currency_id ) ]] [[ (line['currency_id']==None or line['amount_currency']==None) and removeParentNode('font') ]] [[ formatLang(line['amount_currency'] ) ]] [[ line['currency_code'] or '' ]] diff --git a/addons/account/report/account_general_ledger.rml b/addons/account/report/account_general_ledger.rml index 15614444822..de62baed742 100644 --- a/addons/account/report/account_general_ledger.rml +++ b/addons/account/report/account_general_ledger.rml @@ -476,10 +476,10 @@ [[ formatLang(sum_credit_account(o), digits=get_digits(dp='Account')) ]] - [[ formatLang(sum_balance_account(o), digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(sum_balance_account(o), digits=get_digits(dp='Account'),currency_obj=company.currency_id) ]] - [[ o.currency_id and formatLang(sum_currency_amount_account(o), digits=get_digits(dp='Account')) + o.currency_id.symbol or '' ]] + [[ o.currency_id and formatLang(sum_currency_amount_account(o), digits=get_digits(dp='Account'),currency_obj=o.currency_id) or '' ]] @@ -515,7 +515,7 @@ [[ formatLang(line['credit'], digits=get_digits(dp='Account')) ]] - [[ formatLang(line['progress'], digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(line['progress'], digits=get_digits(dp='Account'),currency_obj=company.currency_id) ]] [[ (line.has_key('currency_id') and line['currency_id']==None or line['amount_currency']==None) and removeParentNode('font') ]] [[ formatLang(line['amount_currency'])]] [[ line['currency_code'] or '']] @@ -572,7 +572,7 @@ [[ formatLang(sum_credit_account(o), digits=get_digits(dp='Account')) ]] - [[ formatLang(sum_balance_account(o), digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(sum_balance_account(o), digits=get_digits(dp='Account'),currency_obj=company.currency_id) ]] @@ -608,7 +608,7 @@ [[ formatLang(line['credit'], digits=get_digits(dp='Account')) ]] - [[ formatLang(line['progress'], digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(line['progress'], digits=get_digits(dp='Account'),currency_obj=company.currency_id) ]] diff --git a/addons/account/report/account_general_ledger_landscape.rml b/addons/account/report/account_general_ledger_landscape.rml index ac100c3ecd0..ad5aef790d8 100644 --- a/addons/account/report/account_general_ledger_landscape.rml +++ b/addons/account/report/account_general_ledger_landscape.rml @@ -505,10 +505,10 @@ [[ formatLang(sum_credit_account(o), digits=get_digits(dp='Account')) ]] - [[ formatLang(sum_balance_account(o), digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(sum_balance_account(o), digits=get_digits(dp='Account'), currency = company.currency_id) ]] - [[ o.currency_id and formatLang(sum_currency_amount_account(o), digits=get_digits(dp='Account')) + o.currency_id.symbol or '' ]] + [[ o.currency_id and formatLang(sum_currency_amount_account(o), digits=get_digits(dp='Account'),currency_obj=o.currency_id) or '' ]] @@ -547,7 +547,7 @@ [[ formatLang(line['credit'], digits=get_digits(dp='Account')) ]] - [[ formatLang(line['progress'], digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(line['progress'], digits=get_digits(dp='Account'), currency_obj=company.currency_id) ]] [[ (line.has_key('currency_id') and line['currency_id']==None or line['amount_currency']==None) and removeParentNode('font') ]] [[ formatLang(line['amount_currency'])]] [[ line['currency_code'] or '']] @@ -607,7 +607,7 @@ [[ formatLang(sum_credit_account(o), digits=get_digits(dp='Account')) ]] - [[ formatLang(sum_balance_account(o), digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(sum_balance_account(o), digits=get_digits(dp='Account'), currency_obj=company.currency_id) ]] @@ -646,7 +646,7 @@ [[ formatLang(line['credit'], digits=get_digits(dp='Account')) ]] - [[ formatLang(line['progress'], digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(line['progress'], digits=get_digits(dp='Account'),currency_obj=company.currency_id) ]] diff --git a/addons/account/report/account_journal.rml b/addons/account/report/account_journal.rml index 9b0ac55bb56..9d305bae36b 100644 --- a/addons/account/report/account_journal.rml +++ b/addons/account/report/account_journal.rml @@ -247,8 +247,8 @@ - [[ formatLang(sum_debit(o.period_id.id, o.journal_id.id)) ]] [[ company.currency_id.symbol ]] - [[ formatLang(sum_credit(o.period_id.id, o.journal_id.id)) ]] [[ company.currency_id.symbol ]] + [[ formatLang(sum_debit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id) ]] + [[ formatLang(sum_credit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id) ]] [[lines(o.period_id.id, o.journal_id.id) or removeParentNode('story') ]] @@ -258,8 +258,8 @@ [[ line.account_id.code ]] [[ line.partner_id and strip_name(line.partner_id.name,17) ]] [[ strip_name(line.name,27) ]] - [[ formatLang(line.debit) ]] [[ company.currency_id.symbol ]] - [[ formatLang(line.credit) ]] [[ company.currency_id.symbol ]] + [[ formatLang(line.debit, currency_obj=company.currency_id) ]] + [[ formatLang(line.credit, currency_obj=company.currency_id) ]] @@ -282,8 +282,8 @@ - [[ formatLang(sum_debit(o.period_id.id, o.journal_id.id)) ]] [[ company.currency_id.symbol ]] - [[ formatLang(sum_credit(o.period_id.id, o.journal_id.id)) ]] [[ company.currency_id.symbol ]] + [[ formatLang(sum_debit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id) ]] + [[ formatLang(sum_credit(o.period_id.id, o.journal_id.id), currency_obj=company.currency_id) ]] @@ -295,9 +295,9 @@ [[ line.account_id.code ]] [[ line.partner_id and strip_name(line.partner_id.name,15) ]] [[ strip_name(line.name,17) ]] - [[ formatLang(line.debit) ]] [[ company.currency_id.symbol ]] - [[ formatLang(line.credit) ]] [[ company.currency_id.symbol ]] - [[ line.currency_id and formatLang(line.amount_currency) or '' ]] [[ line.currency_id.symbol or '']] + [[ formatLang(line.debit, currency_obj=company.currency_id) ]] + [[ formatLang(line.credit, currency_obj=company.currency_id) ]] + [[ line.currency_id and formatLang(line.amount_currency, currency_obj=line.currency_id) or '' ]] diff --git a/addons/account/report/account_partner_balance.rml b/addons/account/report/account_partner_balance.rml index 6425d6a4db6..7052c2efb8f 100644 --- a/addons/account/report/account_partner_balance.rml +++ b/addons/account/report/account_partner_balance.rml @@ -241,16 +241,16 @@ [[ formatLang(sum_debit()) ]] [[ formatLang(sum_credit()) ]] - [[ formatLang((sum_debit()-sum_credit())) ]] [[ company.currency_id.symbol ]] - [[ formatLang(sum_litige()) ]] [[ company.currency_id.symbol ]] + [[ formatLang((sum_debit()-sum_credit()), currency_obj=company.currency_id) ]] + [[ formatLang(sum_litige(), currency_obj=company.currency_id) ]] [[ repeatIn(lines(), 'a') ]][[ (a['type']==3 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]][[ a['ref'] ]] [[ a['type']==3 and a['code'] ]] [[ (a['type']==3 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]][[ a['name'] ]] [[ (a['type']==3 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]][[ formatLang(a['debit']) ]] [[ (a['type']==3 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]][[ formatLang(a['credit']) ]] - [[ (a['type']==3 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]][[ formatLang(a['balance']) ]] [[ company.currency_id.symbol ]] - [[ (a['type']==3 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]][[ formatLang(a['enlitige'] or 0.0) ]] [[ company.currency_id.symbol ]] + [[ (a['type']==3 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]][[ formatLang(a['balance'], currency_obj=company.currency_id) ]] + [[ (a['type']==3 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]][[ formatLang(a['enlitige'] or 0.0, currency_obj=company.currency_id) ]] diff --git a/addons/account/report/account_partner_ledger.rml b/addons/account/report/account_partner_ledger.rml index c1ef9b22502..1b423ad1e99 100644 --- a/addons/account/report/account_partner_ledger.rml +++ b/addons/account/report/account_partner_ledger.rml @@ -477,7 +477,7 @@ [[ formatLang((sum_credit_partner(p))) ]] - [[ formatLang((sum_debit_partner(p) - sum_credit_partner(p))) ]] [[ company.currency_id.symbol ]] + [[ formatLang((sum_debit_partner(p) - sum_credit_partner(p)), currency_obj=company.currency_id) ]] @@ -497,7 +497,7 @@ [[ formatLang(get_intial_balance(p)[0][1]) ]] - [[ formatLang(get_intial_balance(p)[0][2]) ]] [[ company.currency_id.symbol ]] + [[ formatLang(get_intial_balance(p)[0][2], currency_obj=company.currency_id) ]] @@ -528,7 +528,7 @@ [[ formatLang((line['credit'])) ]] - [[ formatLang((line['progress'])) ]] [[ company.currency_id.symbol ]] + [[ formatLang((line['progress']), currency_obj=company.currency_id) ]] @@ -581,7 +581,7 @@ [[ formatLang((sum_credit_partner(p))) ]] - [[ formatLang((sum_debit_partner(p) - sum_credit_partner(p))) ]] [[ company.currency_id.symbol ]] + [[ formatLang((sum_debit_partner(p) - sum_credit_partner(p)), currency_obj=company.currency_id) ]] @@ -604,7 +604,7 @@ [[ formatLang(get_intial_balance(p)[0][1]) ]] - [[ formatLang(get_intial_balance(p)[0][2]) ]] [[ company.currency_id.symbol ]] + [[ formatLang(get_intial_balance(p)[0][2], currency_obj=company.currency_id) ]] @@ -640,7 +640,7 @@ [[ formatLang((line['credit'])) ]] - [[ formatLang((line['progress'])) ]] [[ company.currency_id.symbol ]] + [[ formatLang((line['progress']), currency_obj=company.currency_id) ]] diff --git a/addons/account/report/account_partner_ledger_other.rml b/addons/account/report/account_partner_ledger_other.rml index 2f58fc8ec95..97ba9b554d9 100644 --- a/addons/account/report/account_partner_ledger_other.rml +++ b/addons/account/report/account_partner_ledger_other.rml @@ -482,7 +482,7 @@ [[ formatLang((sum_credit_partner(p))) ]] - [[ formatLang((sum_debit_partner(p) - sum_credit_partner(p))) ]] [[ company.currency_id.symbol ]] + [[ formatLang((sum_debit_partner(p) - sum_credit_partner(p)), currency_obj=company.currency_id) ]] @@ -502,7 +502,7 @@ [[ formatLang(get_intial_balance(p)[0][1]) ]] - [[ formatLang(get_intial_balance(p)[0][2]) ]] [[ company.currency_id.symbol ]] + [[ formatLang(get_intial_balance(p)[0][2], currency_obj=company.currency_id) ]] @@ -533,7 +533,7 @@ [[ formatLang((line['credit'])) ]] - [[ formatLang((line['progress'])) ]] [[ company.currency_id.symbol ]] + [[ formatLang((line['progress']), currency_obj=company.currency_id) ]] @@ -590,7 +590,7 @@ [[ formatLang((sum_credit_partner(p))) ]] - [[ formatLang((sum_debit_partner(p) - sum_credit_partner(p))) ]] [[ company.currency_id.symbol ]] + [[ formatLang((sum_debit_partner(p) - sum_credit_partner(p)), currency_obj=company.currency_id) ]] @@ -613,7 +613,7 @@ [[ formatLang(get_intial_balance(p)[0][1]) ]] - [[ formatLang(get_intial_balance(p)[0][2]) ]] [[ company.currency_id.symbol ]] + [[ formatLang(get_intial_balance(p)[0][2], currency_obj=company.currency_id) ]] @@ -649,7 +649,7 @@ [[ formatLang((line['credit'])) ]] - [[ formatLang((line['progress'])) ]] [[ company.currency_id.symbol ]] + [[ formatLang((line['progress']), currency_obj=company.currency_id) ]] diff --git a/addons/account/report/account_print_invoice.rml b/addons/account/report/account_print_invoice.rml index 0350fbf7379..db8f752a56d 100644 --- a/addons/account/report/account_print_invoice.rml +++ b/addons/account/report/account_print_invoice.rml @@ -263,7 +263,7 @@ [[ formatLang(l.discount, dp='Account') ]] - [[ formatLang(l.price_subtotal, dp='Account') ]] [[ o.currency_id.symbol ]] + [[ formatLang(l.price_subtotal, dp='Account', currency_obj=o.currency_id) ]] @@ -309,7 +309,7 @@ Net Total: - [[ formatLang(o.amount_untaxed, digits=get_digits(dp='Account')) ]] [[ o.currency_id.symbol ]] + [[ formatLang(o.amount_untaxed, digits=get_digits(dp='Account'), currency_obj=o.currency_id) ]] @@ -322,7 +322,7 @@ Taxes: - [[ formatLang(o.amount_tax, dp='Account') ]] [[ o.currency_id.symbol ]] + [[ formatLang(o.amount_tax, dp='Account', currency_obj=o.currency_id) ]] @@ -335,7 +335,7 @@ Total: - [[ formatLang(o.amount_total, digits=get_digits(dp='Account')) ]] [[ o.currency_id.symbol ]] + [[ formatLang(o.amount_total, digits=get_digits(dp='Account'), currency_obj=o.currency_id) ]] @@ -368,10 +368,10 @@ [[ t.name ]] - [[ formatLang(t.base, dp='Account') ]] [[ o.currency_id.symbol ]] + [[ formatLang(t.base, dp='Account', currency_obj=o.currency_id) ]] - [[ (t.tax_code_id and t.tax_code_id.notprintable) and removeParentNode('blockTable') or '' ]] [[ formatLang(t.amount, digits=get_digits(dp='Account')) ]] [[ o.currency_id.symbol ]] + [[ (t.tax_code_id and t.tax_code_id.notprintable) and removeParentNode('blockTable') or '' ]] [[ formatLang(t.amount, digits=get_digits(dp='Account'), currency_obj=o.currency_id) ]] diff --git a/addons/account/report/account_print_overdue.rml b/addons/account/report/account_print_overdue.rml index 0797d544f9b..25ccad25377 100644 --- a/addons/account/report/account_print_overdue.rml +++ b/addons/account/report/account_print_overdue.rml @@ -219,7 +219,7 @@ [[ (line['account_id']['type'] == 'receivable' and formatLang(line['credit']) or 0) or (line['account_id']['type'] == 'payable' and formatLang(line['debit'] * -1) or 0) ]] - [[ formatLang((line['date_maturity'] < time.strftime('%Y-%m-%d'))) and formatLang(line['debit'] - line['credit']) ]] [[ company.currency_id.symbol ]] + [[ formatLang((line['date_maturity'] < time.strftime('%Y-%m-%d'))) and formatLang(line['debit'] - line['credit'], currency_obj=company.currency_id) ] [[ line['blocked'] and 'X' or '' ]] @@ -244,7 +244,7 @@ [[ formatLang((reduce(lambda x, y: x + ((y['account_id']['type'] == 'receivable' and y['credit'] or 0) or (y['account_id']['type'] == 'payable' and y['debit'] * -1 or 0)), getLines(o), 0))) ]] - [[ formatLang((reduce(lambda x, y: x + (y['debit'] - y['credit']), filter(lambda x: x['date_maturity'] < time.strftime('%Y-%m-%d'), getLines(o)), 0))) ]] [[ company.currency_id.symbol ]] + [[ formatLang((reduce(lambda x, y: x + (y['debit'] - y['credit']), filter(lambda x: x['date_maturity'] < time.strftime('%Y-%m-%d'), getLines(o)), 0)), currency_obj=company.currency_id) ]] @@ -264,7 +264,7 @@ Balance : - [[ formatLang((reduce(lambda x, y: x +(y['debit'] - y['credit']), getLines(o), 0))) ]] [[ company.currency_id.symbol ]] + [[ formatLang((reduce(lambda x, y: x +(y['debit'] - y['credit']), getLines(o), 0)), currency_obj=company.currency_id) ]] @@ -279,10 +279,10 @@ - Total amount due: [[ formatLang((reduce(lambda x, y: x + (y['debit'] - y['credit']), getLines(o), 0))) ]] [[ company.currency_id.symbol ]]. + Total amount due: [[ formatLang((reduce(lambda x, y: x + (y['debit'] - y['credit']), getLines(o), 0)), currency_obj=company.currency_id) ]]. - \ No newline at end of file + diff --git a/addons/account/report/account_profit_horizontal.rml b/addons/account/report/account_profit_horizontal.rml index 6c70bb47310..7737fc8769c 100644 --- a/addons/account/report/account_profit_horizontal.rml +++ b/addons/account/report/account_profit_horizontal.rml @@ -221,7 +221,7 @@ - [[ a['level']<4 and ( setTag('para','para',{'style':'terp_default_Right_9_Bold'})) or removeParentNode('font') ]][[ formatLang(abs(a['balance'])) ]] [[ company.currency_id.symbol ]] + [[ a['level']<4 and ( setTag('para','para',{'style':'terp_default_Right_9_Bold'})) or removeParentNode('font') ]][[ formatLang(abs(a['balance']), currency_obj=company.currency_id) ]] @@ -234,7 +234,7 @@ - [[ a['level']<4 and ( setTag('para','para',{'style':'terp_default_Right_9_Bold'})) or removeParentNode('font') ]][[(a['code1'] and a['name1']) and formatLang(abs(a['balance1'])) or removeParentNode('font') ]] [[ company.currency_id.symbol ]] + [[ a['level']<4 and ( setTag('para','para',{'style':'terp_default_Right_9_Bold'})) or removeParentNode('font') ]][[(a['code1'] and a['name1']) and formatLang(abs(a['balance1']), currency_obj=company.currency_id) or removeParentNode('font') ]] @@ -247,7 +247,7 @@ [[ final_result()['type'] == 'Net Profit' and final_result()['type'] or '' ]] - [[ final_result()['balance'] and final_result()['type'] == 'Net Profit' and formatLang(abs(final_result()['balance'])) ]] [[ company.currency_id.symbol ]] + [[ final_result()['balance'] and final_result()['type'] == 'Net Profit' and formatLang(abs(final_result()['balance']), currency_obj=company.currency_id) ]] @@ -256,7 +256,7 @@ [[ final_result()['type'] == 'Net Loss' and final_result()['type'] or '' ]] - [[ final_result()['balance'] and final_result()['type'] == 'Net Loss' and formatLang(abs(final_result()['balance'])) ]] [[ final_result()['balance'] and final_result()['type'] == 'Net Loss' and company.currency_id.symbol ]] + [[ final_result()['balance'] and final_result()['type'] == 'Net Loss' and formatLang(abs(final_result()['balance']), currency_obj=company.currency_id) ]] @@ -267,13 +267,13 @@ Total: - [[ formatLang(abs(sum_dr())) ]] [[ company.currency_id.symbol ]] + [[ formatLang(abs(sum_dr()), currency_obj=company.currency_id) ]] Total: - [[ formatLang(abs(sum_cr())) ]] [[ company.currency_id.symbol ]] + [[ formatLang(abs(sum_cr()), currency_obj=company.currency_id) ]] diff --git a/addons/account/report/account_profit_loss.rml b/addons/account/report/account_profit_loss.rml index 2b29f479478..4fc2d73c3d6 100644 --- a/addons/account/report/account_profit_loss.rml +++ b/addons/account/report/account_profit_loss.rml @@ -228,8 +228,8 @@ [[ setTag('tr','tr',{'style': 'Table'+str(min(3,a.level))}) ]] [[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_3_code_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_code'}) ]][[ a.code ]] [[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_name_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(4,a.level))+'_name'}) ]][[ a.name ]] - [[ (a.level <>2) or removeParentNode('td') ]][[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_balance'}) ]][[ formatLang(a.balance) ]] [[company.currency_id.symbol ]] - [[ a.level == 2 or removeParentNode('td') ]][[ formatLang(a.balance) ]] [[company.currency_id.symbol ]] + [[ (a.level <>2) or removeParentNode('td') ]][[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_balance'}) ]][[ formatLang(a.balance, currency_obj=company.currency_id) ]] + [[ a.level == 2 or removeParentNode('td') ]][[ formatLang(a.balance, currency_obj=company.currency_id) ]] @@ -241,7 +241,7 @@ [[ final_result()['type'] == 'Net Profit' and final_result()['type'] or removeParentNode('blockTable') ]] - [[ final_result()['balance'] and final_result()['type'] == 'Net Profit' and formatLang(final_result()['balance']) ]] [[ final_result()['balance'] and final_result()['type'] == 'Net Profit' and company.currency_id.symbol ]] + [[ final_result()['balance'] and final_result()['type'] == 'Net Profit' and formatLang(final_result()['balance'], currency_obj=company.currency_id) ]] @@ -251,7 +251,7 @@ Total: - [[ formatLang(sum_dr()) ]] [[ company.currency_id.symbol ]] + [[ formatLang(sum_dr(), currency_obj=company.currency_id) ]] @@ -277,8 +277,8 @@ [[ setTag('tr','tr',{'style': 'Table'+str(min(3,a.level))}) ]] [[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_3_code_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_code'}) ]][[ a.code ]] [[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_name_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(4,a.level))+'_name'}) ]][[ a.name ]] - [[ (a.level <>2) or removeParentNode('td') ]][[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_balance'}) ]][[ formatLang(a.balance) ]] [[company.currency_id.symbol ]] - [[ a.level == 2 or removeParentNode('td') ]][[ formatLang(a.balance) ]] [[company.currency_id.symbol ]] + [[ (a.level <>2) or removeParentNode('td') ]][[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_balance'}) ]][[ formatLang(a.balance, currency_obj=company.currency_id) ]] + [[ a.level == 2 or removeParentNode('td') ]][[ formatLang(a.balance, currency_obj=company.currency_id) ]] @@ -290,7 +290,7 @@ [[ final_result()['type'] == 'Net Loss' and final_result()['type'] or removeParentNode('blockTable') ]] - [[ final_result()['balance'] and final_result()['type'] == 'Net Loss' and formatLang(final_result()['balance']) ]] [[ final_result()['balance'] and final_result()['type'] == 'Net Loss' and company.currency_id.symbol ]] + [[ final_result()['balance'] and final_result()['type'] == 'Net Loss' and formatLang(final_result()['balance'], currency_obj=company.currency_id) ]] @@ -300,7 +300,7 @@ Total: - [[ formatLang(sum_cr()) ]] [[ company.currency_id.symbol ]] + [[ formatLang(sum_cr(), currency_obj=company.currency_id) ]] diff --git a/addons/account/report/account_tax_code.rml b/addons/account/report/account_tax_code.rml index 7489ac72a39..10a7c76a821 100644 --- a/addons/account/report/account_tax_code.rml +++ b/addons/account/report/account_tax_code.rml @@ -129,10 +129,10 @@ [[ line['name'] ]] - [[ formatLang(line['debit']) ]] [[ company.currency_id.symbol]] + [[ formatLang(line['debit'], currency_obj=company.currency_id) ]] - [[ formatLang(line['credit']) ]] [[ company.currency_id.symbol]] + [[ formatLang(line['credit'], currency_obj=company.currency_id) ]] @@ -141,4 +141,4 @@ - \ No newline at end of file + diff --git a/addons/account/report/account_tax_report.rml b/addons/account/report/account_tax_report.rml index de4aa415fef..f489ee1143e 100644 --- a/addons/account/report/account_tax_report.rml +++ b/addons/account/report/account_tax_report.rml @@ -153,7 +153,7 @@ [[ repeatIn(get_lines(data['form']['based_on'], data['form']['company_id']), 'o') ]][[ (o['level']) ]] [[ (len(o['level'])<5 and setTag('para','para',{'fontName':'Helvetica-Bold'})) or removeParentNode('font') ]][[ o['code'] ]] [[ o['name'] ]] [[ len(o['level'])<5 and setTag('para','para',{'fontName':"Helvetica-Bold"}) or removeParentNode('font')]][[ o['type']=='view' and removeParentNode('font') ]][[ formatLang(o['debit']) ]][[ o['type']<>'view' and removeParentNode('font') ]][[ formatLang(o['debit']) ]] [[ len(o['level'])<5 and setTag('para','para',{'fontName':"Helvetica-Bold"}) or removeParentNode('font')]][[ o['type']=='view' and removeParentNode('font') ]][[ formatLang(o['credit']) ]][[ o['type']<>'view' and removeParentNode('font') ]][[ formatLang(o['credit'])]] - [[ len(o['level'])<5 and setTag('para','para',{'fontName':"Helvetica-Bold"}) or removeParentNode('font')]][[ o['type']=='view' and removeParentNode('font') ]][[ formatLang(o['tax_amount']) ]] [[ company.currency_id.symbol ]][[ o['type']<>'view' and removeParentNode('font') ]][[ formatLang(o['tax_amount']) ]] [[ company.currency_id.symbol ]] + [[ len(o['level'])<5 and setTag('para','para',{'fontName':"Helvetica-Bold"}) or removeParentNode('font')]][[ o['type']=='view' and removeParentNode('font') ]][[ formatLang(o['tax_amount'], currency_obj=company.currency_id) ]][[ o['type']<>'view' and removeParentNode('font') ]][[ formatLang(o['tax_amount'], currency_obj=company.currency_id) ]] diff --git a/addons/account_analytic_plans/report/crossovered_analytic.rml b/addons/account_analytic_plans/report/crossovered_analytic.rml index 6e331ed1b83..f374aa5a2c2 100644 --- a/addons/account_analytic_plans/report/crossovered_analytic.rml +++ b/addons/account_analytic_plans/report/crossovered_analytic.rml @@ -240,7 +240,7 @@ [[ formatLang(a['ref_qty']) ]] - [[ formatLang(a['ref_amt']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(a['ref_amt'], currency_obj=company.currency_id) ]] 100.00% @@ -288,7 +288,7 @@ [[formatLang(a['qty']) ]] - [[ formatLang(a['amt']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(a['amt'], currency_obj=company.currency_id) ]] [[ formatLang(a['perc']) ]]% diff --git a/addons/account_budget/report/analytic_account_budget_report.rml b/addons/account_budget/report/analytic_account_budget_report.rml index a8b957f52a5..ba89c7ed1ea 100644 --- a/addons/account_budget/report/analytic_account_budget_report.rml +++ b/addons/account_budget/report/analytic_account_budget_report.rml @@ -185,13 +185,13 @@ [['.....' *(a['status']-1) ]] [[ (a['status']==1 and (setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ a['name'] ]] - [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['theo']) ]] [[ company.currency_id.symbol ]] + [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['theo'], currency_obj=company.currency_id) ]] - [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['pln']) ]] [[ company.currency_id.symbol ]] + [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['pln'], currency_obj=company.currency_id) ]] - [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['prac']) ]] [[ company.currency_id.symbol ]] + [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['prac'], currency_obj=company.currency_id) ]] [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['perc']) ]]% @@ -205,13 +205,13 @@ [[ repeatIn(funct_total(data['form']),'b') ]] Total: - [[ formatLang(b['tot_theo']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(b['tot_theo'], currency_obj=company.currency_id) ]] - [[ formatLang(b['tot_pln']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(b['tot_pln'], currency_obj=company.currency_id) ]] - [[ formatLang(b['tot_prac']) ]] [[ company.currency_id.symbol ]] + [[ formatLang(b['tot_prac'], currency_obj=company.currency_id) ]] [[ formatLang(b['tot_perc']) ]]% @@ -223,4 +223,4 @@ - \ No newline at end of file + diff --git a/addons/account_budget/report/budget_report.rml b/addons/account_budget/report/budget_report.rml index 0533042822a..4d82e8d8c1d 100644 --- a/addons/account_budget/report/budget_report.rml +++ b/addons/account_budget/report/budget_report.rml @@ -148,13 +148,13 @@ [['.....' *(a['status']-1) ]][[ (a['status']==1 and (setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ a['name'] ]] - [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['theo'], digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] + [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['theo'], digits=get_digits(dp='Account'), currency_obj=company.currency_id) ]] - [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['pln'], digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] + [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['pln'], digits=get_digits(dp='Account'), currency_obj=company.currency_id) ]] - [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['prac'], digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] + [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['prac'], digits=get_digits(dp='Account'), currency_obj=company.currency_id) ]] [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['perc'], digits=2) ]]% @@ -168,13 +168,13 @@ [[ repeatIn(funct_total(data['form']),'b') ]]Total: - [[ formatLang(b['tot_theo'], digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(b['tot_theo'], digits=get_digits(dp='Account'), currency_obj=company.currency_id) ]] - [[ formatLang(b['tot_pln'], digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(b['tot_pln'], digits=get_digits(dp='Account'), currency_obj=company.currency_id) ]] - [[ formatLang(b['tot_prac'], digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] + [[ formatLang(b['tot_prac'], digits=get_digits(dp='Account'), currency_obj=company.currency_id) ]] [[ formatLang(b['tot_perc'], digits=2) ]]% diff --git a/addons/account_budget/report/crossovered_budget_report.rml b/addons/account_budget/report/crossovered_budget_report.rml index 63db53ab5ce..b4e8e963b7d 100644 --- a/addons/account_budget/report/crossovered_budget_report.rml +++ b/addons/account_budget/report/crossovered_budget_report.rml @@ -163,13 +163,13 @@ [['.....' *(a['status']-1) ]][[ (a['status']==1 and (setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ a['name'] ]] - [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['theo'], dp='Account') ]] [[ company.currency_id.symbol ]] + [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['theo'], dp='Account', currency_obj=company.currency_id) ]] - [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['pln'], dp='Account') ]] [[ company.currency_id.symbol ]] + [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['pln'], dp='Account', currency_obj=company.currency_id) ]] - [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['prac'], dp='Account') ]] [[ company.currency_id.symbol ]] + [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['prac'], dp='Account', currency_obj=company.currency_id) ]] [[ (a['status']==1 and ( setTag('para','para',{'fontName':'Helvetica-bold'}))) or removeParentNode('font') ]] [[ formatLang(a['perc'],digits=2) ]]% @@ -183,13 +183,13 @@ [[ repeatIn(funct_total(data['form']),'b') ]] Total : - [[ formatLang(b['tot_theo'], dp='Account') ]] [[ company.currency_id.symbol ]] + [[ formatLang(b['tot_theo'], dp='Account', currency_obj=company.currency_id) ]] - [[ formatLang(b['tot_pln'], dp='Account') ]] [[ company.currency_id.symbol ]] + [[ formatLang(b['tot_pln'], dp='Account', currency_obj=company.currency_id) ]] - [[ formatLang(b['tot_prac'], dp='Account') ]] [[ company.currency_id.symbol ]] + [[ formatLang(b['tot_prac'], dp='Account', currency_obj=company.currency_id) ]] [[ formatLang(b['tot_perc'],digits=2) ]]% diff --git a/addons/purchase/report/order.rml b/addons/purchase/report/order.rml index 4b143d0f961..188f969e07c 100644 --- a/addons/purchase/report/order.rml +++ b/addons/purchase/report/order.rml @@ -293,7 +293,7 @@ [[ formatLang(line.price_unit, digits=get_digits(dp='Purchase Price') ) ]] - [[ formatLang(line.price_subtotal, digits=get_digits(dp='Purchase Price') ) ]] [[ o.pricelist_id.currency_id.symbol ]] + [[ formatLang(line.price_subtotal, digits=get_digits(dp='Purchase Price'), currency_obj=o.pricelist_id.currency_id ) ]] @@ -339,7 +339,7 @@ Net Total : - [[ formatLang(o.amount_untaxed, digits=get_digits(dp='Purchase Price') ) ]] [[ o.pricelist_id.currency_id. symbol ]] + [[ formatLang(o.amount_untaxed, digits=get_digits(dp='Purchase Price'), currency_obj=o.pricelist_id.currency_id ) ]] @@ -352,7 +352,7 @@ Taxes : - [[ formatLang(o.amount_tax, dp='Purchase Price') ]] [[ o.pricelist_id.currency_id. symbol ]] + [[ formatLang(o.amount_tax, dp='Purchase Price', currency_obj=o.pricelist_id.currency_id) ]] @@ -365,7 +365,7 @@ Total : - [[ formatLang(o.amount_total, digits=get_digits(dp='Purchase Price') ) ]] [[ o.pricelist_id.currency_id. symbol ]] + [[ formatLang(o.amount_total, digits=get_digits(dp='Purchase Price') , currency_obj=o.pricelist_id.currency_id) ]] diff --git a/addons/sale/report/sale_order.rml b/addons/sale/report/sale_order.rml index 00ebb50472e..a6902f79047 100644 --- a/addons/sale/report/sale_order.rml +++ b/addons/sale/report/sale_order.rml @@ -283,7 +283,7 @@ [[ formatLang(line.discount) ]] - [[ formatLang(line.price_subtotal, digits=get_digits(dp='Sale Price')) ]] [[ o.pricelist_id.currency_id.symbol ]] + [[ formatLang(line.price_subtotal, digits=get_digits(dp='Sale Price'), currency_obj=o.pricelist_id.currency_id) ]] @@ -329,7 +329,7 @@ Net Total : - [[ formatLang(o.amount_untaxed, dp='Sale Price') ]] [[ o.pricelist_id.currency_id.symbol ]] + [[ formatLang(o.amount_untaxed, dp='Sale Price', currency_obj=o.pricelist_id.currency_id) ]] @@ -342,7 +342,7 @@ Taxes : - [[ formatLang(o.amount_tax, dp='Sale Price') ]] [[ o.pricelist_id.currency_id.symbol ]] + [[ formatLang(o.amount_tax, dp='Sale Price', currency_obj=o.pricelist_id.currency_id) ]] @@ -355,7 +355,7 @@ Total : - [[ formatLang(o.amount_total, dp='Sale Price') ]] [[ o.pricelist_id.currency_id.symbol ]] + [[ formatLang(o.amount_total, dp='Sale Price', currency_obj=o.pricelist_id.currency_id) ]] From d518bdce72c8f3136dea3635db03112c44e39c8c Mon Sep 17 00:00:00 2001 From: openerp user Date: Tue, 13 Sep 2011 11:55:22 +0200 Subject: [PATCH 31/88] Adding vat check for country of Croatia bzr revid: openerp@openerp6desktop-20110913095522-b7ry940z7fnysvlb --- addons/base_vat/base_vat.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/addons/base_vat/base_vat.py b/addons/base_vat/base_vat.py index 6393c0a6182..835a23e7e27 100644 --- a/addons/base_vat/base_vat.py +++ b/addons/base_vat/base_vat.py @@ -42,7 +42,7 @@ _ref_vat = { 'pt': 'PT123456789', 'ro': 'RO1234567897', 'se': 'SE123456789701', 'si': 'SI12345679', 'sk': 'SK0012345675', 'el': 'EL12345670', - 'mx': 'MXABCD831230T1B', + 'mx': 'MXABCD831230T1B', 'hr': 'HR01234567896' } @@ -1104,7 +1104,28 @@ class res_partner(osv.osv): #Valid format and valid date return True - + + def check_vat_hr(self, vat): + ''' + Check Croatia VAT number. + ''' + if not vat: + return True + + if len(vat) != 11: + return False + try: + int(vat) + except ValueError: + return False + t = 10 + for i in vat[:-1]: + c = int(i) + t = (2 * ((t + c) % 10 or 10)) % 11 + check = (11 - t) % 10 + if check != int(vat[10]): + return False + return True res_partner() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From c0936ac657d3e8d41c3b9e7be917a3ef3075cb8f Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 15 Sep 2011 22:22:09 +0200 Subject: [PATCH 32/88] [IMP] Get rid of jQuery accordion. Improved menu (WIP). Now all levels are working bzr revid: fme@openerp.com-20110915202209-5rp3ltzz86msaajz --- addons/web/static/src/css/base.css | 76 +++++++----------------------- addons/web/static/src/js/chrome.js | 25 ++++------ addons/web/static/src/xml/base.xml | 48 ++++++++----------- 3 files changed, 45 insertions(+), 104 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 4645c55f692..9200cfc3383 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -221,17 +221,11 @@ label.error { height: 100%; background: #f0eeee; } +.openerp .oe-application-container { + height: 100%; +} /* Menu */ -.openerp .sf-menu { - margin-bottom: 0; -} -/* -.sf-menu a { - padding: 5px 5px; -} -*/ - .openerp .menu { height: 34px; background: #cc4e45; /* Old browsers */ @@ -291,12 +285,8 @@ label.error { background: linear-gradient(top, #c6c6c6 0%,#5c5c5c 7%,#969595 86%); /* W3C */ /* for ie */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#5c5c5c', endColorstr='#969595',GradientType=0 ); /* IE6-9 */ - color: #fff; } -.openerp .oe-application-container { - height: 100%; -} /* Secondary Menu */ .openerp .secondary_menu { width: 200px; @@ -307,14 +297,16 @@ label.error { vertical-align: top; height: 100%; } -.openerp .secondary_menu .menu_content { - padding: 0; - border: none; - background: none; - overflow: hidden; +.openerp .secondary_menu a { + display: block; + padding: 0 5px 2px 5px; + line-height: 20px; + text-decoration: none; + white-space: nowrap; + color: white; + text-shadow: 0 1px 0 #333; } -.openerp .secondary_menu h3 { - padding: 0 0 2px; +.openerp .secondary_menu a.oe_secondary_menu_item { background: #949292; /* Old browsers */ background: -moz-linear-gradient(top, #949292 0%, #6d6b6b 87%, #282828 99%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#949292), color-stop(87%,#6d6b6b), color-stop(99%,#282828)); /* Chrome,Safari4+ */ @@ -325,34 +317,13 @@ label.error { background: linear-gradient(top, #949292 0%,#6d6b6b 87%,#282828 99%); /* W3C */ /* for ie9 */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#949292', endColorstr='#5B5A5A',GradientType=0 ); /* IE6-9 */ - border: none; - /* overriding jquery ui */ - -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; -} -.openerp .secondary_menu h4 { - padding: 0 0 2px 10px; - border: none; - background: none; -} -.openerp .secondary_menu h3 span, .openerp .secondary_menu h4 span { - left: 0 !important; -} -.openerp .secondary_menu a { - display: block; - height: 20px; - padding: 0 5px; - line-height: 20px; white-space: nowrap; color: white; - text-decoration: none; text-shadow: 0 1px 0 #333; } -.openerp .secondary_menu a.leaf:hover, -.openerp .secondary_menu a.leaf:active, -.openerp .secondary_menu a.leaf.active, -.openerp .secondary_menu h4:hover, -.openerp .secondary_menu h4:active, -.openerp .secondary_menu h4.active { +.openerp a.oe_secondary_submenu_item:hover, +.openerp a.oe_secondary_submenu_item.leaf.active { + display: block; background: #ffffff; /* Old browsers */ background: -moz-linear-gradient(top, #ffffff 0%, #d8d8d8 11%, #afafaf 86%, #333333 91%, #5a5858 96%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(11%,#d8d8d8), color-stop(86%,#afafaf), color-stop(91%,#333333), color-stop(96%,#5a5858)); /* Chrome,Safari4+ */ @@ -361,22 +332,11 @@ label.error { background: -ms-linear-gradient(top, #ffffff 0%,#d8d8d8 11%,#afafaf 86%,#333333 91%,#5a5858 96%); /* IE10+ */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#FFFFFF', endColorstr='#5A5858',GradientType=0 ); /* IE6-9 */ background: linear-gradient(top, #ffffff 0%,#d8d8d8 11%,#afafaf 86%,#333333 91%,#5a5858 96%); /* W3C */ - /* overriding jquery ui */ - -moz-border-radius-topright: 0; -webkit-border-top-right-radius: 0; border-top-right-radius: 0; + padding: 0 5px 2px 5px; + line-height: 20px; color: #3f3d3d; + text-decoration: none; text-shadow: #fff 0 1px 0; - border: none !important; -} - -.openerp .secondary_menu h4:hover a, -.openerp .secondary_menu h4:active a, -.openerp .secondary_menu h4.active a { - color: #3f3d3d; - text-shadow: #fff 0 1px 0; - border: none !important; -} -.openerp div.submenu_accordion div.menu_content a span { - padding-left: 20px; } /* Header */ diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index d114f485c62..0d671b25d53 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -787,18 +787,6 @@ openerp.web.Menu = openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{ var v = { menu : this.data.data.children[i] }; this.$secondary_menu.append(QWeb.render("Menu.secondary", v)); } - this.$secondary_menu.find("div.menu_accordion").accordion({ - animated : false, - autoHeight : false, - icons : false - }); - this.$secondary_menu.find("div.submenu_accordion").accordion({ - animated : false, - autoHeight : false, - active: false, - collapsible: true, - header: 'h4' - }); this.$element.add(this.$secondary_menu).find("a").click(this.on_menu_click); }, @@ -817,15 +805,14 @@ openerp.web.Menu = openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{ id = $menu.data('menu'); } if (this.$secondary_menu.has($menu).length) { - $secondary = $menu.parents('.menu_accordion'); + $secondary = $menu.parents('.oe_secondary_menu'); $parent = this.$element.find('a[data-menu=' + $secondary.data('menu-parent') + ']'); } else { $parent = $menu; - $secondary = this.$secondary_menu.find('.menu_accordion[data-menu-parent=' + $menu.attr('data-menu') + ']'); + $secondary = this.$secondary_menu.find('.oe_secondary_menu[data-menu-parent=' + $menu.attr('data-menu') + ']'); } - this.$secondary_menu.find('.menu_accordion').hide(); - // TODO: ui-accordion : collapse submenus and expand the good one + this.$secondary_menu.find('.oe_secondary_menu').hide(); $secondary.show(); if (id) { @@ -837,11 +824,15 @@ openerp.web.Menu = openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{ $('.active', this.$element.add(this.$secondary_menu.show())).removeClass('active'); $parent.addClass('active'); $menu.addClass('active'); - $menu.parent('h4').addClass('active'); if (this.$secondary_menu.has($menu).length) { + if ($menu.is('.submenu')) { + $menu.next().toggle(); + return false; + } return !$menu.is(".leaf"); } else { + $secondary.find('.oe_secondary_submenu').hide().eq(0).show(); return false; } }, diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 83ca819b4e6..95e2a7e5770 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -374,45 +374,35 @@ - - - - - + + +
- - - -
+ + + +
-