More fields from related model in view in odoo v14 - odoo-14

Is there a way to send more fields than just display name and id from related model in odoov14?
already tried overriding read function and add more fields to RPC call from JS.

Related

odoo 15 default_partner_id is not correctly used from context

we are migrating our odoo v13 App to odoo v15.
We have a model that is using delegation inheritance to extend a res.partner (_inherits = {"res.partner": "partner_id"}). In res.partner we have an action (act_window) to create a new instance of our model based on the actual res.partner. We are redirecting to a form of our model with context "'default_partner_id': active_id". In the redirected form the fields of the contact (name, email) are prefilled correctly with the data of the contact but the field "partner_id" is empty. When we save the new instance of our model odoo creates also a new res.partner with the same data as the source res.partner.
I don't know what we are doing wrong so I've created a simple view and action with res.users so that anybody can reproduce the issue.
I've created an issue on github so that anybody can reproduce it:
https://github.com/odoo/odoo/issues/81508
I've also created a ticket over the odoo support but the answer was:
"... customisation even via a view and XML code is still customisation; this is not covered by traditional Odoo support. (see: https://www.odoo.com/documentation/15.0/services/support/what_can_i_expect.html)"
Does anybody can help us? I don't know if whe are doing something wrong or if odoo isn't working correctly. I think it is odoo but I can't create a szenario without customizings.

Sitefinity add fields through backend code

enter image description here
I have a project where I need to add the customized field use code dynamically , now siteifinity provides user to add in the backend pages as the picture shows. Is any there way to add through code? Now I can add more field column into the table use fluent API, but the newly added field is not shown in the backend page. how to make the newly added field to show in the backend module ?

some documentation about _onchange_spec() methose in odoo

in chapter 6 of the book Odoo Development Cookbook the author introduces the _onchange_spec () methode and he presented it as a follow :
This method will retrieve the updates that are triggered by the odification of which other field. It does this by examining the form view of the model (remember, onchange methods are normally called by the web client).
i need more details
Welcome to the stackoverflow community.
The main objective of the _onchange_spec () method is to call the onchange method from the server side.
In the example of the book you mention, it is explained that:
you can do the required computation yourself, but this is not always
possible as the onchange method can be added or modified by a
third-party addon module installed on the instance that you don 't
know about.
When called:
Passing no argument. This method will retrieve the updates that are triggered by the modification of which other field. It does this by examining the form view of the model.
How to Use it:
You must use it when you want to manually run an onchange method and compute something before creating the registry or updating it.
Example
#api.multi
def return_all_books(self):
self.ensure_one
wizard = self.env['library.returns.wizard']
#this is the manual change (update the member)
values = {'member_id': self.id}
#this examines the form to find the changes
specs = wizard._onchange_spec()
#This gets the values of the onchange
updates = wizard.onchange(values, ['member_id'], specs)
#Combine the results with the new manually added value
values.update(updates.get('value', {}))
record = wizard.create(values)
For another implementation you can check below.
you can see a implementation for testing here

How to update fields before the view is displayed in Odoo

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 that's 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 appreciated.
Regards.

How to reference to a Sitefinity Form in a Custom Field

I am working on a custom sitefinity module in which I need to add a custom field where I can select a Sitefinity Form from a list of existing defined forms on the backend. What is the best approach to do this? Precisely how should I approach in defining the field and making its UI?
Unfortunately when I select "Related Data" as field type, Sitefinity Form is not available in the list of built-in data types. The other option (advanced option) I see is a GUID (or array of GUIDs) field type among field types which suggest making a custom code.
CMS version is Sitefinity 8.2 and we are using MVC-based feather components as well as our custom MVC components to develop the website.
Anybody had similar requirement and experience on this?
I would probably create a custom field control. This can be streamlined by using Sitefinity Thunder (because there's a lot of boilerplate C# and JavaScript needed). Once that's in place, you can create a custom field of either type Short Text or GUID, and for the interface, you use your custom field.
In your custom field's code, you can do something like creating a drop down list, where the text for each option is the form name, and the value is either the "name for developers" field or the ID of the form. That way the input is always constrained to IDs pointing to Sitefinity forms. Then when you interact with your custom content items later, you can use this ID/name to look up the referenced form.
As an aside about Related Data: Indeed, that only refers to either built-in content types (blogs, news, etc.) or custom-build dynamic content types. You won't find things like Forms in there.