Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
271 มุมมอง

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง