Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
292 Ansichten

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

Avatar
Verwerfen
Autor

Thanks for your confirmation !


Beste Antwort

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.

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Okt. 23
4356
0
Juni 22
23
4
Juni 25
4051
3
Sept. 24
1670
0
Nov. 23
1651