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 | etc.
Odoo team, my question is about how to create a read-only field in Odoo, have a prefix or suffix, eg. fact00001, fact00002, fact00003 etc. or 00001A,00002A,00003A, etc
I need that new field in the invoice module but I have no idea how to make it appear there.
I know I create a new class in python, then inherit from the base class, you need to create the field, then create an .xml file with the structure of the view and modify the view from the xml, but I do not know how to do it ...
thanks in advance ...
You can have better understanding with an example:
in your xml file, you can define the sequence with the prefix or suffix you need:
<?xml version="1.0" encoding="utf-8"?>
<record id="seq_invoice_code" model="ir.sequence.type">
<record id="seq_invoice" model="ir.sequence">
in your .py file, you can define the readonly field and override the create() to get the sequence on that field:
_inherit = "account.invoice"
inv_code = fields.Char(string='Code', readonly=True)
def create(self, cr, uid, vals, context=None):
vals['inv_code'] = self.pool.get('ir.sequence').get(cr, uid,'account.invoice')
return super(account_invoice, self).create(cr, uid, vals, context=context)
You can then call this field in the form view wherever you want, by inheriting the corresponding form view.
And you may also check all the sequences available in your current database and can also modify from here:
Settings >> Technical >> Sequences & identifiers >> Sequences
Hope this helps!
You should consider using the sequence in invoice module. It has the prefix, suffix and auto increment feature. You need to create a sequence and sequence code. Invoice already has a sequence field there. You should take it has a example. Go through the following links to get the basics:
About This Community
This platform 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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 5/22/15, 9:57 AM|
|Seen: 2400 times|
|Last updated: 10/21/15, 1:36 AM|