From b495cec9d12666240ff4d8a31dc3ec0b97dcbcaf Mon Sep 17 00:00:00 2001 From: Husen Daudi Date: Wed, 28 May 2008 03:03:38 +0000 Subject: [PATCH 001/159] Module for password encryption. bzr revid: hda@tinyerp.com-20080528030338-7izwvtmmmizg9sp5 --- addons/base_crypt/__init__.py | 31 ++++++ addons/base_crypt/__terp__.py | 16 +++ addons/base_crypt/base_update.xml | 29 +++++ addons/base_crypt/crypt.py | 173 ++++++++++++++++++++++++++++++ 4 files changed, 249 insertions(+) create mode 100644 addons/base_crypt/__init__.py create mode 100644 addons/base_crypt/__terp__.py create mode 100644 addons/base_crypt/base_update.xml create mode 100644 addons/base_crypt/crypt.py diff --git a/addons/base_crypt/__init__.py b/addons/base_crypt/__init__.py new file mode 100644 index 00000000000..88854384b0e --- /dev/null +++ b/addons/base_crypt/__init__.py @@ -0,0 +1,31 @@ +############################################################################## +# +# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved. +# Fabien Pinckaers +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +from service import security +import crypt + diff --git a/addons/base_crypt/__terp__.py b/addons/base_crypt/__terp__.py new file mode 100644 index 00000000000..b6780541289 --- /dev/null +++ b/addons/base_crypt/__terp__.py @@ -0,0 +1,16 @@ +{ + "name" : "Base", + "version" : "1.0", + "author" : "Tiny", + "website" : "http://tinyerp.com", + "category" : "Generic Modules/Base", + "description": "Module for password encryption.", + "depends" : ["base"], + "init_xml" : [], + "demo_xml" : [], + "update_xml" : [ + "base_update.xml", + ], + "active": False, + "installable": True, +} diff --git a/addons/base_crypt/base_update.xml b/addons/base_crypt/base_update.xml new file mode 100644 index 00000000000..06de41b4850 --- /dev/null +++ b/addons/base_crypt/base_update.xml @@ -0,0 +1,29 @@ + + + + + + res.users.form.modif.inherit + res.users + form + + + + + + + + + + res.users.form.inherit1 + res.users + form + + + + + + + + + diff --git a/addons/base_crypt/crypt.py b/addons/base_crypt/crypt.py new file mode 100644 index 00000000000..1d461463a27 --- /dev/null +++ b/addons/base_crypt/crypt.py @@ -0,0 +1,173 @@ +from random import seed, sample +from string import letters, digits +from osv import fields,osv +import pooler +import tools +from service import security + +magic_md5 = '$1$' + +def gen_salt( length=8, symbols=letters + digits ): + seed() + return ''.join( sample( symbols, length ) ) + +import md5 + +def encrypt_md5( raw_pw, salt, magic=magic_md5 ): + hash = md5.new( raw_pw + magic + salt ) + stretch = md5.new( raw_pw + salt + raw_pw).digest() + + for i in range( 0, len( raw_pw ) ): + hash.update( stretch[i % 16] ) + + i = len( raw_pw ) + + while i: + if i & 1: + hash.update('\x00') + else: + hash.update( raw_pw[0] ) + i >>= 1 + + saltedmd5 = hash.digest() + + for i in range( 1000 ): + hash = md5.new() + + if i & 1: + hash.update( raw_pw ) + else: + hash.update( saltedmd5 ) + + if i % 3: + hash.update( salt ) + if i % 7: + hash.update( raw_pw ) + if i & 1: + hash.update( saltedmd5 ) + else: + hash.update( raw_pw ) + + saltedmd5 = hash.digest() + + itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + + rearranged = '' + for a, b, c in ((0, 6, 12), (1, 7, 13), (2, 8, 14), (3, 9, 15), (4, 10, 5)): + v = ord( saltedmd5[a] ) << 16 | ord( saltedmd5[b] ) << 8 | ord( saltedmd5[c] ) + + for i in range(4): + rearranged += itoa64[v & 0x3f] + v >>= 6 + + v = ord( saltedmd5[11] ) + + for i in range( 2 ): + rearranged += itoa64[v & 0x3f] + v >>= 6 + + return magic + salt + '$' + rearranged + +_salt_cache = {} + +def login(db, login, password): + cr = pooler.get_db(db).cursor() + cr.execute( 'select password from res_users where login=%s', (login.encode( 'utf-8' ),) ) + stored_pw = cr.fetchone() + + if stored_pw: + stored_pw = stored_pw[0] + else: + # Return early if no one has a login name like that. + return False + + # Calculate a new password ('updated_pw') from 'stored_pw' if the + # latter isn't encrypted yet. Use that to update the database entry. + # Also update the 'stored_pw' to reflect the change. + + if stored_pw[0:3] != magic_md5: + updated_pw = encrypt_md5( stored_pw, gen_salt() ) + cr.execute( 'update res_users set password=%s where login=%s', (updated_pw.encode( 'utf-8' ), login.encode( 'utf-8' ),) ) + cr.commit() + + cr.execute( 'select password from res_users where login=%s', (login.encode( 'utf-8' ),) ) + stored_pw = cr.fetchone()[0] + + # Calculate an encrypted password from the user-provided + # password ('encrypted_pw'). + + salt = _salt_cache[password] = stored_pw[3:11] + encrypted_pw = encrypt_md5( password, salt ) + + # Retrieve a user id from the database, factoring in an encrypted + # password. + + cr.execute('select id from res_users where login=%s and password=%s and active', (login.encode('utf-8'), encrypted_pw.encode('utf-8'))) + res = cr.fetchone() + cr.close() + + if res: + return res[0] + else: + return False + +#def check_super(passwd): +# salt = _salt_cache[passwd] +# if encrypt_md5( passwd, salt ) == tools.config['admin_passwd']: +# return True +# else: +# raise Exception('AccessDenied') + +def check(db, uid, passwd): + if security._uid_cache.has_key( uid ) and (security._uid_cache[uid]==passwd): + return True + cr = pooler.get_db(db).cursor() + salt = _salt_cache[passwd] + cr.execute(' select count(*) from res_users where id=%d and password=%s', (int(uid), encrypt_md5( passwd, salt )) ) + res = cr.fetchone()[0] + cr.close() + if not bool(res): + raise Exception('AccessDenied') + if res: + security._uid_cache[uid] = passwd + return bool(res) + + +def access(db, uid, passwd, sec_level, ids): + cr = pooler.get_db(db).cursor() + salt = _salt_cache[passwd] + cr.execute('select id from res_users where id=%s and password=%s', (uid, encrypt_md5( passwd, salt )) ) + res = cr.fetchone() + cr.close() + if not res: + raise Exception('Bad username or password') + return res[0] + +# check if module is installed or not +security.login=login +#security.check_super=check_super +security.access=access +security.check=check + +class users(osv.osv): + _name="res.users" + _inherit="res.users" + # agi - 022108 + # Add handlers for 'input_pw' field. + + def set_pw( self, cr, uid, id, name, value, args, context ): + self.write( cr, uid, id, { 'password' : encrypt_md5( value, gen_salt() ) } ) + del value + + def get_pw( self, cr, uid, ids, name, args, context ): + res = {} + for id in ids: + res[id] = '' + return res + + # Continuing to original code. + + _columns = { + 'input_pw': fields.function( get_pw, fnct_inv=set_pw, type='char', method=True, size=20, string='Password', invisible=True), + } +users() \ No newline at end of file From e830358b25b74430c8bceb3e724f774d440a09d1 Mon Sep 17 00:00:00 2001 From: Husen Daudi Date: Thu, 29 May 2008 04:46:07 +0000 Subject: [PATCH 002/159] Add copyrights bzr revid: hda@tinyerp.com-20080529044607-09pqwt6ihm3j62go --- addons/base_crypt/crypt.py | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/addons/base_crypt/crypt.py b/addons/base_crypt/crypt.py index 1d461463a27..7d2ab0e8cf7 100644 --- a/addons/base_crypt/crypt.py +++ b/addons/base_crypt/crypt.py @@ -1,3 +1,41 @@ +# Notice: +# ------ +# +# Implements encrypting functions. +# +# Copyright (c) 2008, F S 3 Consulting Inc. +# +# Maintainer: +# Alec Joseph Rivera (agifs3.ph) +# +# +# Warning: +# ------- +# +# This program as such is intended to be used by professional programmers +# who take the whole responsibility of assessing all potential consequences +# resulting from its eventual inadequacies and bugs. End users who are +# looking for a ready-to-use solution with commercial guarantees and +# support are strongly adviced to contract a Free Software Service Company. +# +# This program is Free Software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 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 General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the: +# +# Free Software Foundation, Inc. +# 59 Temple Place - Suite 330 +# Boston, MA 02111-1307 +# USA. + from random import seed, sample from string import letters, digits from osv import fields,osv @@ -11,6 +49,22 @@ def gen_salt( length=8, symbols=letters + digits ): seed() return ''.join( sample( symbols, length ) ) +# The encrypt_md5 is based on Mark Johnson's md5crypt.py, which in turn is +# based on FreeBSD src/lib/libcrypt/crypt.c (1.2) by Poul-Henning Kamp. +# Mark's port can be found in ActiveState ASPN Python Cookbook. Kudos to +# Poul and Mark. -agi +# +# Original license: +# +# * "THE BEER-WARE LICENSE" (Revision 42): +# * +# * wrote this file. As long as you retain this +# * notice you can do whatever you want with this stuff. If we meet some +# * day, and you think this stuff is worth it, you can buy me a beer in +# * return. +# * +# * Poul-Henning Kamp + import md5 def encrypt_md5( raw_pw, salt, magic=magic_md5 ): From 601f6d412b0e7f4c654b086632f0df9d0f4ca889 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Thu, 29 May 2008 11:14:58 +0000 Subject: [PATCH 003/159] Changed author bzr revid: fp@tinyerp.com-20080529111458-x1rf2m3z134qs710 --- addons/base_crypt/__terp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/base_crypt/__terp__.py b/addons/base_crypt/__terp__.py index b6780541289..8c93f4e9e01 100644 --- a/addons/base_crypt/__terp__.py +++ b/addons/base_crypt/__terp__.py @@ -1,7 +1,7 @@ { "name" : "Base", "version" : "1.0", - "author" : "Tiny", + "author" : "FS3 , Review Tiny", "website" : "http://tinyerp.com", "category" : "Generic Modules/Base", "description": "Module for password encryption.", From f522b775740cca110ae434e7b687d83501e6465c Mon Sep 17 00:00:00 2001 From: Husen Daudi Date: Wed, 11 Jun 2008 07:03:22 +0000 Subject: [PATCH 004/159] Improve code to check cache (reference: HMO) bzr revid: hda@tinyerp.com-20080611070322-smrboaciwsho7env --- addons/base_crypt/crypt.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/base_crypt/crypt.py b/addons/base_crypt/crypt.py index 7d2ab0e8cf7..c3d7a71e5ef 100644 --- a/addons/base_crypt/crypt.py +++ b/addons/base_crypt/crypt.py @@ -176,6 +176,14 @@ def check(db, uid, passwd): if security._uid_cache.has_key( uid ) and (security._uid_cache[uid]==passwd): return True cr = pooler.get_db(db).cursor() + if passwd not in _salt_cache: + cr.execute( 'select login from res_users where id=%d', (uid,) ) + stored_login = cr.fetchone() + if stored_login: + stored_login = stored_login[0] + + if not login(db,stored_login,passwd): + return False salt = _salt_cache[passwd] cr.execute(' select count(*) from res_users where id=%d and password=%s', (int(uid), encrypt_md5( passwd, salt )) ) res = cr.fetchone()[0] From eebf1d9860aefdd6933f0a3dbf19d764d5b1d9aa Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Mon, 22 Sep 2008 10:10:56 +0200 Subject: [PATCH 005/159] merge bzr revid: vmt@openerp.com-20080922081056-td14d6etaevzjbzm --- addons/base_crypt/base_update.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/base_crypt/base_update.xml b/addons/base_crypt/base_update.xml index 06de41b4850..8a0a5443eb8 100644 --- a/addons/base_crypt/base_update.xml +++ b/addons/base_crypt/base_update.xml @@ -1,5 +1,5 @@ - + @@ -26,4 +26,4 @@ - + From 055921341c897b1e909a05ccc7e5e10c19fdf01f Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 4 Nov 2008 17:22:16 +0100 Subject: [PATCH 006/159] merge bzr revid: vmt@openerp.com-20081104162216-vrbjrkewfuejwj3r --- addons/base_crypt/__init__.py | 33 +++++++++++++-------------------- addons/base_crypt/__terp__.py | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/addons/base_crypt/__init__.py b/addons/base_crypt/__init__.py index 88854384b0e..db124dc453f 100644 --- a/addons/base_crypt/__init__.py +++ b/addons/base_crypt/__init__.py @@ -1,28 +1,21 @@ ############################################################################## # -# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved. -# Fabien Pinckaers +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved +# $Id$ # -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 Free Software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# 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 General Public License for more details. # -# 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . # ############################################################################## diff --git a/addons/base_crypt/__terp__.py b/addons/base_crypt/__terp__.py index 8c93f4e9e01..8779f7381ee 100644 --- a/addons/base_crypt/__terp__.py +++ b/addons/base_crypt/__terp__.py @@ -1,3 +1,24 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## { "name" : "Base", "version" : "1.0", From 062c792152b62c4f7190bea58f221df500d49615 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Thu, 19 Feb 2009 19:51:09 +0100 Subject: [PATCH 007/159] merge bzr revid: vmt@openerp.com-20090219185109-qlyshbp6av7njujp --- addons/base_crypt/__terp__.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/addons/base_crypt/__terp__.py b/addons/base_crypt/__terp__.py index 8779f7381ee..6a3164f9aec 100644 --- a/addons/base_crypt/__terp__.py +++ b/addons/base_crypt/__terp__.py @@ -20,18 +20,18 @@ # ############################################################################## { - "name" : "Base", - "version" : "1.0", - "author" : "FS3 , Review Tiny", - "website" : "http://tinyerp.com", - "category" : "Generic Modules/Base", - "description": "Module for password encryption.", - "depends" : ["base"], - "init_xml" : [], - "demo_xml" : [], - "update_xml" : [ - "base_update.xml", - ], - "active": False, - "installable": True, + "name" : "Base", + "version" : "1.0", + "author" : "FS3 , Review Tiny", + "website" : "http://www.openerp.com", + "category" : "Generic Modules/Base", + "description": "Module for password encryption.", + "depends" : ["base"], + "init_xml" : [], + "demo_xml" : [], + "update_xml" : [ + "base_update.xml", + ], + "active": False, + "installable": True, } From ccfe97090b321a39f82a2d6b76f9ad10152d68f4 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Thu, 15 Oct 2009 19:27:18 +0530 Subject: [PATCH 008/159] [MERGE]:merging from the same branch bzr revid: vmt@openerp.com-20091015135718-cr715tqqm9ub6amz --- addons/base_crypt/__init__.py | 19 +++++++++---------- addons/base_crypt/__terp__.py | 19 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/addons/base_crypt/__init__.py b/addons/base_crypt/__init__.py index db124dc453f..a8b9a6b0740 100644 --- a/addons/base_crypt/__init__.py +++ b/addons/base_crypt/__init__.py @@ -1,21 +1,20 @@ ############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved -# $Id$ +# +# 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 General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# 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 General Public License for more details. +# GNU Affero General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . # ############################################################################## diff --git a/addons/base_crypt/__terp__.py b/addons/base_crypt/__terp__.py index 6a3164f9aec..c8454fff0cc 100644 --- a/addons/base_crypt/__terp__.py +++ b/addons/base_crypt/__terp__.py @@ -1,22 +1,21 @@ # -*- encoding: utf-8 -*- ############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved -# $Id$ +# +# 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 General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# 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 General Public License for more details. +# GNU Affero General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . # ############################################################################## { From 7e098c3fa9b88b8a22e945dc5b810a2758322fc4 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Wed, 25 Nov 2009 15:20:36 +0530 Subject: [PATCH 009/159] [MERGE]: merging from the same branch bzr revid: vmt@openerp.com-20091125095036-klz8sos8eey5urnp --- addons/base_crypt/__terp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/base_crypt/__terp__.py b/addons/base_crypt/__terp__.py index c8454fff0cc..400a277ca81 100644 --- a/addons/base_crypt/__terp__.py +++ b/addons/base_crypt/__terp__.py @@ -19,7 +19,7 @@ # ############################################################################## { - "name" : "Base", + "name" : "Base - Password Encryption", "version" : "1.0", "author" : "FS3 , Review Tiny", "website" : "http://www.openerp.com", From 0232413678ff45f8b3beee4e026204898920fae2 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Wed, 25 Nov 2009 19:44:35 +0530 Subject: [PATCH 010/159] [MERGE]: merging from same branch bzr revid: vmt@openerp.com-20091125141435-vsxil5iy8pa69jgj --- addons/base_crypt/crypt.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/base_crypt/crypt.py b/addons/base_crypt/crypt.py index c3d7a71e5ef..2d29704aeb0 100644 --- a/addons/base_crypt/crypt.py +++ b/addons/base_crypt/crypt.py @@ -41,6 +41,7 @@ from string import letters, digits from osv import fields,osv import pooler import tools +from tools.translate import _ from service import security magic_md5 = '$1$' @@ -218,6 +219,8 @@ class users(osv.osv): # Add handlers for 'input_pw' field. def set_pw( self, cr, uid, id, name, value, args, context ): + if not value: + raise osv.except_osv(_('Error'), _("Please specify the password !")) self.write( cr, uid, id, { 'password' : encrypt_md5( value, gen_salt() ) } ) del value From 0a3c2bf26d4f899aa1f18519e9f426f3f91d173c Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Tue, 1 Dec 2009 15:49:51 +0530 Subject: [PATCH 011/159] [MERGE]: merging from same branch bzr revid: vmt@openerp.com-20091201101951-0gqnmboirjoelwly --- addons/base_crypt/i18n/fr_BE.po | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 addons/base_crypt/i18n/fr_BE.po diff --git a/addons/base_crypt/i18n/fr_BE.po b/addons/base_crypt/i18n/fr_BE.po new file mode 100644 index 00000000000..d62691cb699 --- /dev/null +++ b/addons/base_crypt/i18n/fr_BE.po @@ -0,0 +1,37 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * base_crypt +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 5.0.6\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2009-11-26 09:12:09+0000\n" +"PO-Revision-Date: 2009-11-26 09:12:09+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: base_crypt +#: model:ir.module.module,description:base_crypt.module_meta_information +msgid "Module for password encryption." +msgstr "" + +#. module: base_crypt +#: constraint:ir.ui.view:0 +msgid "Invalid XML for View Architecture!" +msgstr "" + +#. module: base_crypt +#: model:ir.module.module,shortdesc:base_crypt.module_meta_information +msgid "Base" +msgstr "" + +#. module: base_crypt +#: field:res.users,input_pw:0 +msgid "Password" +msgstr "" + From da1395bb41bdeeedee3cb26f06693d3beeb5fbc0 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Sun, 3 Jan 2010 00:41:50 +0530 Subject: [PATCH 012/159] [MERGE]: merging from same branch bzr revid: vmt@openerp.com-20100102191150-mnajl1zi8lxt776h --- addons/base_crypt/i18n/base_crypt.pot | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 addons/base_crypt/i18n/base_crypt.pot diff --git a/addons/base_crypt/i18n/base_crypt.pot b/addons/base_crypt/i18n/base_crypt.pot new file mode 100644 index 00000000000..d62691cb699 --- /dev/null +++ b/addons/base_crypt/i18n/base_crypt.pot @@ -0,0 +1,37 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * base_crypt +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 5.0.6\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2009-11-26 09:12:09+0000\n" +"PO-Revision-Date: 2009-11-26 09:12:09+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: base_crypt +#: model:ir.module.module,description:base_crypt.module_meta_information +msgid "Module for password encryption." +msgstr "" + +#. module: base_crypt +#: constraint:ir.ui.view:0 +msgid "Invalid XML for View Architecture!" +msgstr "" + +#. module: base_crypt +#: model:ir.module.module,shortdesc:base_crypt.module_meta_information +msgid "Base" +msgstr "" + +#. module: base_crypt +#: field:res.users,input_pw:0 +msgid "Password" +msgstr "" + From 6f5ead9b97fc2f82a43f6bf0ad3e75d4865c24ad Mon Sep 17 00:00:00 2001 From: "sma (Tiny)" Date: Wed, 3 Mar 2010 17:52:02 +0530 Subject: [PATCH 013/159] [FIX] base_crypt: make password field hidden by setting password=True. lp bug: https://launchpad.net/bugs/530743 fixed bzr revid: sma@tinyerp.com-20100303122202-v512lrl8mep2uf0b --- addons/base_crypt/base_update.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/base_crypt/base_update.xml b/addons/base_crypt/base_update.xml index 8a0a5443eb8..66e4eaeb8c7 100644 --- a/addons/base_crypt/base_update.xml +++ b/addons/base_crypt/base_update.xml @@ -10,7 +10,7 @@ - + @@ -21,7 +21,7 @@ - + From d66295f7b3d6b734040e0550db16224762df6fdc Mon Sep 17 00:00:00 2001 From: Christophe Chauvet Date: Wed, 24 Mar 2010 02:17:46 +0100 Subject: [PATCH 014/159] [IMP] Don't hide main company field with a group on customize form bzr revid: christophe.chauvet@syleam.fr-20100324011746-gdjx7hm6jf293fwc --- bin/addons/base/res/res_company_view.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/addons/base/res/res_company_view.xml b/bin/addons/base/res/res_company_view.xml index 34e58b75b6c..40855eae86b 100644 --- a/bin/addons/base/res/res_company_view.xml +++ b/bin/addons/base/res/res_company_view.xml @@ -9,7 +9,7 @@ - + @@ -29,7 +29,7 @@ - + From 756ab060bb31d471da52ece6bbc6d21fd108d2ed Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Tue, 6 Jul 2010 10:40:58 +0530 Subject: [PATCH 015/159] [IMP]:Remove print statement bzr revid: vmt@openerp.com-20100706051058-q29kpyy7s80i0e9h --- addons/base_crypt/__init__.py | 0 addons/base_crypt/__terp__.py | 0 addons/base_crypt/base_update.xml | 0 addons/base_crypt/crypt.py | 0 addons/base_crypt/i18n/base_crypt.pot | 0 addons/base_crypt/i18n/fr_BE.po | 0 6 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 addons/base_crypt/__init__.py mode change 100644 => 100755 addons/base_crypt/__terp__.py mode change 100644 => 100755 addons/base_crypt/base_update.xml mode change 100644 => 100755 addons/base_crypt/crypt.py mode change 100644 => 100755 addons/base_crypt/i18n/base_crypt.pot mode change 100644 => 100755 addons/base_crypt/i18n/fr_BE.po diff --git a/addons/base_crypt/__init__.py b/addons/base_crypt/__init__.py old mode 100644 new mode 100755 diff --git a/addons/base_crypt/__terp__.py b/addons/base_crypt/__terp__.py old mode 100644 new mode 100755 diff --git a/addons/base_crypt/base_update.xml b/addons/base_crypt/base_update.xml old mode 100644 new mode 100755 diff --git a/addons/base_crypt/crypt.py b/addons/base_crypt/crypt.py old mode 100644 new mode 100755 diff --git a/addons/base_crypt/i18n/base_crypt.pot b/addons/base_crypt/i18n/base_crypt.pot old mode 100644 new mode 100755 diff --git a/addons/base_crypt/i18n/fr_BE.po b/addons/base_crypt/i18n/fr_BE.po old mode 100644 new mode 100755 From 4a587039027d163aed2aa93a404a5ceb86c95861 Mon Sep 17 00:00:00 2001 From: "g.shipilov" Date: Thu, 5 Aug 2010 08:32:28 +0600 Subject: [PATCH 016/159] Page rotation bzr revid: g.shipilov@it1-20100805023228-pbd2b3tkudu7uj1j --- bin/report/render/rml2pdf/trml2pdf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/report/render/rml2pdf/trml2pdf.py b/bin/report/render/rml2pdf/trml2pdf.py index 771a59fa28f..1e628370a44 100644 --- a/bin/report/render/rml2pdf/trml2pdf.py +++ b/bin/report/render/rml2pdf/trml2pdf.py @@ -773,7 +773,7 @@ class _rml_template(object): ps = map(lambda x:x.strip(), node.get('pageSize').replace(')', '').replace('(', '').split(',')) pageSize = ( utils.unit_get(ps[0]),utils.unit_get(ps[1]) ) - self.doc_tmpl = TinyDocTemplate(out, pagesize=pageSize, **utils.attr_get(node, ['leftMargin','rightMargin','topMargin','bottomMargin'], {'allowSplitting':'int','showBoundary':'bool','title':'str','author':'str'})) + self.doc_tmpl = TinyDocTemplate(out, pagesize=pageSize, **utils.attr_get(node, ['leftMargin','rightMargin','topMargin','bottomMargin'], {'allowSplitting':'int','showBoundary':'bool','rotation':'int','title':'str','author':'str'})) self.page_templates = [] self.styles = doc.styles self.doc = doc From 1e1830cd00a62908128a9d09005d86c0cffd54ec Mon Sep 17 00:00:00 2001 From: Julien Thewys Date: Fri, 8 Oct 2010 16:15:53 +0200 Subject: [PATCH 017/159] [FIX] generate_order_by now supports 'id' order_field. Sorting on 'id desc' is used in email_template/email_template.py . bzr revid: jth@openerp.com-20101008141553-tzf94l6lq2qeer96 --- bin/osv/orm.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index c4195dc00fa..817ca1469b6 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -4001,7 +4001,9 @@ class orm(orm_template): order_split = order_part.strip().split(' ') order_field = order_split[0].strip() order_direction = order_split[1].strip() if len(order_split) == 2 else '' - if order_field in self._columns: + if order_field == 'id': + order_by_clause = '"%s"."%s"' % (self._table, order_field) + elif order_field in self._columns: order_column = self._columns[order_field] if order_column._classic_read: order_by_clause = '"%s"."%s"' % (self._table, order_field) From 2272c189d9279eb368a030def29e0e7a42a91ce0 Mon Sep 17 00:00:00 2001 From: Julien Thewys Date: Wed, 20 Oct 2010 16:42:48 +0200 Subject: [PATCH 018/159] [IMP] Added cli args to load one or more languages translation terms automatically. Mainly used to automate languages installation at DB initialization. bzr revid: jth@openerp.com-20101020144248-q20vnt72ovx3md96 --- bin/addons/base/module/module.py | 16 +++++++++------- bin/openerp-server.py | 10 +++++++++- bin/tools/config.py | 4 ++++ bin/tools/translate.py | 13 +++++++++++++ 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/bin/addons/base/module/module.py b/bin/addons/base/module/module.py index b2c2da96d13..3aa42af3954 100644 --- a/bin/addons/base/module/module.py +++ b/bin/addons/base/module/module.py @@ -436,7 +436,7 @@ class module(osv.osv): self.write(cr, uid, [id], {'category_id': p_id}) def update_translations(self, cr, uid, ids, filter_lang=None, context={}): - logger = netsvc.Logger() + logger = logging.getLogger('i18n') if not filter_lang: pool = pooler.get_pool(cr.dbname) lang_obj = pool.get('res.lang') @@ -456,13 +456,15 @@ class module(osv.osv): if len(lang) > 5: raise osv.except_osv(_('Error'), _('You Can Not Load Translation For language Due To Invalid Language/Country Code')) iso_lang = tools.get_iso_codes(lang) - f = os.path.join(modpath, 'i18n', iso_lang + '.po') - if not os.path.exists(f) and iso_lang.find('_') != -1: - f = os.path.join(modpath, 'i18n', iso_lang.split('_')[0] + '.po') + fn = os.path.join(modpath, 'i18n', iso_lang + '.po') + if not os.path.exists(fn) and iso_lang.find('_') != -1: iso_lang = iso_lang.split('_')[0] - if os.path.exists(f): - logger.notifyChannel("i18n", netsvc.LOG_INFO, 'module %s: loading translation file for language %s' % (mod.name, iso_lang)) - tools.trans_load(cr.dbname, f, lang, verbose=False, context=context) + fn = os.path.join(modpath, 'i18n', iso_lang + '.po') + if os.path.exists(fn): + logger.info('module %s: loading translation file for language %s' % (mod.name, iso_lang)) + tools.trans_load(cr.dbname, fn, lang, verbose=False, context=context) + else: + logger.warn('module %s: translation file not found %s' % (mod.name, fn)) def check(self, cr, uid, ids, context=None): logger = logging.getLogger('init') diff --git a/bin/openerp-server.py b/bin/openerp-server.py index 8d210fc2906..18a2238daea 100755 --- a/bin/openerp-server.py +++ b/bin/openerp-server.py @@ -119,13 +119,21 @@ if not ( tools.config["stop_after_init"] or \ if tools.config['db_name']: for dbname in tools.config['db_name'].split(','): db,pool = pooler.get_db_and_pool(dbname, update_module=tools.config['init'] or tools.config['update'], pooljobs=False) + cr = db.cursor() + if tools.config["test_file"]: logger.info('loading test file %s', tools.config["test_file"]) - cr = db.cursor() tools.convert_yaml_import(cr, 'base', file(tools.config["test_file"]), {}, 'test', True) cr.rollback() + + if tools.config['load_language']: + for lang in tools.config['load_language'].split(','): + tools.load_language(cr, lang) + pool.get('ir.cron')._poolJobs(db.dbname) + cr.close() + #---------------------------------------------------------- # translation stuff #---------------------------------------------------------- diff --git a/bin/tools/config.py b/bin/tools/config.py index 2964870d427..c0600d0a881 100644 --- a/bin/tools/config.py +++ b/bin/tools/config.py @@ -58,6 +58,7 @@ class configmanager(object): 'xmlrpcs': True, 'translate_in': None, 'translate_out': None, + 'load_language': None, 'language': None, 'pg_path': None, 'admin_passwd': 'admin', @@ -206,6 +207,8 @@ class configmanager(object): "Option '-l' is mandatory in case of importation" ) + group.add_option('--load-language', dest="load_language", + help="specifies the languages for the translations you want to be loaded") group.add_option('-l', "--language", dest="language", help="specify the language of the translation file. Use it with --i18n-export or --i18n-import") group.add_option("--i18n-export", dest="translate_out", @@ -283,6 +286,7 @@ class configmanager(object): keys = [ 'language', 'translate_out', 'translate_in', 'debug_mode', 'smtp_ssl', + 'load_language', 'stop_after_init', 'logrotate', 'without_demo', 'netrpc', 'xmlrpc', 'syslog', 'list_db', 'xmlrpcs', 'test_file', 'test_disable', 'test_commit', 'test_report_directory' diff --git a/bin/tools/translate.py b/bin/tools/translate.py index f978ecbfd4b..ad4d6ba3b14 100644 --- a/bin/tools/translate.py +++ b/bin/tools/translate.py @@ -898,5 +898,18 @@ def resetlocale(): except locale.Error: continue +def load_language(cr, lang): + """Loads a translation terms for a language. + Used mainly to automate language loading at db initialization. + + :param lang: language ISO code with optional _underscore_ and l10n flavor (ex: 'fr', 'fr_BE', but not 'fr-BE') + :type lang: str + """ + pool = pooler.get_pool(cr.dbname) + language_installer = pool.get('base.language.install') + uid = 1 + oid = language_installer.create(cr, uid, {'lang': lang}) + language_installer.lang_install(cr, uid, [oid], context=None) + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 925180946e2afc8744a71afb813c9a9ea851eccf Mon Sep 17 00:00:00 2001 From: "AMP (OpenERP)" Date: Mon, 25 Oct 2010 18:16:01 +0530 Subject: [PATCH 019/159] [MOD/IMP]: Improvement in Usebility Icon bzr revid: amp@tinyerp.com-20101025124601-mspsq4g5h4gwtj5l --- bin/addons/base/res/partner/wizard/partner_sms_send_view.xml | 2 +- bin/addons/base/res/partner/wizard/partner_wizard_spam_view.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/addons/base/res/partner/wizard/partner_sms_send_view.xml b/bin/addons/base/res/partner/wizard/partner_sms_send_view.xml index 97c418d9f81..7d84d6d405a 100644 --- a/bin/addons/base/res/partner/wizard/partner_sms_send_view.xml +++ b/bin/addons/base/res/partner/wizard/partner_sms_send_view.xml @@ -20,7 +20,7 @@