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

How can I add VAT (TIN) field from partner in customer Invoice tree view? Odoo v7

By
Santi
on 4/13/15, 7:16 AM 1,760 views

I need to make the VAT (TIN) field from res.partner available in account.invoice, so I can add it to the Invoice Tree View. How can I achieve this?



You have to customize one small module to make it visible to invoice, for more info contact@tidyway.in

Tidy Way
on 4/24/15, 9:49 AM

I know how to create a module, I just need to know what to inherit exactly...in order to pass the field data from one model to another

Santi
on 5/4/15, 6:26 PM
2

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 5/5/15, 2:47 AM

Hi,

You can inherit account.invoice object and add a functional field.

Try like this:

in .py file:

from openerp.osv import fields, osv
class account_invoice(osv.osv):
 
    _inherit = "account.invoice"
    
    def _get_vat_num(self, cr, uid, ids,field_name, args, context=None):
        
        partner_pool = self.pool.get('res.partner')
        invoice_pool = self.pool.get('account.invoice')
        res = {}
        for inv_id in self.browse(cr, uid, ids, context=context):
            invoice = invoice_pool.browse(cr,uid, inv_id.id, context=None)
            partner = partner_pool.browse(cr, uid, invoice.partner_id.id, context=None)
            res[inv_id.id] = partner.vat
        
        return res 
    
    _columns = {
                
                'inv_vat': fields.function(_get_vat_num, string="VAT", type='char', method=True)  
                 }


in .xml file:

<openerp>
    <data>
        <record id="invoice_form_inherit" model="ir.ui.view">
    		<field name="name">invoice.form.inherit</field>
    		<field name="model">account.invoice</field>
    		<field name="inherit_id" ref="account.invoice_form"/>
    		<field name="arch" type="xml">
    		    <field name="partner_id" position="after">
    		    	
                                    <field name="inv_vat"/>
    		    </field>
    		</field>
		</record>
            
    </data>
</openerp>

Thanks Akhil! and sorry for my late response, I was busy and hadn't been able to try it till now. That's exactly what I was looking for, I just changed the view code to tree instead of form, and it worked. Thanks again for the detailed response.

Santi
on 5/10/15, 6:09 PM
3

Solanki Shamji

--Solanki Shamji--
1293
| 5 2 6
Baroda, India
--Solanki Shamji--

Hello!

Solanki Shamji
On 5/5/15, 2:41 AM

Hello,

May be this will help full to you.

Inherit account.account.

Add one functional field in account.account which fetch value from res.partner because partner_id is already present in account.account.

Thanks.

Shamji.

Thanks Solanki.

Santi
on 5/10/15, 6:10 PM

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)

Stats

Asked: 4/13/15, 7:16 AM
Seen: 1760 times
Last updated: 5/10/15, 6:06 PM