how can we generate a random code for leads

Asked by Pravitha V

hello everyone.......

i want to know how can we generate a unique code for each leads? can anyone help??????????????

Question information

English Edit question
Odoo Server (MOVED TO GITHUB) Edit question
No assignee Edit question
Solved by:
Pravitha V
Last query:
Last reply:
Revision history for this message
Pravitha V (pravithavarghese1) said :

hey i got the answer

a)goto openerp-server-->bin-->addons-->crm.
b)create a new xml file named “crm.sequence.xml”
 b.1)add the following code to crm.sequence.xml
  <?xml version="1.0" encoding="utf-8"?>
        <data noupdate="1">

        <!-- Sequences for crm.lead -->
         <record id="seq_type_crm_lead" model="ir.sequence.type">
              <field name="name">Lead/Opportunity</field>
              <field name="code">crm.lead</field>

         <record id="seq_crm_lead" model="ir.sequence">
                   <field name="name">Lead/Opportunity</field>
                   <field name="code">crm.lead</field>
                   <field name="prefix">EO</field>
                   <field name="padding">3</field>

 b.2)save and ext

c)goto openerp-server-->bin-->addons-->crm-->
 c.1)add the following code to at line 152:9

                       'x_enquirycode': fields.char('Enquiry Code', size=64, required=True,
                       readonly=True, states={'draft': [('readonly', False)]}, select=True),
 c.2)add the following code to at line 166:109

                       'x_enquirycode': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'crm.lead'),
 c.3)add the following code to at line 170:5

          def copy(self, cr, uid, id, default=None, context=None):
          if not default:
               default = {}
              'name': self.pool.get('ir.sequence').get(cr, uid, 'crm.lead'),
          return super(sale_order, self).copy(cr, uid, id, default, context=context)
 c.4)save and exit.

d)goto openerp-server-->bin-->addons-->crm-->crm_lead_view.xml
 d.1)add the following code to crm_lead_view.xml at line 71:21

                            <field name="x_enquirycode" string="Enquiry Code"/>
 d.2)save and exit
e)goto home-->workspace-->openERP-->src-->openerp-server-->bin-->addons-->crm-->
 e.1)add the following code to at line 104:8

 e.2)save and exit
f)goto sales-->sales-->leads-->customize object-->new
 f.1)fill the following fields
      Name :x_enquirycode
             Field label :Enquiry Code
             Field Type :char
             Required :yes
      Readonly :yes
 f.2)save and exit
g)goto Administration-->customisation-->user interface-->views-->crm.leads-->CRM-Leads form
 g.2)<field name="x_enquirycode”/>
 g.3)save and exit.

2)Restart the server and web.
 -->Restart server using thee command: –update=module
 -->goto localhost:8080