Odoo Help

1

Odoo v8: can't write into website field (model: res.partner)

By
Sergej
on 4/1/15, 9:33 AM 1,187 views

I've created my own field company_origin. It is only visible if the partner (res.partner modell) is a company.

The field company_origin is a Many2one field, related to a modell origin which i added to res_partner.

My Problem is that i can't write values into the children of the company. For some fields it works (e.g. street) but for some it doesn't. (e.g. website). I also can not write the fields that i added to res.partner with my own model.

Here is some code that shows my problem, street changes but website doesnt (both are fields.Char() fields).


    @api.onchange('company_origin')
    def _set_children_origin(self):
        if self.child_ids != False:
            #--------------------------#
            for child in self.child_ids:
                child.street = "teststreet"
                child.website = "testsite"


Thanks, for any advice.

Both fields are in the view xml?

Zbik
on 4/1/15, 2:31 PM

Yes i can see both fields and they are defined in res.partner (view). I use _inherit=res.partner in my modell to add new elements. But those two fields both are untouched. I really would like to know why i can not write into child.website. Thanks for your reply.

Sergej
on 4/1/15, 3:07 PM
1
Cyril Gaspard (GEM)
On 4/1/15, 6:30 PM

see documentation (not tested) :


http://odoo-new-api-guide-line.readthedocs.org/en/latest/environment.html

Many2many One2many Behavior

One2many and Many2many fields have some special behavior to be taken in account. At that time (this may change at release) using create on a multiple relation fields will not introspect to look for the relation.


self.line_ids.create({'name': 'Tho'}) # this will fail as order is not set

self.line_ids.create({'name': 'Tho', 'order_id': self.id}) # this will work

self.line_ids.write({'name': 'Tho'}) # this will write all related lines

0
Zbik
On 4/1/15, 3:37 PM

I previously poorly understood your construction. Now my answer:

  • @api.onchange scope is limited to the same screen / model

you define relation fields in your model, if it is necessary.


PS> line

if self.child_ids != False: 

is redundant



0
Sergej
On 4/1/15, 3:03 PM

It is possibke to write, if I use self.env['res.partner'].browse(child.id).write({'website': "test"}) .

If someone knows why it doesnt work with child.website = ..., pls help out. Would be interesting to know how those operations are different and how they really work.

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

Question tools

2 follower(s)

Stats

Asked: 4/1/15, 9:33 AM
Seen: 1187 times
Last updated: 4/2/15, 6:05 PM