Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
306 Widoki

Hello,

I have a question regarding custom fields in Odoo:

  1. I initially created some custom fields using Odoo Studio, and these fields already contain data.
  2. A developer advised me that it’s better to create a custom module for new fields, so that the environment is consistent across all my Odoo instances.
  3. I don’t want to delete the Studio-created fields since they already hold values. Instead, I have recreated the same fields in a custom module.



Is there a risk of conflict when deploying the custom module, given that the fields already exist in the database from Studio? 


Additionally, when deploying the fields through the module, I am seeing this warning:

WARNING server Field sale.order.line.x_custom_field: unknown parameter 'tracking', if this is an actual parameter you may want to override the method _valid_field_parameter on the relevant model in order to allow it

  • What does this warning mean, and how should I resolve it when moving fields from Studio to a custom module?


Any guidance or best practices for safely migrating Studio fields to a custom module would be greatly appreciated!


Thank you

Awatar
Odrzuć
Autor

Thanks for your confirmation !


Najlepsza odpowiedź

Hi,


Moving a Studio Char field (x_custom_field) from Studio → custom module


Python Code:

from odoo import models, fields


class SaleOrderLine(models.Model):

    _inherit = "sale.order.line"


    # This redeclares the Studio field

    x_custom_field = fields.Char(

        string="Custom Field",

        tracking=True

    )



If your model doesn’t use chatter (no mail.thread):


Remove tracking=True to avoid the warning:


Python Code:

from odoo import models, fields


class SaleOrderLine(models.Model):

    _inherit = "sale.order.line"


    x_custom_field = fields.Char(string="Custom Field")


As long as the field name (x_custom_field) and type (Char, Many2one, etc.) match what Studio made, Odoo will reuse the same DB column and your data is safe.


Hope it helps.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
paź 23
4362
0
cze 22
23
4
cze 25
4056
3
wrz 24
1673
0
lis 23
1671