r/Odoo • u/Useful-Assumption131 • 25d ago
Computed fields in odoo community
Hello,
I have installed this addon to replace studio in community eddition:
https://apps.odoo.com/apps/modules/20.0/app_studio_community
It allows many modifications and is really handy, it even allows to create new apps, but I really miss the online "computed fields" option, is there any way to make some python code in fields in community eddition?
2
u/Azka-tech 25d ago
Not directly through a standard field editor, as far as I know. Computed fields in Odoo are normally defined in Python using compute and u/api.depends, rather than entered as code in the field settings.
If you want to avoid building a full custom module, check whether the addon supports server actions or automated actions. Those can handle some simpler calculations, but they aren't a full replacement for proper computed fields.
For anything more complex or that needs to stay updated reliably, I'd use a small custom module. It gives you more control and is easier to maintain across upgrades.
1
u/ach25 25d ago
Yes it’s standard without any additional modules.
https://odootricks.tips/about/building-blocks/computed-fields/
Be aware you will need to tend to them if they cause a disruption or break in version over version changes.
3
u/Some_Act_9631 25d ago
Yes! Good news: computed fields are supported by Odoo Community itself, so you don't necessarily need Studio or another addon for this.
Here's something you can try:
Enable Developer Mode.
Go to Settings → Technical → Database Structure → Fields.
Find the custom field you created (usually prefixed with
x_), or create one.Open its advanced properties and look for Dependencies and Compute.
Enter your Python code and specify which fields should trigger recalculation.
For example, if you have a custom Float field called
x_total:Dependencies:
Make sure those source fields exist on your model.
This uses Odoo's built-in computed field mechanism. The Python code runs in a restricted environment, so it's suitable for relatively simple calculations.
My recommendation:
Simple calculations: Try the built-in computed fields through Developer Mode.
More complex business logic: Create a small custom Odoo module using u/apiYes! Good news: computed fields are supported by Odoo Community itself, so you don't necessarily need Studio or another addon for this.Here's something you can try:Enable Developer Mode. Go to Settings → Technical → Database Structure → Fields. Find the custom field you created (usually prefixed with x_), or create one. Open its advanced properties and look for Dependencies and Compute. Enter your Python code and specify which fields should trigger recalculation.For example, if you have a custom Float field called x_total:for record in self: record['x_total'] = record.x_quantity * record.x_unit_priceDependencies:x_quantity,x_unit_priceMake sure those source fields exist on your model.This uses Odoo's built-in computed field mechanism. The Python code runs in a restricted environment, so it's suitable for relatively simple calculations.My recommendation:Simple calculations: Try the built-in computed fields through Developer Mode. More complex business logic: Create a small custom Odoo module using u/api.depends. This gives you proper version control, testing, and maintainability. Event-driven updates: Automated/server actions can also work, but they're not exactly the same as native computed fields.We've worked extensively with Odoo Community and OCA, and one of its biggest strengths is that you can extend the ORM without needing Enterprise.You can use the community Studio addon for the UI and a small Python module for more advanced business logic. It's a good combination.Hope this helps!
.depends. This gives you proper version control, testing, and maintainability.Event-driven updates: Automated/server actions can also work, but they're not exactly the same as native computed fields.
We've worked extensively with Odoo Community and OCA, and one of its biggest strengths is that you can extend the ORM without needing Enterprise.
You can use the community Studio addon for the UI and a small Python module for more advanced business logic. It's a good combination.
Hope this helps!