From 323aa0e8ad1f932be0d2f1b8eecdcf99b4b600d8 Mon Sep 17 00:00:00 2001 From: skh Date: Wed, 11 May 2011 14:48:38 +0530 Subject: [PATCH 001/160] [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 002/160] [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 003/160] [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 322d3dd3409cb61b5898a771dd954ed5f0ada8b2 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Thu, 26 May 2011 18:45:51 +0530 Subject: [PATCH 004/160] [FIX] add noupdate=1 in ir.rule Record. bzr revid: ysa@tinyerp.com-20110526131551-nvt6tgyrh2ddsctp --- .../addons/base/security/base_security.xml | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/openerp/addons/base/security/base_security.xml b/openerp/addons/base/security/base_security.xml index 0caf21e5196..4d04ac105c4 100644 --- a/openerp/addons/base/security/base_security.xml +++ b/openerp/addons/base/security/base_security.xml @@ -40,28 +40,32 @@ - - res.widget.user rule - - - ['|', ('user_id','=',user.id),('user_id','=',False)] - + - - res.partner company - - - - ['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)] - + - - Multi_company_default company - - - [('company_id','child_of',[user.company_id.id])] - + + res.widget.user rule + + + ['|', ('user_id','=',user.id),('user_id','=',False)] + + + + res.partner company + + + + ['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)] + + + + Multi_company_default company + + + [('company_id','child_of',[user.company_id.id])] + From dd673b080f90af4d3cb71e98b5afc8a7379bbb8d Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Fri, 27 May 2011 14:28:41 +0530 Subject: [PATCH 005/160] [USABILITY] change string of tab allowed companies instead of companies in user form. bzr revid: ysa@tinyerp.com-20110527085841-4yjchpazj0m6d5gu --- openerp/addons/base/base_update.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/addons/base/base_update.xml b/openerp/addons/base/base_update.xml index 7432018fd94..f3adbf4179e 100644 --- a/openerp/addons/base/base_update.xml +++ b/openerp/addons/base/base_update.xml @@ -146,7 +146,7 @@ - + From fe230bbb6d569c6af3abbd79d4664be844fc5b42 Mon Sep 17 00:00:00 2001 From: "Nimesh (Open ERP)" Date: Mon, 30 May 2011 14:33:35 +0530 Subject: [PATCH 006/160] [fix] improvement in trml2pdf.py for the image bzr revid: nco@tinyerp.com-20110530090335-7lamm1fbnalkrhlh --- openerp/report/render/rml2pdf/trml2pdf.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openerp/report/render/rml2pdf/trml2pdf.py b/openerp/report/render/rml2pdf/trml2pdf.py index e083062e302..e3afa872fbd 100644 --- a/openerp/report/render/rml2pdf/trml2pdf.py +++ b/openerp/report/render/rml2pdf/trml2pdf.py @@ -447,14 +447,14 @@ class _rml_canvas(object): self._logger.debug("Image %s used", node.get('name')) s = StringIO(image_data) else: + newtext = node.text if self.localcontext: - res = utils._regex.findall(node.text) + res = utils._regex.findall(newtext) for key in res: - newtext = eval(key, {}, self.localcontext) - node.text = newtext or '' + newtext = eval(key, {}, self.localcontext) or '' image_data = None - if node.text: - image_data = base64.decodestring(node.text) + if newtext: + image_data = base64.decodestring(newtext) if image_data: s = StringIO(image_data) else: From 9c1d85e2985de335043217caddf9e9827e73bc12 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 30 May 2011 16:36:21 +0530 Subject: [PATCH 007/160] [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 008/160] [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 009/160] [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 010/160] [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 011/160] [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 012/160] [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 013/160] [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 014/160] [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 015/160] [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 016/160] 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 017/160] 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 018/160] 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 019/160] 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 020/160] 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 021/160] [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 022/160] [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 023/160] [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 024/160] [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 025/160] [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 026/160] 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 027/160] 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 028/160] [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 a5a07e49933d0f21958940e3c7339130aaf5e0d7 Mon Sep 17 00:00:00 2001 From: "Nimesh (Open ERP)" Date: Tue, 26 Jul 2011 18:51:37 +0530 Subject: [PATCH 029/160] Add missing unique keys lp bug: https://launchpad.net/bugs/789019 fixed bzr revid: nco@tinyerp.com-20110726132137-h8go2l62xkn8pdme --- openerp/addons/base/ir/ir_model.py | 4 +++- openerp/addons/base/res/partner/partner.py | 2 +- openerp/addons/base/res/res_company.py | 3 +++ openerp/addons/base/res/res_currency.py | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index d3dfd987638..add19f62078 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -97,7 +97,9 @@ class ir_model(osv.osv): 'modules': fields.function(_in_modules, method=True, type='char', size=128, string='In modules', help='List of modules in which the object is defined or inherited'), 'view_ids': fields.function(_view_ids, method=True, type='one2many', obj='ir.ui.view', string='Views'), } - + _sql_constraints = [ + ('obj_name_uniq', 'unique (name)', 'The object name must be unique !'), + ] _defaults = { 'model': lambda *a: 'x_', 'state': lambda self,cr,uid,ctx=None: (ctx and ctx.get('manual',False)) and 'manual' or 'base', diff --git a/openerp/addons/base/res/partner/partner.py b/openerp/addons/base/res/partner/partner.py index 091927f126d..0eed895e404 100644 --- a/openerp/addons/base/res/partner/partner.py +++ b/openerp/addons/base/res/partner/partner.py @@ -434,7 +434,7 @@ class res_partner_bank(osv.osv): 'state_id': lambda obj, cursor, user, context: obj._default_value( cursor, user, 'state_id', context=context), } - + def fields_get(self, cr, uid, fields=None, context=None): res = super(res_partner_bank, self).fields_get(cr, uid, fields, context) bank_type_obj = self.pool.get('res.partner.bank.type') diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py index 14ef53199d5..3e31401ec49 100644 --- a/openerp/addons/base/res/res_company.py +++ b/openerp/addons/base/res/res_company.py @@ -127,6 +127,9 @@ class res_company(osv.osv): 'email': fields.function(_get_address_data, fnct_inv=_set_address_data, size=64, type='char', string="Email", multi='address'), 'phone': fields.function(_get_address_data, fnct_inv=_set_address_data, size=64, type='char', string="Phone", multi='address'), } + _sql_constraints = [ + ('com_name_uniq', 'unique (name)', 'The company name must be unique !') + ] def _search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False, access_rights_uid=None): diff --git a/openerp/addons/base/res/res_currency.py b/openerp/addons/base/res/res_currency.py index d81248a735d..6005ea8dd97 100644 --- a/openerp/addons/base/res/res_currency.py +++ b/openerp/addons/base/res/res_currency.py @@ -65,6 +65,9 @@ class res_currency(osv.osv): '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) } + _sql_constraints = [ + ('currency_name_uniq', 'unique (name, company_id)', 'The currency code must be unique !'), + ] _order = "name" def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'): From 2632bb3d0439f2f8798e05ab5f0605da1eceeafe Mon Sep 17 00:00:00 2001 From: Boris Timokhin Date: Sun, 31 Jul 2011 22:17:24 +0400 Subject: [PATCH 030/160] base_module_import fix crash for not zip files, better module_name detection, codestyling lp bug: https://launchpad.net/bugs/818951 fixed bzr revid: qoqenator@gmail.com-20110731181724-6l35g3tqog79gi2m --- .../base/module/wizard/base_module_import.py | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/openerp/addons/base/module/wizard/base_module_import.py b/openerp/addons/base/module/wizard/base_module_import.py index 05c3b18198d..3ef9132af0e 100644 --- a/openerp/addons/base/module/wizard/base_module_import.py +++ b/openerp/addons/base/module/wizard/base_module_import.py @@ -28,6 +28,8 @@ import base64 from tools.translate import _ from osv import osv, fields +ADDONS_PATH = tools.config['addons_path'].split(",")[-1] + class base_module_import(osv.osv_memory): """ Import Module """ @@ -37,7 +39,8 @@ class base_module_import(osv.osv_memory): _columns = { 'module_file': fields.binary('Module .ZIP file', required=True), - 'state':fields.selection([('init','init'),('done','done')], 'state', readonly=True), + 'state':fields.selection([('init','init'),('done','done')], + 'state', readonly=True), 'module_name': fields.char('Module Name', size=128), } @@ -48,26 +51,30 @@ class base_module_import(osv.osv_memory): def importzip(self, cr, uid, ids, context): (data,) = self.browse(cr, uid, ids , context=context) module_data = data.module_file - - val = base64.decodestring(module_data) + zip_data = base64.decodestring(module_data) fp = StringIO() - fp.write(val) - fdata = zipfile.ZipFile(fp, 'r') - fname = fdata.namelist()[0] - module_name = os.path.split(fname)[0] - - ad = tools.config['addons_path'].split(",")[-1] - - fname = os.path.join(ad, module_name+'.zip') + fp.write(zip_data) try: - fp = file(fname, 'wb') - fp.write(val) - fp.close() - except IOError: - raise osv.except_osv(_('Error !'), _('Can not create the module file: %s !') % (fname,) ) + file_data = zipfile.ZipFile(fp, 'r') + except zipfile.BadZipfile: + raise osv.except_osv(_('Error !'), _('File is not a zip file!')) + init_file_name = sorted(file_data.namelist())[0] + module_name = os.path.split(init_file_name)[0] - self.pool.get('ir.module.module').update_list(cr, uid, {'module_name': module_name,}) - self.write(cr, uid, ids, {'state':'done', 'module_name': module_name}, context) + file_path = os.path.join(ADDONS_PATH, '%s.zip' % module_name) + try: + zip_file = open(file_path, 'wb') + except IOError: + raise osv.except_osv(_('Error !'), + _('Can not create the module file: %s !') % \ + (file_path,) ) + zip_file.write(zip_data) + zip_file.close() + + self.pool.get('ir.module.module').update_list(cr, uid, + {'module_name': module_name,}) + self.write(cr, uid, ids, {'state':'done', 'module_name': module_name}, + context) return False def action_module_open(self, cr, uid, ids, context): @@ -84,4 +91,4 @@ class base_module_import(osv.osv_memory): base_module_import() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From c761404086f02cb014d7f4fcc342a27d7d78ab8c Mon Sep 17 00:00:00 2001 From: gpa Date: Wed, 3 Aug 2011 16:35:59 +0530 Subject: [PATCH 031/160] [FIX] Fixed error of non-ascii charcter in label, remove by default condition True and display group lp bug: https://launchpad.net/bugs/727263 fixed bzr revid: gpa@tinyerp.com-20110803110559-83xiqnjtb510w8ka --- openerp/addons/base/ir/ir_ui_view.py | 4 ++-- openerp/addons/base/ir/workflow/workflow.py | 24 +++++++++---------- .../addons/base/ir/workflow/workflow_view.xml | 8 +++---- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/openerp/addons/base/ir/ir_ui_view.py b/openerp/addons/base/ir/ir_ui_view.py index ee23a2f52f1..84a065fe356 100644 --- a/openerp/addons/base/ir/ir_ui_view.py +++ b/openerp/addons/base/ir/ir_ui_view.py @@ -158,10 +158,10 @@ class view(osv.osv): label_string = "" if label: for lbl in eval(label): - if t.has_key(str(lbl)) and str(t[lbl])=='False': + if t.has_key(tools.ustr(lbl)) and tools.ustr(t[lbl])=='False': label_string = label_string + ' ' else: - label_string = label_string + " " + t[lbl] + label_string = label_string + " " + tools.ustr(t[lbl]) labels[str(t['id'])] = (a['id'],label_string) g = graph(nodes, transitions, no_ancester) g.process(start) diff --git a/openerp/addons/base/ir/workflow/workflow.py b/openerp/addons/base/ir/workflow/workflow.py index c638855aacf..414420d6c81 100644 --- a/openerp/addons/base/ir/workflow/workflow.py +++ b/openerp/addons/base/ir/workflow/workflow.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -46,21 +46,21 @@ class workflow(osv.osv): return super(workflow, self).write(cr, user, ids, vals, context=context) def get_active_workitems(self, cr, uid, res, res_id, context={}): - + cr.execute('select * from wkf where osv=%s limit 1',(res,)) wkfinfo = cr.dictfetchone() workitems = [] - + if wkfinfo: cr.execute('SELECT id FROM wkf_instance \ WHERE res_id=%s AND wkf_id=%s \ ORDER BY state LIMIT 1', (res_id, wkfinfo['id'])) inst_id = cr.fetchone() - + cr.execute('select act_id,count(*) from wkf_workitem where inst_id=%s group by act_id', (inst_id,)) - workitems = dict(cr.fetchall()) - + workitems = dict(cr.fetchall()) + return {'wkf': wkfinfo, 'workitems': workitems} @@ -148,12 +148,12 @@ class wkf_transition(osv.osv): _columns = { 'trigger_model': fields.char('Trigger Object', size=128), 'trigger_expr_id': fields.char('Trigger Expression', size=128), - 'signal': fields.char('Signal (button Name)', size=64, + 'signal': fields.char('Signal (button Name)', size=64, help="When the operation of transition comes from a button pressed in the client form, "\ "signal tests the name of the pressed button. If signal is NULL, no button is necessary to validate this transition."), - 'group_id': fields.many2one('res.groups', 'Group Required', + 'group_id': fields.many2one('res.groups', 'Group Required', help="The group that a user must have to be authorized to validate this transition."), - 'condition': fields.char('Condition', required=True, size=128, + 'condition': fields.char('Condition', size=128, help="Expression to be satisfied if we want the transition done."), 'act_from': fields.many2one('workflow.activity', 'Source Activity', required=True, select=True, ondelete='cascade', help="Source activity. When this activity is over, the condition is tested to determine if we can start the ACT_TO activity."), @@ -161,9 +161,7 @@ class wkf_transition(osv.osv): help="The destination activity."), 'wkf_id': fields.related('act_from','wkf_id', type='many2one', relation='workflow', string='Workflow', select=True), } - _defaults = { - 'condition': lambda *a: 'True', - } + wkf_transition() class wkf_instance(osv.osv): diff --git a/openerp/addons/base/ir/workflow/workflow_view.xml b/openerp/addons/base/ir/workflow/workflow_view.xml index 5866b81a25e..2d6d2d1e753 100644 --- a/openerp/addons/base/ir/workflow/workflow_view.xml +++ b/openerp/addons/base/ir/workflow/workflow_view.xml @@ -52,7 +52,7 @@ - + @@ -329,7 +329,7 @@ form
- + @@ -343,7 +343,7 @@ tree - + @@ -359,7 +359,7 @@ - + From 3e5e4dce7c391c1b985be33b146e7b4ec800c283 Mon Sep 17 00:00:00 2001 From: gpa Date: Wed, 3 Aug 2011 17:23:48 +0530 Subject: [PATCH 032/160] [IMP]Improvement in code bzr revid: gpa@tinyerp.com-20110803115348-kg6lhy40ylk4hnvq --- openerp/addons/base/ir/workflow/workflow.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openerp/addons/base/ir/workflow/workflow.py b/openerp/addons/base/ir/workflow/workflow.py index 414420d6c81..36102878c20 100644 --- a/openerp/addons/base/ir/workflow/workflow.py +++ b/openerp/addons/base/ir/workflow/workflow.py @@ -153,7 +153,7 @@ class wkf_transition(osv.osv): "signal tests the name of the pressed button. If signal is NULL, no button is necessary to validate this transition."), 'group_id': fields.many2one('res.groups', 'Group Required', help="The group that a user must have to be authorized to validate this transition."), - 'condition': fields.char('Condition', size=128, + 'condition': fields.char('Condition', required=True, size=128, help="Expression to be satisfied if we want the transition done."), 'act_from': fields.many2one('workflow.activity', 'Source Activity', required=True, select=True, ondelete='cascade', help="Source activity. When this activity is over, the condition is tested to determine if we can start the ACT_TO activity."), @@ -162,6 +162,10 @@ class wkf_transition(osv.osv): 'wkf_id': fields.related('act_from','wkf_id', type='many2one', relation='workflow', string='Workflow', select=True), } + _defaults = { + 'condition': lambda *a: 'False', + } + wkf_transition() class wkf_instance(osv.osv): From 27a0a2c059e3cf5cbca02700b9f4ffb8c30150d0 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Thu, 11 Aug 2011 16:38:47 +0530 Subject: [PATCH 033/160] [ADD] account: Added new object account.report for printing reports. bzr revid: uco@tinyerp.com-20110811110847-telg63rtz0bshdry --- addons/account/__openerp__.py | 1 + addons/account/wizard/__init__.py | 1 + addons/account/wizard/account_report.py | 45 +++++++++++++++ addons/account/wizard/account_report_view.xml | 56 +++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 addons/account/wizard/account_report.py create mode 100644 addons/account/wizard/account_report_view.xml diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 23846183ddf..93270889657 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -98,6 +98,7 @@ module named account_voucher. 'wizard/account_reconcile_view.xml', 'wizard/account_reconcile_partner_process_view.xml', 'wizard/account_automatic_reconcile_view.xml', + 'wizard/account_report_view.xml', 'project/wizard/project_account_analytic_line_view.xml', 'account_end_fy.xml', 'account_invoice_view.xml', diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py index caed6fc3977..f6090539b73 100644 --- a/addons/account/wizard/__init__.py +++ b/addons/account/wizard/__init__.py @@ -47,6 +47,7 @@ import account_open_closed_fiscalyear import account_invoice_state import account_chart import account_tax_chart +import account_report #TODO: remove this file no moe used # also remove related view fiel diff --git a/addons/account/wizard/account_report.py b/addons/account/wizard/account_report.py new file mode 100644 index 00000000000..3cd3b06be44 --- /dev/null +++ b/addons/account/wizard/account_report.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import fields, osv + +class account_report(osv.osv_memory): + _name = "account.report" + _inherit = "account.common.report" + _description = "Account Report" + + _columns = { + 'parent_id': fields.many2one('account.report', 'Report'), + 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of invoice tax."), + 'type': fields.selection([ + ('sum','Sum'), + ('accounts','Accounts'), + ('account_report','Account Report'), + ],'Type'), + 'account_ids': fields.many2many('account.account', 'account_account_report', 'report_line_id', 'account_id', 'Accounts'), + 'note': fields.text('Notes'), + 'account_report_id': fields.many2one('account.report', 'Account Reports'), + 'enable_comparison': fields.boolean('Enable Comparison'), + } + +account_report() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_view.xml b/addons/account/wizard/account_report_view.xml new file mode 100644 index 00000000000..0b326626ee2 --- /dev/null +++ b/addons/account/wizard/account_report_view.xml @@ -0,0 +1,56 @@ + + + + + + Account Report + account.report + form + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Mail Report + account.report + ir.actions.act_window + form + form + + new + + + + + + From aeec03e7ebc622a7f10adc7d2d73bd9405e46691 Mon Sep 17 00:00:00 2001 From: gpa Date: Thu, 11 Aug 2011 18:51:48 +0530 Subject: [PATCH 034/160] [FIX]Added missing pg_path, to solve the problem of backup and restore of database lp bug: https://launchpad.net/bugs/723424 fixed bzr revid: gpa@tinyerp.com-20110811132148-xhje7bwwhzzty4vp --- setup.nsi | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.nsi b/setup.nsi index f9c962ae383..79e7903f6a3 100644 --- a/setup.nsi +++ b/setup.nsi @@ -210,6 +210,7 @@ Section OpenERP_Server SectionOpenERP_Server WriteIniStr "$INSTDIR\openerp-server.conf" "options" "db_user" $TextPostgreSQLUsername WriteIniStr "$INSTDIR\openerp-server.conf" "options" "db_password" $TextPostgreSQLPassword WriteIniStr "$INSTDIR\openerp-server.conf" "options" "db_port" $TextPostgreSQLPort + WriteIniStr "$INSTDIR\Server\openerp-server.conf" "options" "pg_path" "$INSTDIR\PostgreSQL\bin" nsExec::Exec '"$INSTDIR\openerp-server.exe" --stop-after-init --logfile "$INSTDIR\openerp-server.log" -s' nsExec::Exec '"$INSTDIR\service\OpenERPServerService.exe" -auto -install' From feffc1cb33559fbcbe9bdc583c59765f0071b96c Mon Sep 17 00:00:00 2001 From: gpa Date: Thu, 11 Aug 2011 18:58:15 +0530 Subject: [PATCH 035/160] [IMP]Improvement in code bzr revid: gpa@tinyerp.com-20110811132815-q37jxu29v6p368cr --- setup.nsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.nsi b/setup.nsi index 79e7903f6a3..0ea37b0f9e6 100644 --- a/setup.nsi +++ b/setup.nsi @@ -210,7 +210,7 @@ Section OpenERP_Server SectionOpenERP_Server WriteIniStr "$INSTDIR\openerp-server.conf" "options" "db_user" $TextPostgreSQLUsername WriteIniStr "$INSTDIR\openerp-server.conf" "options" "db_password" $TextPostgreSQLPassword WriteIniStr "$INSTDIR\openerp-server.conf" "options" "db_port" $TextPostgreSQLPort - WriteIniStr "$INSTDIR\Server\openerp-server.conf" "options" "pg_path" "$INSTDIR\PostgreSQL\bin" + WriteIniStr "$INSTDIR\openerp-server.conf" "options" "pg_path" "$INSTDIR\PostgreSQL\bin" nsExec::Exec '"$INSTDIR\openerp-server.exe" --stop-after-init --logfile "$INSTDIR\openerp-server.log" -s' nsExec::Exec '"$INSTDIR\service\OpenERPServerService.exe" -auto -install' From d4ee49e658a90657da2dc848c40e2dd31d5cd71d Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Fri, 12 Aug 2011 16:53:21 +0530 Subject: [PATCH 036/160] [IMP] account: Improved report. bzr revid: uco@tinyerp.com-20110812112321-3q1vfylgojz0s91h --- addons/account/account.py | 28 ++- addons/account/account_menuitem.xml | 1 + addons/account/account_view.xml | 49 +++++ addons/account/report/__init__.py | 1 + .../account/report/account_report_common.py | 83 ++++++++ .../account/report/account_report_common.rml | 187 ++++++++++++++++++ addons/account/wizard/account_report.py | 28 +-- addons/account/wizard/account_report_view.xml | 24 +-- 8 files changed, 371 insertions(+), 30 deletions(-) create mode 100644 addons/account/report/account_report_common.py create mode 100644 addons/account/report/account_report_common.rml diff --git a/addons/account/account.py b/addons/account/account.py index 72208314ed9..ec72237c897 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1331,7 +1331,7 @@ class account_move(osv.osv): def _centralise(self, cr, uid, move, mode, context=None): assert mode in ('debit', 'credit'), 'Invalid Mode' #to prevent sql injection - currency_obj = self.pool.get('res.currency') + currency_obj = self.pool.get('res.currency') if context is None: context = {} @@ -1593,7 +1593,7 @@ class account_tax_code(osv.osv): (parent_ids,) + where_params) res=dict(cr.fetchall()) obj_precision = self.pool.get('decimal.precision') - res2 = {} + res2 = {} for record in self.browse(cr, uid, ids, context=context): def _rec_get(record): amount = res.get(record.id, 0.0) @@ -2607,6 +2607,30 @@ class account_fiscal_position_account_template(osv.osv): account_fiscal_position_account_template() +class account_report(osv.osv): + _name = "account.report" + _description = "Account Report" + + _columns = { + 'name': fields.char('Report Name', size=64, required=True), + 'parent_id': fields.many2one('account.report', 'Parent Report'), + 'sequence': fields.integer('Sequence'), + 'type': fields.selection([ + ('sum','Sum'), + ('accounts','Accounts'), + ('account_report','Account Report'), + ],'Type'), + 'account_ids': fields.many2many('account.account', 'account_account_report', 'report_line_id', 'account_id', 'Accounts'), + 'note': fields.text('Notes'), + 'account_report_id': fields.many2one('account.report', 'Account Report'), + } + + _defaults = { + 'type': 'sum', + } + +account_report() + # Multi charts of Accounts wizard class wizard_multi_charts_accounts(osv.osv_memory): diff --git a/addons/account/account_menuitem.xml b/addons/account/account_menuitem.xml index 062e1f6382b..48fe424e7fb 100644 --- a/addons/account/account_menuitem.xml +++ b/addons/account/account_menuitem.xml @@ -30,6 +30,7 @@ + + + + + account.report.form + account.report + form + + + + + + + + + + + + + + + + + account.report.tree + account.report + tree + + + + + + + + + + + + + Account Reports + ir.actions.act_window + account.report + form + tree,form + + + + + diff --git a/addons/account/report/__init__.py b/addons/account/report/__init__.py index 7c09027f3ca..86c13a85582 100644 --- a/addons/account/report/__init__.py +++ b/addons/account/report/__init__.py @@ -42,6 +42,7 @@ import account_analytic_entries_report import account_balance_sheet import account_profit_loss import account_treasury_report +import account_report_common # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py new file mode 100644 index 00000000000..a2dbf62e7fa --- /dev/null +++ b/addons/account/report/account_report_common.py @@ -0,0 +1,83 @@ +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import time +import pooler +from report import report_sxw +from common_report_header import common_report_header +from tools.translate import _ + +class report_account_common(report_sxw.rml_parse, common_report_header): + + def __init__(self, cr, uid, name, context=None): + super(report_account_common, self).__init__(cr, uid, name, context=context) + self.localcontext.update( { + 'time': time, + 'get_report_name': self._get_report_name, + 'get_fiscalyear': self._get_fiscalyear, + 'get_account': self._get_account, + 'get_start_period': self.get_start_period, + 'get_end_period': self.get_end_period, + 'get_sortby': self._get_sortby, + 'get_filter': self._get_filter, + 'get_start_date':self._get_start_date, + 'get_end_date':self._get_end_date, + 'get_company':self._get_company, + 'get_account_details': self.get_account_details, + }) + self.context = context + + def set_context(self, objects, data, ids, report_type=None): + new_ids = ids + if (data['model'] == 'ir.ui.menu'): + new_ids = 'chart_account_id' in data['form'] and [data['form']['chart_account_id']] or [] + objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) + return super(report_account_common, self).set_context(objects, data, new_ids, report_type=report_type) + + def _get_report_name(self, data): + cr, uid = self.cr, self.uid + db_pool = pooler.get_pool(self.cr.dbname) + + report_obj = db_pool.get('account.report') + children = [] + name = data['form'].get('account_report_id') and data['form']['account_report_id'][1] or '' + report_id = data['form'].get('account_report_id') and data['form']['account_report_id'][0] or False + children.append({'id': report_id, 'name': name}) + if report_id: + child_ids = report_obj.search(cr, uid, [('parent_id','=',report_id)]) + for chld in report_obj.browse(cr, uid, child_ids): + children.append({'id': chld.id, 'name': chld.name}) + return children + + def get_account_details(self, acc_id): + cr, uid = self.cr, self.uid + db_pool = pooler.get_pool(self.cr.dbname) + + report_obj = db_pool.get('account.report') + accounts = [] + if acc_id: + for rpt in report_obj.browse(cr, uid, [acc_id]): + for acc in rpt.account_ids: + accounts.append({'code': acc.code, 'name': acc.name, 'bal': acc.balance}) + return accounts + +report_sxw.report_sxw('report.account.common', 'account.account', + 'addons/account/report/account_report_common.rml', parser=report_account_common, header='internal') + diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml new file mode 100644 index 00000000000..c0864862fbf --- /dev/null +++ b/addons/account/report/account_report_common.rml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Chart of Account + + + Fiscal Year + + + Filters By [[ get_filter(data)!='No Filter' and get_filter(data) ]] + + + + + [[ get_account(data) or '' ]] + + + [[ get_fiscalyear(data) or '' ]] + + + + + + [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + Start Date + + + End Date + + + + + [[ get_start_date(data) ]] + + + [[ get_end_date(data) ]] + + + + + + + [[ get_filter(data)=='Periods' or removeParentNode('blockTable')]] + ]]Start Period + + + End Period + + + + + [[ get_start_period(data) or removeParentNode('para') ]] + + + [[ get_end_period(data) or removeParentNode('para') ]] + + + + + + + + + + + + + + [[ repeatIn(get_report_name(data),'r') ]] + + + [[ r['name'] ]] + + + + Account Details + + + + + + + Code + + + Name + + + Balance + + + + + + [[ repeatIn(get_account_details(r['id']), 'a') ]] [[ a['code'] ]] + + + + + [[ a['name'] ]] + + + + + [[ a['bal'] ]] + + + + + + + + + + + + diff --git a/addons/account/wizard/account_report.py b/addons/account/wizard/account_report.py index 3cd3b06be44..784c1e03a7b 100644 --- a/addons/account/wizard/account_report.py +++ b/addons/account/wizard/account_report.py @@ -21,25 +21,27 @@ from osv import fields, osv -class account_report(osv.osv_memory): - _name = "account.report" +class accounting_report(osv.osv_memory): + _name = "accounting.report" _inherit = "account.common.report" _description = "Account Report" _columns = { - 'parent_id': fields.many2one('account.report', 'Report'), - 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of invoice tax."), - 'type': fields.selection([ - ('sum','Sum'), - ('accounts','Accounts'), - ('account_report','Account Report'), - ],'Type'), - 'account_ids': fields.many2many('account.account', 'account_account_report', 'report_line_id', 'account_id', 'Accounts'), - 'note': fields.text('Notes'), - 'account_report_id': fields.many2one('account.report', 'Account Reports'), 'enable_comparison': fields.boolean('Enable Comparison'), + 'display_details_per_account': fields.boolean('Display Details per Account'), + 'account_report_id': fields.many2one('account.report', 'Account Reports', required=True), } -account_report() + def _print_report(self, cr, uid, ids, data, context=None): + if context is None: + context = {} + data['form'].update(self.read(cr, uid, ids, ['account_report_id'], context=context)[0]) + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'account.common', + 'datas': data, + } + +accounting_report() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_view.xml b/addons/account/wizard/account_report_view.xml index 0b326626ee2..119b1d7f1bd 100644 --- a/addons/account/wizard/account_report_view.xml +++ b/addons/account/wizard/account_report_view.xml @@ -2,19 +2,16 @@ - + Account Report - account.report + accounting.report form - - - - - - + + + @@ -28,25 +25,22 @@ - - - - Mail Report - account.report + Report + accounting.report ir.actions.act_window form form - + new Date: Fri, 12 Aug 2011 17:52:34 +0530 Subject: [PATCH 037/160] [IMP] account: Improved report. bzr revid: uco@tinyerp.com-20110812122234-rkh36ya1zzmonpnt --- .../account/report/account_report_common.py | 28 +++++++++++++++---- .../account/report/account_report_common.rml | 24 ++++++++++++++-- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py index a2dbf62e7fa..69b5668bdbe 100644 --- a/addons/account/report/account_report_common.py +++ b/addons/account/report/account_report_common.py @@ -30,7 +30,7 @@ class report_account_common(report_sxw.rml_parse, common_report_header): super(report_account_common, self).__init__(cr, uid, name, context=context) self.localcontext.update( { 'time': time, - 'get_report_name': self._get_report_name, + 'get_report_details': self._get_report_details, 'get_fiscalyear': self._get_fiscalyear, 'get_account': self._get_account, 'get_start_period': self.get_start_period, @@ -51,20 +51,32 @@ class report_account_common(report_sxw.rml_parse, common_report_header): objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) return super(report_account_common, self).set_context(objects, data, new_ids, report_type=report_type) - def _get_report_name(self, data): + def _get_report_details(self, data): cr, uid = self.cr, self.uid db_pool = pooler.get_pool(self.cr.dbname) report_obj = db_pool.get('account.report') - children = [] + datas = [] + balance = 0.0 name = data['form'].get('account_report_id') and data['form']['account_report_id'][1] or '' report_id = data['form'].get('account_report_id') and data['form']['account_report_id'][0] or False - children.append({'id': report_id, 'name': name}) + datas.append({'id': report_id}) if report_id: child_ids = report_obj.search(cr, uid, [('parent_id','=',report_id)]) + child_ids.append(datas[0]['id']) for chld in report_obj.browse(cr, uid, child_ids): - children.append({'id': chld.id, 'name': chld.name}) - return children + if chld.type == 'accounts': + for a in chld.account_ids: + balance += a.balance + if chld.type == 'account_report': + pass # TDDO: it's the balance of the linked account.report (so it means it's only a way to reuse figures coming from another report) + if chld.type == 'sum': + pass # TDDO: it's the sum of balance of the children of this account.report (if there isn't, then it's 0.0) + if chld.id == datas[0]['id']: + datas[0].update({'name': chld.name, 'balance': balance}) + else: + datas.append({'id': chld.id, 'name': chld.name, 'balance': balance}) + return datas def get_account_details(self, acc_id): cr, uid = self.cr, self.uid @@ -78,6 +90,10 @@ class report_account_common(report_sxw.rml_parse, common_report_header): accounts.append({'code': acc.code, 'name': acc.name, 'bal': acc.balance}) return accounts + def get_report_balance(self): + balance = 0.0 + return balance + report_sxw.report_sxw('report.account.common', 'account.account', 'addons/account/report/account_report_common.rml', parser=report_account_common, header='internal') diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml index c0864862fbf..9918ad0ee18 100644 --- a/addons/account/report/account_report_common.rml +++ b/addons/account/report/account_report_common.rml @@ -136,10 +136,30 @@ - [[ repeatIn(get_report_name(data),'r') ]] + [[ repeatIn(get_report_details(data),'r') ]] - [[ r['name'] ]] + + + + Report Name + + + Report Balance + + + + + [[ r['name'] ]] + + + [[ r['balance'] ]] + + + + + + From 56ca812f04f110a84c67d7ae643914bccf1c71ff Mon Sep 17 00:00:00 2001 From: "Purnendu Singh (OpenERP)" Date: Wed, 17 Aug 2011 17:32:19 +0530 Subject: [PATCH 038/160] [IMP] account: Improve the code so it will consider the check box display_details_per_account, improve rml, and some logic bzr revid: psi@tinyerp.com-20110817120219-39eg41ofgeyniyk1 --- .../account/report/account_report_common.py | 37 +++-- .../account/report/account_report_common.rml | 152 ++++++------------ addons/account/wizard/account_report.py | 6 +- 3 files changed, 72 insertions(+), 123 deletions(-) diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py index 69b5668bdbe..57a97f8ab4e 100644 --- a/addons/account/report/account_report_common.py +++ b/addons/account/report/account_report_common.py @@ -19,7 +19,7 @@ ############################################################################## import time -import pooler + from report import report_sxw from common_report_header import common_report_header from tools.translate import _ @@ -53,9 +53,8 @@ class report_account_common(report_sxw.rml_parse, common_report_header): def _get_report_details(self, data): cr, uid = self.cr, self.uid - db_pool = pooler.get_pool(self.cr.dbname) - report_obj = db_pool.get('account.report') + report_obj = self.pool.get('account.report') datas = [] balance = 0.0 name = data['form'].get('account_report_id') and data['form']['account_report_id'][1] or '' @@ -64,27 +63,31 @@ class report_account_common(report_sxw.rml_parse, common_report_header): if report_id: child_ids = report_obj.search(cr, uid, [('parent_id','=',report_id)]) child_ids.append(datas[0]['id']) - for chld in report_obj.browse(cr, uid, child_ids): - if chld.type == 'accounts': - for a in chld.account_ids: + for child in report_obj.browse(cr, uid, child_ids): + if child.type == 'accounts': + for a in child.account_ids: balance += a.balance - if chld.type == 'account_report': - pass # TDDO: it's the balance of the linked account.report (so it means it's only a way to reuse figures coming from another report) - if chld.type == 'sum': - pass # TDDO: it's the sum of balance of the children of this account.report (if there isn't, then it's 0.0) - if chld.id == datas[0]['id']: - datas[0].update({'name': chld.name, 'balance': balance}) + # it's the balance of the linked account.report (so it means it's only a way to reuse figures coming from another report) + if child.type == 'account_report' and child.account_report_id: + for a in child.account_report_id.account_ids: + balance +=a.balance + #it's the sum of balance of the children of this account.report (if there isn't, then it's 0.0) + if child.type == 'sum': + for child in report_obj.browse(cr, uid, child_ids): + for a in child.account_ids: + balance += a.balance + if child.id == datas[0]['id']: + datas[0].update({'name': child.name, 'balance': balance}) else: - datas.append({'id': chld.id, 'name': chld.name, 'balance': balance}) + datas.append({'id': child.id, 'name': child.name, 'balance': balance}) return datas - def get_account_details(self, acc_id): + def get_account_details(self, acc_id, data): cr, uid = self.cr, self.uid - db_pool = pooler.get_pool(self.cr.dbname) - report_obj = db_pool.get('account.report') + report_obj = self.pool.get('account.report') accounts = [] - if acc_id: + if acc_id and data['form'].get('display_details_per_account', False): for rpt in report_obj.browse(cr, uid, [acc_id]): for acc in rpt.account_ids: accounts.append({'code': acc.code, 'name': acc.name, 'bal': acc.balance}) diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml index 9918ad0ee18..602f072f47d 100644 --- a/addons/account/report/account_report_common.rml +++ b/addons/account/report/account_report_common.rml @@ -59,6 +59,7 @@ + @@ -68,133 +69,74 @@ - + - - Chart of Account - - - Fiscal Year - - - Filters By [[ get_filter(data)!='No Filter' and get_filter(data) ]] - + Chart of Account + Fiscal Year + Filter By [[ get_filter(data)!='No Filter' and '' or removeParentNode('font') ]] - - - [[ get_account(data) or '' ]] + + [[ get_account(data) or removeParentNode('para') ]] + [[ get_fiscalyear(data) or '' ]] + [[ get_filter(data)=='No Filter' and get_filter(data) or removeParentNode('para') ]] + [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] + + Start Date + End Date + + + [[ formatLang(get_start_date(data),date=True) ]] + [[ formatLang(get_end_date(data),date=True) ]] + + + [[ get_filter(data)=='Periods' or removeParentNode('blockTable') ]] + + Start Period + End Period + + + [[ get_start_period(data) or removeParentNode('para') ]] + [[ get_end_period(data) or removeParentNode('para') ]] + + - - [[ get_fiscalyear(data) or '' ]] - - - - - - [[ get_filter(data)=='Date' or removeParentNode('blockTable') ]] - Start Date - - - End Date - - - - - [[ get_start_date(data) ]] - - - [[ get_end_date(data) ]] - - - - - - - [[ get_filter(data)=='Periods' or removeParentNode('blockTable')]] - ]]Start Period - - - End Period - - - - - [[ get_start_period(data) or removeParentNode('para') ]] - - - [[ get_end_period(data) or removeParentNode('para') ]] - - - - - - - - + - - - + + + [[ repeatIn(get_report_details(data),'r') ]] - + - - Report Name - - - Report Balance - + Report Name + Report Balance - - [[ r['name'] ]] - - - [[ r['balance'] ]] - + [[ r['name'] ]] + [[ r['balance'] ]] - + - - Account Details - + Account Details - + - - Code - - - Name - - - Balance - + Code + Name + Balance - - - [[ repeatIn(get_account_details(r['id']), 'a') ]] [[ a['code'] ]] - - - - - [[ a['name'] ]] - - - - - [[ a['bal'] ]] - - + [[ repeatIn(get_account_details(r['id'], data), 'a') ]] [[ a['code'] ]] + [[ a['name'] ]] + [[ a['bal'] ]] diff --git a/addons/account/wizard/account_report.py b/addons/account/wizard/account_report.py index 784c1e03a7b..064c9bb723e 100644 --- a/addons/account/wizard/account_report.py +++ b/addons/account/wizard/account_report.py @@ -32,10 +32,14 @@ class accounting_report(osv.osv_memory): 'account_report_id': fields.many2one('account.report', 'Account Reports', required=True), } + _defaults={ + 'enable_comparison': False, + 'display_details_per_account': False, + } def _print_report(self, cr, uid, ids, data, context=None): if context is None: context = {} - data['form'].update(self.read(cr, uid, ids, ['account_report_id'], context=context)[0]) + data['form'].update(self.read(cr, uid, ids, ['account_report_id', 'enable_comparison', 'display_details_per_account'], context=context)[0]) return { 'type': 'ir.actions.report.xml', 'report_name': 'account.common', From 2854c3091ed8c4a507a29b5768951213ced8c6b7 Mon Sep 17 00:00:00 2001 From: "Mustufa Rangwala (OpenERP)" Date: Thu, 18 Aug 2011 11:10:26 +0530 Subject: [PATCH 039/160] [IMP] Code clean bzr revid: mra@tinyerp.com-20110818054026-1c8295185zn9vmp4 --- addons/account/account.py | 4 ++-- addons/account/report/account_report_common.py | 2 -- addons/account/wizard/account_report.py | 9 +-------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index f58f478b5fd..ba8cdbcd9a2 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2612,8 +2612,8 @@ class account_report(osv.osv): _description = "Account Report" _columns = { - 'name': fields.char('Report Name', size=64, required=True), - 'parent_id': fields.many2one('account.report', 'Parent Report'), + 'name': fields.char('Report Name', size=32, required=True), + 'parent_id': fields.many2one('account.report', 'Parent'), 'sequence': fields.integer('Sequence'), 'type': fields.selection([ ('sum','Sum'), diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py index 57a97f8ab4e..c8b899e5311 100644 --- a/addons/account/report/account_report_common.py +++ b/addons/account/report/account_report_common.py @@ -53,7 +53,6 @@ class report_account_common(report_sxw.rml_parse, common_report_header): def _get_report_details(self, data): cr, uid = self.cr, self.uid - report_obj = self.pool.get('account.report') datas = [] balance = 0.0 @@ -84,7 +83,6 @@ class report_account_common(report_sxw.rml_parse, common_report_header): def get_account_details(self, acc_id, data): cr, uid = self.cr, self.uid - report_obj = self.pool.get('account.report') accounts = [] if acc_id and data['form'].get('display_details_per_account', False): diff --git a/addons/account/wizard/account_report.py b/addons/account/wizard/account_report.py index 064c9bb723e..1174fb04bfc 100644 --- a/addons/account/wizard/account_report.py +++ b/addons/account/wizard/account_report.py @@ -31,14 +31,7 @@ class accounting_report(osv.osv_memory): 'display_details_per_account': fields.boolean('Display Details per Account'), 'account_report_id': fields.many2one('account.report', 'Account Reports', required=True), } - - _defaults={ - 'enable_comparison': False, - 'display_details_per_account': False, - } def _print_report(self, cr, uid, ids, data, context=None): - if context is None: - context = {} data['form'].update(self.read(cr, uid, ids, ['account_report_id', 'enable_comparison', 'display_details_per_account'], context=context)[0]) return { 'type': 'ir.actions.report.xml', @@ -48,4 +41,4 @@ class accounting_report(osv.osv_memory): accounting_report() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file From b2415915cd8c1619f833dfe524103003b4102b11 Mon Sep 17 00:00:00 2001 From: gpa Date: Thu, 18 Aug 2011 11:53:26 +0530 Subject: [PATCH 040/160] [FIX] Fixed problem of import translation do not work after another import lp bug: https://launchpad.net/bugs/826623 fixed bzr revid: gpa@tinyerp.com-20110818062326-bc0ti49g2p6e6z7w --- .../base/module/wizard/base_import_language.py | 14 +++++++++++--- .../module/wizard/base_import_language_view.xml | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/openerp/addons/base/module/wizard/base_import_language.py b/openerp/addons/base/module/wizard/base_import_language.py index d73cd0864a6..f9587df1911 100644 --- a/openerp/addons/base/module/wizard/base_import_language.py +++ b/openerp/addons/base/module/wizard/base_import_language.py @@ -35,9 +35,13 @@ class base_language_import(osv.osv_memory): 'name': fields.char('Language Name',size=64 , required=True), 'code': fields.char('Code (eg:en__US)',size=5 , required=True), 'data': fields.binary('File', required=True), + 'overwrite': fields.boolean('Overwrite Existing Terms'), + } + _defaults = { + 'overwrite': False } - def import_lang(self, cr, uid, ids, context): + def import_lang(self, cr, uid, ids, context=None): """ Import Language @param cr: the current row, from the database cursor. @@ -45,8 +49,12 @@ class base_language_import(osv.osv_memory): @param ids: the ID or list of IDs @param context: A standard dictionary """ - + if context is None: + context = {} + import_data = self.browse(cr, uid, ids)[0] + if import_data.overwrite: + context = {'overwrite': True} fileobj = TemporaryFile('w+') fileobj.write(base64.decodestring(import_data.data)) @@ -56,7 +64,7 @@ class base_language_import(osv.osv_memory): fileformat = first_line.endswith("type,name,res_id,src,value") and 'csv' or 'po' fileobj.seek(0) - tools.trans_load_data(cr, fileobj, fileformat, import_data.code, lang_name=import_data.name) + tools.trans_load_data(cr, fileobj, fileformat, import_data.code, lang_name=import_data.name, context=context) tools.trans_update_res_ids(cr) fileobj.close() return {} diff --git a/openerp/addons/base/module/wizard/base_import_language_view.xml b/openerp/addons/base/module/wizard/base_import_language_view.xml index d313afc4080..4a1d7e5b758 100644 --- a/openerp/addons/base/module/wizard/base_import_language_view.xml +++ b/openerp/addons/base/module/wizard/base_import_language_view.xml @@ -27,6 +27,7 @@ + From e111108320459ca80a303126659ae13826d8e2a2 Mon Sep 17 00:00:00 2001 From: "Purnendu Singh (OpenERP)" Date: Fri, 19 Aug 2011 11:10:14 +0530 Subject: [PATCH 041/160] [IMP] accunt : small improvments like renaming variable bzr revid: psi@tinyerp.com-20110819054014-bh4cut8jd3d3nwv0 --- addons/account/report/account_report_common.rml | 10 +++++----- addons/account/wizard/account_report.py | 6 +++--- addons/account/wizard/account_report_view.xml | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml index 602f072f47d..130d903a62a 100644 --- a/addons/account/report/account_report_common.rml +++ b/addons/account/report/account_report_common.rml @@ -13,22 +13,22 @@ - + - + xtly - + - + @@ -37,7 +37,7 @@ - + diff --git a/addons/account/wizard/account_report.py b/addons/account/wizard/account_report.py index 064c9bb723e..1cc4e2d32c0 100644 --- a/addons/account/wizard/account_report.py +++ b/addons/account/wizard/account_report.py @@ -27,8 +27,8 @@ class accounting_report(osv.osv_memory): _description = "Account Report" _columns = { - 'enable_comparison': fields.boolean('Enable Comparison'), - 'display_details_per_account': fields.boolean('Display Details per Account'), + 'comparison': fields.boolean('Enable Comparison'), + 'account_details': fields.boolean('Details by Account'), 'account_report_id': fields.many2one('account.report', 'Account Reports', required=True), } @@ -39,7 +39,7 @@ class accounting_report(osv.osv_memory): def _print_report(self, cr, uid, ids, data, context=None): if context is None: context = {} - data['form'].update(self.read(cr, uid, ids, ['account_report_id', 'enable_comparison', 'display_details_per_account'], context=context)[0]) + data['form'].update(self.read(cr, uid, ids, ['account_report_id', 'comparison', 'account_details'], context=context)[0]) return { 'type': 'ir.actions.report.xml', 'report_name': 'account.common', diff --git a/addons/account/wizard/account_report_view.xml b/addons/account/wizard/account_report_view.xml index 119b1d7f1bd..6c436f97057 100644 --- a/addons/account/wizard/account_report_view.xml +++ b/addons/account/wizard/account_report_view.xml @@ -10,11 +10,11 @@ - - + + - + From 98cb234bf6e94dbafbabed6e782d7950b7d5dd93 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Fri, 19 Aug 2011 17:42:02 +0530 Subject: [PATCH 042/160] [IMP] account: Small improvements in formatting and improved some code. bzr revid: uco@tinyerp.com-20110819121202-i827lpb1yq8y5hyh --- .../account/report/account_report_common.py | 29 ++++++++++--------- .../account/report/account_report_common.rml | 16 +++++----- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py index c8b899e5311..21a1eb5f6e3 100644 --- a/addons/account/report/account_report_common.py +++ b/addons/account/report/account_report_common.py @@ -63,18 +63,7 @@ class report_account_common(report_sxw.rml_parse, common_report_header): child_ids = report_obj.search(cr, uid, [('parent_id','=',report_id)]) child_ids.append(datas[0]['id']) for child in report_obj.browse(cr, uid, child_ids): - if child.type == 'accounts': - for a in child.account_ids: - balance += a.balance - # it's the balance of the linked account.report (so it means it's only a way to reuse figures coming from another report) - if child.type == 'account_report' and child.account_report_id: - for a in child.account_report_id.account_ids: - balance +=a.balance - #it's the sum of balance of the children of this account.report (if there isn't, then it's 0.0) - if child.type == 'sum': - for child in report_obj.browse(cr, uid, child_ids): - for a in child.account_ids: - balance += a.balance + balance = self.get_report_balance(child) if child.id == datas[0]['id']: datas[0].update({'name': child.name, 'balance': balance}) else: @@ -85,14 +74,26 @@ class report_account_common(report_sxw.rml_parse, common_report_header): cr, uid = self.cr, self.uid report_obj = self.pool.get('account.report') accounts = [] - if acc_id and data['form'].get('display_details_per_account', False): + if acc_id and data['form'].get('account_details', False): for rpt in report_obj.browse(cr, uid, [acc_id]): for acc in rpt.account_ids: accounts.append({'code': acc.code, 'name': acc.name, 'bal': acc.balance}) return accounts - def get_report_balance(self): + def get_report_balance(self, child): balance = 0.0 + if child.type == 'accounts': + for a in child.account_ids: + balance += a.balance + # it's the balance of the linked account.report (so it means it's only a way to reuse figures coming from another report) + if child.type == 'account_report' and child.account_report_id: + for a in child.account_report_id.account_ids: + balance += a.balance + #it's the sum of balance of the children of this account.report (if there isn't, then it's 0.0) + if child.type == 'sum': + for child in report_obj.browse(cr, uid, child_ids): + for a in child.account_ids: + balance += a.balance return balance report_sxw.report_sxw('report.account.common', 'account.account', diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml index 130d903a62a..44edd762bdb 100644 --- a/addons/account/report/account_report_common.rml +++ b/addons/account/report/account_report_common.rml @@ -105,29 +105,31 @@ - + [[ repeatIn(get_report_details(data),'r') ]] - + Report Name Report Balance [[ r['name'] ]] - [[ r['balance'] ]] + [[ formatLang(r['balance']) ]] - + - Account Details + + Account Details + - + Code Name @@ -136,7 +138,7 @@ [[ repeatIn(get_account_details(r['id'], data), 'a') ]] [[ a['code'] ]] [[ a['name'] ]] - [[ a['bal'] ]] + [[ formatLang(a['bal']) ]] From 5989085e5ad751454a769236c7b307fe2d1d223f Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Tue, 23 Aug 2011 15:05:25 +0530 Subject: [PATCH 043/160] [IMP] account: Improved account report. bzr revid: uco@tinyerp.com-20110823093525-me84x0jpndcmc5po --- .../account/report/account_report_common.py | 30 +- .../account/report/account_report_common.rml | 349 ++++++++++++------ addons/account/wizard/account_report_view.xml | 2 +- 3 files changed, 257 insertions(+), 124 deletions(-) diff --git a/addons/account/report/account_report_common.py b/addons/account/report/account_report_common.py index 21a1eb5f6e3..05a4049ee30 100644 --- a/addons/account/report/account_report_common.py +++ b/addons/account/report/account_report_common.py @@ -35,11 +35,9 @@ class report_account_common(report_sxw.rml_parse, common_report_header): 'get_account': self._get_account, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, - 'get_sortby': self._get_sortby, 'get_filter': self._get_filter, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, - 'get_company':self._get_company, 'get_account_details': self.get_account_details, }) self.context = context @@ -59,11 +57,12 @@ class report_account_common(report_sxw.rml_parse, common_report_header): name = data['form'].get('account_report_id') and data['form']['account_report_id'][1] or '' report_id = data['form'].get('account_report_id') and data['form']['account_report_id'][0] or False datas.append({'id': report_id}) + ctx = self.context.copy() if report_id: child_ids = report_obj.search(cr, uid, [('parent_id','=',report_id)]) child_ids.append(datas[0]['id']) - for child in report_obj.browse(cr, uid, child_ids): - balance = self.get_report_balance(child) + for child in report_obj.browse(cr, uid, child_ids, context=ctx): + balance = self.get_report_balance(child, child_ids, ctx) if child.id == datas[0]['id']: datas[0].update({'name': child.name, 'balance': balance}) else: @@ -74,14 +73,27 @@ class report_account_common(report_sxw.rml_parse, common_report_header): cr, uid = self.cr, self.uid report_obj = self.pool.get('account.report') accounts = [] + + ctx = self.context.copy() + ctx['fiscalyear'] = data['form'].get('fiscalyear_id', False) + + if data['form']['filter'] == 'filter_period': + ctx['period_from'] = data['form'].get('period_from', False) + ctx['period_to'] = data['form'].get('period_to', False) + elif data['form']['filter'] == 'filter_date': + ctx['date_from'] = data['form'].get('date_from', False) + ctx['date_to'] = data['form'].get('date_to', False) + if acc_id and data['form'].get('account_details', False): - for rpt in report_obj.browse(cr, uid, [acc_id]): - for acc in rpt.account_ids: - accounts.append({'code': acc.code, 'name': acc.name, 'bal': acc.balance}) + for rpt in report_obj.browse(cr, uid, [acc_id], context=ctx): + accounts = [acc for acc in rpt.account_ids if acc.level != 0] return accounts - def get_report_balance(self, child): + def get_report_balance(self, child, child_ids, context=None): + cr, uid = self.cr, self.uid + report_obj = self.pool.get('account.report') balance = 0.0 + # it's the sum of balance of the linked accounts if child.type == 'accounts': for a in child.account_ids: balance += a.balance @@ -91,7 +103,7 @@ class report_account_common(report_sxw.rml_parse, common_report_header): balance += a.balance #it's the sum of balance of the children of this account.report (if there isn't, then it's 0.0) if child.type == 'sum': - for child in report_obj.browse(cr, uid, child_ids): + for child in report_obj.browse(cr, uid, child_ids, context=context): for a in child.account_ids: balance += a.balance return balance diff --git a/addons/account/report/account_report_common.rml b/addons/account/report/account_report_common.rml index 44edd762bdb..adc751f9cab 100644 --- a/addons/account/report/account_report_common.rml +++ b/addons/account/report/account_report_common.rml @@ -1,8 +1,8 @@ -