Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Auto Number or Auto Increment custom field (GUI)

By
Abdullah Sofan
on 11/3/14, 10:43 AM 2,030 views

I want to create a custom field to serve as an "Autonumber" field using the GUI. Can someone help? 

1

Odoo

--Odoo --
1328
| 5 2 5
kerala, India
--Odoo --

Working as a Odoo Functional and Technical Expert

Odoo
On 11/3/14, 11:05 AM

create one xml file  for sequencing---

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data noupdate="1">

        <!-- Sequences for loan_id -->
        <record id="seq__loan_code_inh1" model="ir.sequence.type">
            <field name="name">Loan ID</field>
            <field name="code">lending.info</field>
        </record>

        <record id="seq_cloan_code_inh2" model="ir.sequence">
            <field name="name">Loan ID</field>
            <field name="code">lending.info</field>
            <field name="prefix">LN</field>
            <field name="padding">2</field>
            
        </record>


    </data>
</openerp>

add  this xml file into your openerp.py file -------

{
'name':'Money Lend ',
'description':"""Module for managing small scale for managing their customers""",
'version':'0.0',
'author':'Libu Koshy m',
'depends':['base'],
'update_xml' : ['loan_view.xml',
                'loanseq_id.xml'],
'installable':True,
'category':'General',
'description':'Financial module Demo',
'website':'http://www.sirocotech.com',
'demo':[]
}
----------------------------------------

override the create method and add into your custom class

class lending_info(osv.osv):
    
    _name='lending.info'
  
    
    _columns={
          
              'loan_id':fields.char('ID',readonly=True),

              }

def create(self, cr, uid, vals, context=None):
        vals['loan_id'] = self.pool.get('ir.sequence').get(cr, uid,'lending.info')
        return super(lending_info, self).create(cr, uid, vals, context=context)

 _defaults={
                'loan_id': lambda obj, cr, uid, context: '/',

                }

 

 

 

Thank you for the quick response. However, I need this to work for a custom field added through the GUI. (Settings>Database Structure> Fields ) Can this be done?

Abdullah Sofan
on 11/3/14, 11:12 AM
0
Abdullah Sofan
On 11/3/14, 3:28 PM

Thank you for the quick response. However, I need this to work for a custom field added through the GUI. (Settings>Database Structure> Fields ) Can this be done?

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/3/14, 10:43 AM
Seen: 2030 times
Last updated: 9/7/15, 8:52 AM