Odoo Help


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.


Customer Invoice : Sequence generated but not displayed on view ; called in a method ; v7

Yassine TEIMI
on 12/26/14, 11:57 AM 729 views

I created a sequence via user interface : Configuration/Technical/Sequences and identifiers/ Sequences

I also created its code so as so to call it, on the python method on : Configuration/technical/Sequence Code

The model concerned is account.invoice , I want that when validating the invoice, it switches to state open, and generate a sequence  number, for that : 

1.  I overrided the type of validate invoice button to object ( it was workflow )

2.  I used invoice_validate as a button method , and overrided it.

3.  I overrided the number field, it was related, I made it simple char field.

and then I used the sequence, after the code for more explaination.

.py :  

class AccountInvoice(orm.Model):

    _inherit = 'account.invoice'
    _name = 'account.invoice'
    _colmuns = {
        'number': fields.char(size=64, readonly=True),

    def invoice_validate(self, cr, uid, ids, context=None):

        num_facture = self.pool.get('ir.sequence').get(cr, uid,'Invoice_number')

        self.write(cr, uid, ids[0], {'state':'open','number': num_facture,}, context=context)
        return True

.xml :

        <record id="invoice_form_custom" model="ir.ui.view">
            <field name="name">invoice.form.custom</field>
            <field name="model">account.invoice</field>
            <field name="inherit_id" ref="account.invoice_form"/>
            <field name="arch" type="xml">
                <xpath expr="//form/header/button[@name='invoice_open']" position="replace">
                    <button name="invoice_validate" states="draft" string="Valider" type="object" class="oe_highlight"/>

The issue is that the sequence is not displayed on the field "number" I overrided, should I add "number" on the xml view also ?




Med Said BARA

--Med Said BARA--
| 5 5 7
--Med Said BARA--
Med Said BARA
On 12/29/14, 11:31 AM

To get a field displayed, you must add it to a view (in .xml file)

I've added it, here is the xml file : invoice.form.custom account.invoice <xpath expr="//form/header/button[@name='invoice_open']" position="replace"> <xpath expr="//form/sheet/group/group/field[@name='partner_id']" position="before"> XML architecture error rising.

Yassine TEIMI
on 12/29/14, 2:15 PM

We are talking about the field "number" !!!

Med Said BARA
on 12/29/14, 2:34 PM

Oh sorry, I pasted the wrong code, I added number with inheritance in the XML file, it didn't work, The purpose is to change the field number, so as to get a new sequence.

Yassine TEIMI
on 12/30/14, 4:01 AM


| 5 4 7
Bangalore, India

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

On 12/29/14, 5:05 AM

Hi, the invoice number is associated with Journal Entry Number (account.move), so you cannot modify like that...

And Invoice validate action is performed by a Workflow..

So do this, write your own function/method say action_XXX(), in which you generate and update the Number

Then override the workflow function to include your custom method...

Like this...

        <record id="act_open" model="workflow.activity">
            <field name="wkf_id" ref="wkf"/>
            <field name="name">open</field>
            <field name="action">action_date_assign()
            <field name="kind">function</field>

Hi, I don't want to keep the actual invoice validation workflow, so no need to override it, I changed the type of the button "validate" into object, and related it to a method "x()", which is doing the right treatment I want. I want to give my validated invoice his own sequence, because it's no longer related to account_move. My problem now, is that I want to create a field, taking the new sequence and replacing the old invoice number field.it doesn't work with inheritance, always XML architecture error rising. The sequence is generated, and displayed on any char field of the form, but I want to place it in the heading of the invoice form right after INVOICE ( in bold caracter style).

Yassine TEIMI
on 12/29/14, 7:33 AM

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

2 follower(s)


Asked: 12/26/14, 11:57 AM
Seen: 729 times
Last updated: 3/16/15, 8:10 AM