Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

OpenERP Users Customizing error [Closed]

By
priyankahdp
on 4/15/13, 4:05 AM 1,317 views

The Question has been closed

by
Sudhir Arya (SA)
on 04/18/2013 05:12:17
class res_users(osv.osv):

    def create(self, cr, uid, values, context=None):
        res_users_obj = self.pool.get('res.users')
        # res_users_obj.create(cr, uid, values)
        return res_users_obj.create(cr, uid, {        'login': values['login'],
                                                      'password': values['password'],
                                                      'company_id': values['bpl_company_id'],
                                                      'partner_id': values['officer_id'],
                                                      'name': values['login']
                                                      })


    # _inherit = "res.users"
    _name = "bpl.res.users"
    _columns = {
        'bpl_company_id':fields.many2one('bpl.company.n.registration', 'Company'),
        'bpl_estate_id':fields.many2one('bpl.estate.n.registration', 'Estate', help='Estate', domain="[('company_id','=',bpl_company_id)]"),
        'officer_id':fields.many2one('bpl.officer', 'User', domain="[('bpl_company_id','=',bpl_company_id)]"),
        'login': fields.char('Login', size=20),
        'password': fields.char('Password', size=20),
    }


res_users()

above code shows my res_user class in "bpl" model. i'm going to create users in my page and add record in res_users when i create users here.

but issue is now my users are creating in res_users table.but not create in bpl_res_users table.when i press save button it wait on form view.not navigate to tree view.not shows any error in console also.

please advice me friends..

i uploaded my whole code here @ GitHub

2

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 4/15/13, 4:15 AM

It is because in create method you are creating record in res.users.

If create method is not required, remove create method, I am sure it will work as per your expectation.

If you want to create res.users along with bpl.res.users then replace your method by this:

    def create(self, cr, uid, values, context=None):
        res_users_obj = self.pool.get('res.users')
        # res_users_obj.create(cr, uid, values)
        res_users_obj.create(cr, uid, {
            'login': values['login'],
            'password': values['password'],
            'company_id': values['bpl_company_id'],
            'partner_id': values['officer_id'],
            'name': values['login'],
        }, context=context)
    return super(res_users, self).create(cr, uid, values, context=context)

are you sure you want to use super(res_users, self)? I expect to use super(bpl_res_users, self), to use the original create of the module.

patrick
on 4/15/13, 6:35 AM

I know that but his class name is res_users that is why I used it.

Sudhir Arya (SA)
on 4/15/13, 6:40 AM

In that case, you create an entry in res_users, becasue of the code and the calling of the res_users_obj.create, and an entry in bpl_res_users will be made because of the call to super?

patrick
on 4/15/13, 7:23 AM

thanks sooooooo much arya.now its worked.u saved my day :-)

when login to openerp how to change it's call table res_users to our own one .?

priyankahdp
on 4/15/13, 7:23 AM

Why you are creating new class while we have res.users?

Sudhir Arya (SA)
on 4/15/13, 7:31 AM

because we create our own module.as per my manager request :-) thatswhy i'm going to do this type module

priyankahdp
on 4/15/13, 12:06 PM
1

Priyesh Solanki (pso)

--Priyesh Solanki (pso)--
Tiny ERP Pvt Ltd
http://www.odoo.com
1100
| 2 2 4
--Priyesh Solanki (pso)--
Priyesh Solanki (pso)
On 4/15/13, 6:44 AM

Try with this:

class bpl_res_users(osv.osv):

_name = "bpl.res.users"
_columns = {
    'bpl_company_id':fields.many2one('bpl.company.n.registration', 'Company'),
    'bpl_estate_id':fields.many2one('bpl.estate.n.registration', 'Estate', help='Estate', domain="[('company_id','=',bpl_company_id)]"),
    'officer_id':fields.many2one('bpl.officer', 'User', domain="[('bpl_company_id','=',bpl_company_id)]"),
    'login': fields.char('Login', size=20),
    'password': fields.char('Password', size=20),
}

bpl_res_users()

Add related Views, Action and menu from xml for bpl.res.users object. Update your module and check it.

thanks Priyesh.. :-) issue with my Super() method. now its sorted

priyankahdp
on 4/15/13, 7:27 AM

I think class name does not make any sense for this issue.

Sudhir Arya (SA)
on 4/15/13, 7:37 AM

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/15/13, 4:05 AM
Seen: 1317 times
Last updated: 3/16/15, 8:10 AM