diff options
| author | YSA (OpenERP) <ysa@openerp.com> | 2010-12-29 21:12:50 +0100 |
|---|---|---|
| committer | Olivier Dony <odo@openerp.com> | 2010-12-29 21:12:50 +0100 |
| commit | cbe201785fd3a7b93acea9797b09abc39ba7c69c (patch) | |
| tree | 61ecfe49b8b4b98fec54ed5e94e416b2ac51437a /bin | |
| parent | e2f6d60065963ce74a8df99a3915f2c7702574a2 (diff) | |
| parent | 6112db95ddc52bc09b197c9df8b2a9181d57fc5f (diff) | |
[MERGE] base, report: several bugfixes (see bug links)
bzr revid: odo@openerp.com-20101229201250-q7le63xa3rbsce6o
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/addons/base/base_demo.xml | 17 | ||||
| -rw-r--r-- | bin/addons/base/base_update.xml | 34 | ||||
| -rw-r--r-- | bin/addons/base/res/res_config.xml | 2 | ||||
| -rw-r--r-- | bin/addons/base/res/res_user.py | 38 | ||||
| -rw-r--r-- | bin/addons/base/test/test_context.xml | 6 | ||||
| -rw-r--r-- | bin/report/render/rml2pdf/utils.py | 2 |
6 files changed, 87 insertions, 12 deletions
diff --git a/bin/addons/base/base_demo.xml b/bin/addons/base/base_demo.xml index 7779171fe08..73f6fa400a5 100644 --- a/bin/addons/base/base_demo.xml +++ b/bin/addons/base/base_demo.xml @@ -1,14 +1,27 @@ <?xml version="1.0" encoding="utf-8"?> <openerp> <data noupdate="1"> + + <record id="demo_address" model="res.partner.address"> + <field name="name">Fabien Dupont</field> + <field name="street">Chaussee de Namur</field> + <field name="zip">1367</field> + <field name="city">Gerompont</field> + <field name="phone">(+32).81.81.37.00</field> + <field name="type">default</field> + <field model="res.country" name="country_id" ref="be"/> + <!-- Company ID will be set later --> + <field name="company_id" eval="None"/> + </record> + <record id="user_demo" model="res.users"> <field name="login">demo</field> <field name="password">demo</field> <field name="name">Demo User</field> <field name="signature">Mr Demo</field> - <field name="address_id" ref="main_address"/> + <field name="address_id" ref="demo_address"/> <field name="company_id" ref="main_company"/> - <field name="groups_id" eval="[(6,0,[ref('base.group_user')])]"/> + <field name="groups_id" eval="[(6,0,[ref('base.group_user')])]"/> </record> </data> </openerp> diff --git a/bin/addons/base/base_update.xml b/bin/addons/base/base_update.xml index 2448306ad79..411d67ec6f7 100644 --- a/bin/addons/base/base_update.xml +++ b/bin/addons/base/base_update.xml @@ -69,6 +69,35 @@ Users ====================== --> + + <record id="view_change_user_password_form" model="ir.ui.view"> + <field name="name">change.user.password</field> + <field name="model">change.user.password</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Change Password"> + <field name="current_password" password="True" readonly="0" colspan="4"/> + <field name="new_password" password="True" readonly="0" colspan="4"/> + <field name="confirm_password" password="True" readonly="0" colspan="4"/> + <label colspan="1" string=""/> + <label colspan="3" string="You must logout and login again after changing your password."/> + <separator colspan="4" /> + <label align="0.0" colspan="2" string=""/> + <button colspan="1" icon="gtk-cancel" special="cancel" string="Cancel"/> + <button colspan="1" icon="gtk-ok" name="change_password" string="Change" type="object"/> + </form> + </field> + </record> + + <record id="action_view_change_password_form" model="ir.actions.act_window"> + <field name="name">Change Password</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">change.user.password</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + <record id="view_users_form_simple_modif" model="ir.ui.view"> <field name="name">res.users.form.modif</field> <field name="model">res.users</field> @@ -87,12 +116,11 @@ <newline/> </page> <page string="Preferences"> - <field name="password" password="True" readonly="0" /> <field name="context_lang" completion="1" readonly="0"/> - <label string="" colspan="1"/> - <label colspan="3" string="You must logout and login again after changing your password."/> <field name="context_tz" completion="1" readonly="0"/> <field name="menu_tips" colspan="2" readonly="0"/> + <label string="" colspan="1"/> + <button name="%(action_view_change_password_form)d" string="Change Password" type="action" icon="gtk-execute"/> <separator string="Email & Signature" colspan="4"/> <group colspan="4"><field name="user_email" widget="email" readonly="0"/></group> <field colspan="4" name="signature" readonly="0" nolabel="1"/> diff --git a/bin/addons/base/res/res_config.xml b/bin/addons/base/res/res_config.xml index 24728d0cf45..56432f51f7b 100644 --- a/bin/addons/base/res/res_config.xml +++ b/bin/addons/base/res/res_config.xml @@ -7,7 +7,7 @@ <field name="arch" type="xml"> <form> <group colspan="4" col="8"> - <group colspan="1" width="220" height="250"> + <group colspan="1" width="220"> <field name="config_logo" widget="image" width="220" height="130" nolabel="1"/> <newline/> <label align="0.0" string="description" width="200" colspan="2"/> diff --git a/bin/addons/base/res/res_user.py b/bin/addons/base/res/res_user.py index e7f881c1c9d..c8aa83f3253 100644 --- a/bin/addons/base/res/res_user.py +++ b/bin/addons/base/res/res_user.py @@ -448,7 +448,7 @@ class users(osv.osv): return True cr = pooler.get_db(db).cursor() try: - cr.execute('SELECT COUNT(1) FROM res_users WHERE id=%s AND password=%s AND active=%s', + cr.execute('SELECT COUNT(1) FROM res_users WHERE id=%s AND password=%s AND active=%s', (int(uid), passwd, True)) res = cr.fetchone()[0] if not bool(res): @@ -547,7 +547,7 @@ class groups2(osv.osv): ##FIXME: Is there a reason to inherit this object ? if len(user_names) >= 5: user_names = user_names[:5] user_names += '...' - raise osv.except_osv(_('Warning !'), + raise osv.except_osv(_('Warning !'), _('Group(s) cannot be deleted, because some user(s) still belong to them: %s !') % \ ', '.join(user_names)) return super(groups2, self).unlink(cr, uid, ids, context=context) @@ -574,5 +574,39 @@ class res_config_view(osv.osv_memory): res_config_view() +class change_user_password(osv.osv_memory): + _name = 'change.user.password' + _columns = { + 'current_password':fields.char('Current Password', size=64, required=True, help="Enter your current password."), + 'new_password': fields.char('New Password', size=64, required=True, help="Enter the new password."), + 'confirm_password': fields.char('Confirm Password', size=64, required=True, help="Enter the new password again for confirmation."), + } + _defaults={ + 'current_password' : '', + 'new_password' : '', + 'confirm_password' : '', + } + + def change_password(self, cr, uid, ids, context=None): + for form_id in ids: + password_rec = self.browse(cr, uid, form_id, context) + if password_rec.new_password != password_rec.confirm_password: + raise osv.except_osv(_('Error !'), _('The new and confirmation passwords do not match, please double-check them.')) + + # Validate current password without reading it from database, + # as it could be stored differently (LDAP, encrypted/hashed, etc.) + is_correct_password = False + try: + user_obj = self.pool.get('res.users') + is_correct_password = user_obj.check(cr.dbname, uid, password_rec.current_password) + except Exception: + pass + if not is_correct_password: + raise osv.except_osv(_('Error !'), _('The current password does not match, please double-check it.')) + user_obj.write(cr, uid, [uid], {'password': password_rec.new_password}, context=context) + return {} + +change_user_password() + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/bin/addons/base/test/test_context.xml b/bin/addons/base/test/test_context.xml index 44751644403..d308fc3dea8 100644 --- a/bin/addons/base/test/test_context.xml +++ b/bin/addons/base/test/test_context.xml @@ -6,15 +6,15 @@ <!-- model="res.currency"--> <!-- id="INR"--> <!-- string="Indian rupee rate in 2009">--> - <!-- date specified in data element's context --> + <!-- date specified in data element's context --> <!-- <test expr="str(rate)">65.8287</test>--> <!-- </assert> --> - <assert + <assert model="res.currency" id="INR" string="Indian rupee rate in 2002" context="{'date': '2010-06-01'}"> - <test expr="str(rate)">59.9739</test> + <test expr="rate_ids and str(rate_ids[0].rate)">59.9739</test> </assert> </data> </openerp> diff --git a/bin/report/render/rml2pdf/utils.py b/bin/report/render/rml2pdf/utils.py index 6f8616da96d..e631fcd9566 100644 --- a/bin/report/render/rml2pdf/utils.py +++ b/bin/report/render/rml2pdf/utils.py @@ -131,7 +131,7 @@ def _process_text(self, txt): pass if isinstance(txt, basestring): result += str2xml(txt) - elif (txt is not None) and (txt is not False): + elif txt and (txt is not None) and (txt is not False): result += ustr(txt) return result |
