Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
11 Odpowiedzi
12252 Widoki

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! :) 

Awatar
Odrzuć

@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.

Autor

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!

Najlepsza odpowiedź

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
 

Awatar
Odrzuć
Autor

Yes! That is PERFECT! You rock!

Autor

Yes! That is PERFECT! You rock!

can you please mark it as correct.?

Autor

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

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

@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.

Najlepsza odpowiedź

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>

Awatar
Odrzuć
Najlepsza odpowiedź
<xpath expr="//form/sheet/notebook/page[1]/field[@name='invoice_line_ids']/tree/field[@name='price_unit']" position="after">
<field name="deduction"/>
</xpath>
Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
mar 15
4925
3
kwi 15
3538
2
lis 22
2962
5
lut 22
5846
0
gru 23
5127