Odoo Help

0

0
3 Answers
1
Avatar

Bole

--Bole--

2537
| 6 4 8
Zagreb | Karlovac, Croatia
--Bole--

there is only 10 kind of people the ones that understand binary ... and others

Bole
7/15/14, 10:03 AM

Well.. you are looking at wrong data.. 

In odoo/openerp resource_resource contains(actualy is hr_employee name i related to this field) 
 the name for employees, not users.. 

there is a table res_users where some user data is stored... (login, password, mail.. etc..) and a relation to res_partner (partner_id) wich contains actual name of user, along with other data (address, phone , mail....)

So eather you rewrite your sql acordingly (using some joins for foreign key ids..) ,

or.. simply user orm methods like.. if you want to search for user wich has login : 'someuser' it would look like:

ids = self.pool.get('res.users').search(cr, uid, [('login'.'=','someuser')])    #expecting a list of ids returned

now that you have list of ids, you can browse those records and read/modify any data stored in fields...

 

but in your case... i think it would be much easier if you do not use fields.selection.. but instead, 

define your:

_columns = {
...
'my_user':fields.many2one('res.users','User'),
...
}
 

this is common usage for many to one field, and it preserves most orm methods in it ( addins and modifying user) 
in case you want to show just a selection on the view... define a view like: (addon after comment:)
<field name="my_user" widget="selection" /> 

If you need only a few fields shown and not the default view for related field, define them in the same view like:

<field name="my_user" widget="selection" > 
    <tree>
        <field name="first_name"/>
        <filed name="last_name"/>
    </tree>
</field>


 

0
Andrew
7/17/14, 3:03 AM

Thank you. I solved this isue in the next way:

_columns = {

...

'user_id': fields.many2many('res.users'),

...

}

 

but in the xml view I inserted this string

 

<field name="user_id" string='Assigned Users' widget="many2many_tags" />

0
Zahin
7/16/14, 12:24 AM

HI. Andrew 

Here right way TODO.

_columns = {

          'user_id': fields.many2one('res.users', 'Salesperson',),

}

_defaults = {
         'user_id': lambda obj, cr, uid, context: uid,

}

I suggest you to read existing code of sale module or account module, and just go through code and understand existing codes and utilize it in your modules.

 

Ask a Question
Writer
Keep Informed
2 follower(s)
About This Community

This platform 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.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now