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

Add a Field to the Invoice Line (v8)

By
David Birchmier
on 12/28/14, 7:08 PM 2,698 views

What Models/Views/etc must be edited in order to add a new field to the Invoice Line? 

Here's an example of where I want to add the field:
http://screencast.com/t/mSIxf3y4i7os

Thanks for your help! :) 

@David, Could you describe the field that you would like to add to the invoice line, is it a picture, your own custom text field, a computed field, etc.? This will help me to better answer your question. With that being said, you may find that you can edit the general invoice layout by inheriting and modifying the following id: inherit_id="account.report_invoice_document" This covers much of the body of the invoice. In terms of models this will depend on the nature of the field you'd like to place there.

Luke Branch
on 12/28/14, 11:09 PM

Hi Luke, Thanks for your detailed reply! The type of field I wish to add is a text field which will be limited to 7 characters, numbers only. Here's a specific use-case, if that helps: #1 In our workflow, every billable incident has a TICKET NUMBER associated with it. #2 When we bill, each line item is associated with a TICKET NUMBER #3 I want to add a custom field to allow us to enter the TICKET NUMBER that is associated with that line item that is being billed for. #4 This will output on the printed report invoice (I think I know how to do that) as well as be searchable/saved in the database for future reference. #5 The goal is to be able to correlate each line item with a specific Ticket # to allow us to reference more details if needed regarding any invoice line item. Hope this makes sense. Thanks again for the help!

David Birchmier
on 12/28/14, 11:17 PM
2

Baiju

--Baiju--
3154
| 5 4 8
Kochi, India
--Baiju--
ODOO technical and functional

        I like learning new thing, especially technical thing. I am a quick learner, I can learn technical things very fast. I have good logical skill,  I have immense interest in programming.

e-mail id : baijuks@hotmail.com

Baiju
On 12/29/14, 4:46 AM

Hi David,

Please check this , is it okay

I inherited 'account.invoice.line'
and added a integer field to that object

and then i inherited the view form i.e.. 'invoice_form' in account
and added that field to view part
 

Yes! That is PERFECT! You rock!

David Birchmier
on 12/29/14, 10:36 AM

Yes! That is PERFECT! You rock!

David Birchmier
on 12/29/14, 10:36 AM

can you please mark it as correct.?

Baiju
on 12/29/14, 10:37 AM

Marked as correct! Can you tell me how you achieved that result?

David Birchmier
on 12/29/14, 12:36 PM

Do you have a Skype id, or you want me to e-mail that to you?

Baiju
on 12/29/14, 1:00 PM

@Baiju and David, Please consider updating your answer with the method you have used if possible so that others viewing your post that are looking to accomplish something similar can learn from what you have done.

Luke Branch
on 12/29/14, 9:29 PM
1
Odoo Honduras
On 2/26/16, 2:52 PM

Hope it be usefull to you

__init__

from . import "name of yor module"


__openerp__


{

'name': 'Name of your module',

'version': '0.1',

'depends': ['account'],

'author': "Daniel Hernández",

'website': 'http://www.odoohonduras.com',

'category': 'Invoicing',

'data': [

'views/report_account_invoice.xml', # In order to show your field in the invoice document

' "name of your module" _view.xml',

],

}


name_of_your_module.py

from openerp import models, fields, api, _

class account_invoice_line(models.Model):

_inherit = 'account.invoice.line'

your_field_name = fields.Char(string='Your field name')


your_module_view.xml


<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data>

<record id="invoice_form_inherit" model="ir.ui.view">

<field name="name">account.invoice.inherit</field>

<field name="model">account.invoice</field>

<field name="inherit_id" ref="account.invoice_form"/>

<field name="arch" type="xml">

<xpath expr="//page[@string='Invoice Lines']/field[@name='invoice_line']/tree/field[@name='quantity']" position="before">

<field name="your field"/>

</xpath>

</field>

</record>

<!--<record id="invoice_supplier_form_inherit" model="ir.ui.view">

<field name="name">account.invoice.supplier.form.inherit</field>

<field name="model">account.invoice</field>

<field name="inherit_id" ref="account.invoice_supplier_form"/>

<field name="arch" type="xml">

<xpath expr="//tree[@string='Invoice lines']/field[@name='quantity']" position="before">

<field name="second_uom" attrs="{'readonly': [('state', '!=', 'draft')]}"/>

</xpath>

</field>

</record>-->

</data>

</openerp>



Abd in views folder


report_account_invoice,xml


<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data>

<template id="report_invoice_document_itemnumber"

inherit_id="account.report_invoice_document">

<xpath expr="//div[contains(@class, 'page')]/table[1]/thead/tr/th[1]" position="before">

<th>String of your field</th>

</xpath>

<xpath expr="//div[contains(@class, 'page')]/table[1]/tbody/tr/td[1]" position="before">

<td>

<span t-field="l.your field"/>

</td>

</xpath>

</template>

</data>

</openerp>

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

3 follower(s)

Stats

Asked: 12/28/14, 7:08 PM
Seen: 2698 times
Last updated: 8/19/16, 3:42 PM