I want to create a custom field to serve as an "Autonumber" field using the GUI. Can someone help?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
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 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':'',
'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?
I look ed all over and the only tutorial or explanation that was in any way helpful is this excellent YouTube video from Odoo Mates, which completely solved the problem.
https://www.youtube.com/watch?v=Cz5eM5FDmTE
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?
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up