Skip to Content
Menu
This question has been flagged
2 Replies
257 Views

I'm designing a custom app in studio with two models, a parent model called x_etsy_shops and a child module called x_etsy_shop_notices, linked through a many2one field on x_etsy_shop_notices, x_studio_etsy_shop.


The aim of this is to create a scheduler that can automatically update the published messages in my etsy shop - so far everything is working, but I have 4 text fields in x_etsy_shop_notices for setting different messages, and I also have matching text fields in x_etsy_shops.


I use the fields in x_esty_shops to store the latest published messages, but now I want to use those values for defaults in x_etsy_shop_notices model. Basically, when I create a new record in x_etsy_shop_notices, I want the defaults to be as follows;

Field in x_etsy_shop_notices

Field from x_etsy_shops

x_studio_announcement

x_studio_current_announcement

x_studio_sales_message

x_studio_current_sales_message

x_studio_digital_sales_message

x_studio_current_digital_sales_message

x_studio_policies

x_stuido_current_policies

Based on my resarch online, I think I'm meant to use Context... I've been able to use the context to set static default text successfully, but I'm not sure how to get the value from the parent record for the default.


I'm using Odoo Studio Online running 18.3

Avatar
Discard
Best Answer

Hello Dan,

With debug mode activated ( https://www.odoo.com/documentation/18.0/applications/general/developer_mode.html#activation ) you can navigate to Settings / Technical / Actions / User-defined Defaults and you can there specify defaults values for your records

Otherwise, you can also go to Settings / Technical / Database Structure / Fields, select your field and define a compute value to take the one you want from the parent model 

Don't forget to set the dependencies on the field so the compute is triggered properly ! More info on compute fields here : https://www.odoo.com/documentation/18.0/developer/tutorials/server_framework_101/08_compute_onchange.html


Hope this helps !

Kind regards,

Avatar
Discard
Author Best Answer

Thanks Nathan, I know about those methods - but I'm not wanting to compute the value as it's uneditable after. What I need to do is set the field default from the parent record (so the debug user defaults doesn't work either), but still have the child fields editable.

Avatar
Discard
Related Posts Replies Views Activity
2
Aug 25
166
1
Jul 25
1175
2
Mar 25
1451
0
Feb 25
1103
0
Feb 25
1265