This question has been flagged
2803 Views

I could not figure how i'm supposed to do the following scenario;

I've two fields in my inherited res.partner view "ExternalID" and "ExternalCode" all the fields are going to be editable until those two are filled. And after these two are filled everything is going to be read-only thats the easy part we can handle this by attrs. The problem is when these two fields are filled (they're being filled from an external app by odoo web api.) i need call an external web api before the form is loaded i^ve to update the read-only fields. I've tried placing a computed field and make it invisible so that it gets fired up when the view is being loaded and i thought i should update the other fields but it seems when i write a compute function it can only update the field that it is called from.

For Example;

    external_api_call_field = fields.Char(compute='_get_values_from_api')

    @api.multi
    def _get_values_from_api(self):
      for record in self:

        #call api and do stuff

        #set the values that we got from the external application
        record.company_detailed_address="Sample address line"

the method gets triggered and seems to run all the way but when the form is loaded the address field is not filled.

I tried to call

self.write({'company_detailed_address' : 'Sample address line'})

which seems to work but the new value is not set directly you've to refresh the view

Any help or guidance is appriciated.

Regards.

Avatar
Discard

Hi, did you manage to solve this issue?