Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
170 Переглядів

Hello

There is a field in odoo called Team_ID where you select the sales team in a quote.

I will create a new model in order to modify the behavior of this field.

Specifically I want to:

​1. I want the field to be a required field

​2. Odoo suggests the last sales team created. I want to eliminate the suggest part. I want it to appear blank

I know how to code for item 1. My question is: If I make it a required field will odoo show the last team created or will it show the field empty (in red) and prompt me to fill it if I forget

Аватар
Відмінити
Найкраща відповідь

Hello,



Here's how to ensure the Sales Team field is required and blank by default on Quotations:



  Making a field required in Odoo generally doesn't prevent Odoo from pre-filling it with a default value if one is configured.

  To achieve your goal, first, ensure that there is no default value set for the team_id field in the Sales Team model itself (via the Studio or custom code).

  Next, in your custom module, when defining the team_id field on the Quotation model, set required=True and ensure there's no default=... argument that would pre-populate the field.

  If a default value is not set, Odoo will display the field in red, prompting the user to fill it in before saving.


For personalized assistance:
https://www.pragtech.co.in/contact-us-mql.html

Аватар
Відмінити
Найкраща відповідь

Hi,


In Odoo, making the team_id field required does not automatically prefill it with the last sales team; the field is only automatically suggested if a default value exists. To ensure the field appears empty when creating a new quote, you should set default=False when defining the field. With this setup, the field will be blank initially, highlighted in red if left empty, and the user will be prompted to select a sales team before saving the record.


To prevent Odoo from suggesting the last team, you need to remove or override the default. For example:


from odoo import models, fields


class SaleOrder(models.Model):

    _inherit = 'sale.order'


    team_id = fields.Many2one(

        'crm.team',

        string='Sales Team',

        required=True,

        default=False,  # ensures no suggestion

    )


With this, the field will be empty when opening a new quote, and the user must select a team before saving.


Hope it helps

Аватар
Відмінити