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

How to generate aut number for opportunity?

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

https://www.odoo.com/nl_NL/forum/help-1/give-numbers-to-leads-181527 


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

You mean like using a sequence to generate numbers also with a prefix:

class crm_lead(models.Model):
    _inherit = 'crm.lead'
    name = fields.Char(default='/')
    
    @api.model
    def create(self, vals):
        if vals.get('name', False) == '/':
            vals['name'] = self.env['ir.sequence'].next_by_code('crm.lead.seq')
        return super(crm_lead, self).create(vals)

Depending on the Odoo version(ex: v8) you need to include the sequence type like:

<record id="sequence_crm_lead_type" model="ir.sequence.type">
    <field name="name">CRM Lead Sequence Type</field>
    <field name="code">crm.lead.seq</field>
</record>

And add the sequence record

<record id="sequence_crm_lead" model="ir.sequence">
    <field name="name">CRM Lead Sequence</field>
    <field name="code">crm.lead.seq</field>
    <field name="prefix">OP</field>
    <field eval="1" name="number_next"/>
    <field eval="1" name="number_increment"/>
</record>

 Hope this helps

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

Add the ID field to the views - it is already a unique number assigned automatically by Odoo to each document (the database id).



อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มิ.ย. 23
1840
1
ต.ค. 24
1810
0
เม.ย. 22
2427
0
ต.ค. 17
3254
How To Edit Order Numbers? แก้ไขแล้ว
2
มิ.ย. 24
4190