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.

1

How to change the Invoice Line?

By
my
on 4/20/13, 4:14 AM 6,178 views

Hi i want to change the code in this field in the line of Invoice: [[ formatLang(l.price_subtotal, digits get_digits(dp 'Account')) ]] [[ o.currency_id.symbol ]]. I want it incl. tax. How had to be this code? Who can help me?

0
my
On 4/21/13, 10:57 PM

Hi klacus, hi i get an Error

OpenERP Server Error

Client Traceback (most recent call last): File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server\openerp\addons\web\http.py", line 204, in dispatch File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server\openerp\addons\web\controllers\main.py", line 1133, in call_button File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server\openerp\addons\web\controllers\main.py", line 1121, in _call_kw File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server\openerp\addons\web\session.py", line 43, in proxy File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server\openerp\addons\web\session.py", line 31, in proxy_method File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server\openerp\addons\web\session.py", line 104, in send

Server Traceback (most recent call last): File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server\openerp\addons\web\session.py", line 90, in send File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\netsvc.py", line 293, in dispatch_rpc File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\service\web_services.py", line 626, in dispatch File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\osv\osv.py", line 188, in execute_kw File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\osv\osv.py", line 131, in wrapper File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\osv\osv.py", line 197, in execute File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\osv\osv.py", line 185, in execute_cr File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server\openerp\addons\sale\sale.py", line 579, in action_button_confirm File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\wkf_service.py", line 119, in trg_validate File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\instance.py", line 43, in validate File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\workitem.py", line 60, in process File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\workitem.py", line 175, in _split_test File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\workitem.py", line 183, in _join_test File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\workitem.py", line 40, in create File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\workitem.py", line 60, in process File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\workitem.py", line 175, in _split_test File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\workitem.py", line 183, in _join_test File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\workitem.py", line 40, in create File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\workitem.py", line 60, in process File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\workitem.py", line 175, in _split_test File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\workitem.py", line 183, in _join_test File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\workitem.py", line 40, in create File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\workitem.py", line 52, in process File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\workitem.py", line 127, in _execute File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\wkf_expr.py", line 67, in execute File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\workflow\wkf_expr.py", line 57, in _eval_expr File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\tools\safe_eval.py", line 241, in safe_eval File "", line 1, in <module> File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\osv\orm.py", line 374, in function_proxy File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server\openerp\addons\sale_stock\sale_stock.py", line 190, in action_invoice_create File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server\openerp\addons\sale\sale.py", line 519, in action_invoice_create File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server\openerp\addons\sale\sale.py", line 809, in invoice_line_create File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\osv\orm.py", line 4478, in create File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\osv\orm.py", line 4627, in _store_set_values File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server.\openerp\osv\fields.py", line 1131, in get File "C:\Program Files (x86)\OpenERP 7.0-20130327-002325\Server\server\openerp\addons\csysc_inh_account_inv_tax\account_invoice.py", line 10, in _amount_line TypeError: _amount_line() takes exactly 7 arguments (8 given)

Whats wrong?

Morgen.. :-) Yeah, just a wait a few hours. I will help you, as I can... Please try the upside code.

klacus
on 4/22/13, 2:06 AM

Hi. Just do it. If I can I will help you. Regards.

klacus
on 4/28/13, 11:57 AM

Your problem is raised here: def _amount_line(self, cr, uid, ids, prop, unknow_none, unknow_dict):

but the problem is there: _columns = { 'tax_percent' : fields.float('tax_percent'), # percentage of the tax 'tax_amount' : fields.float('tax_amount'), # amount of the tax 'line_total' : fields.float('line_total'), # calculate line tax + line amount 'price_subtotal': fields.function(_amount_line, string='Subtotal', type="float",digits_compute= dp.get_precision('Account'), store=True),
} Please check again. the price_subtotal..

klacus
on 5/6/13, 1:07 AM

hi, thanks for your help. Now I can indeed confirm an offer again in an order, but unfortunately at the 'price_subtota'l nothing changed. Here, the net amount is still displayed.

my
on 5/6/13, 10:58 PM

What is the situation now? 1. The program is running? 2. You should restart your server, after change something in python. 3. Price subtotal is change by auto, if you create a new invoice line. May you forget the restart. :-)

klacus
on 5/6/13, 11:56 PM

What is the situation now? 1. The program is running? 2. You should restart your server, after change something in python. 3. Price subtotal is change by auto, if you create a new invoice line. May you forget the restart. :-)

klacus
on 5/7/13, 2:11 AM
0
NSC
On 1/12/14, 6:31 PM

I have a similar issue. Maybe somebody can help. I need to add only product.name_template to account.invoice.line. This is the very left part of the invoice lines shown inside form view. Booking text joins Internal ID, product name and product description. This is too much and these three fields can not be accessed separately. Internal Id and description are only for internal use and should not appear on my invoices. I would be grateful for help.

0
klacus
On 4/21/13, 3:28 AM

Hi.

The account.invoice.line table is not include the tax. So if you want to see the tax by row, first your need to inherit the account.invoice.line table to add tax. After that you need some code in python what is filling it. If you have all of this things you can add a report. Just put somewhere [[o.your_tax_column_name]].

If you use Open/libre for editing, sometimes the system not found your custom record, but do not hesitate write it by hand, and try to see the filed values.

You need to understand the followings: - inherit a model. - some basics in python.

Hi.

In python you can add like this your own inherit module: My module name is: csysc_inh_account_inv_tax You just create a folder under addons. . create the following files with a same name - install a module. (first refresh the modules list, after looking the csysc_... module)

account_invoice.py

from osv import fields, osv
import decimal_precision as dp
import time

# inherit account_invoice line by standard way

class account_invoice_line(osv.osv):
    # override this methode to get the tax info's by invoice line   
    def _amount_line(self, cr, uid, ids, prop, unknow_none, unknow_dict):
        values = super(account_invoice_line, self)._amount_line(self, cr, uid, ids, prop, unknow_none, unknow_dict)
        res = {}
        tax_obj = self.pool.get('account.tax')
        cur_obj = self.pool.get('res.currency')
        for line in self.browse(cr, uid, ids):
            price = line.price_unit * (1-(line.discount or 0.0)/100.0)
            taxes = tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, price, line.quantity, product=line.product_id, address_id=line.invoice_id.address_invoice_id, partner=line.invoice_id.partner_id)
            res[line.id] = taxes['total']
                        #-----------------------------------------------------------------------------------
        for r in taxes['taxes']: # listing the result list
            id = r.get('id')    # get id of the taxes       
        tax_percent = self.pool.get('account.tax').browse(cr, uid, id).amount               
        tax_amount  = taxes['total_included'] -  taxes['total']
        tax_total   = taxes['total_included'] 
        for r in ids:
            id = r
            cr.execute('UPDATE account_invoice_line SET tax_percent = %s  WHERE id=%s', (tax_percent,id,))
            cr.execute('UPDATE account_invoice_line SET Tax_amount = %s  WHERE id=%s', (tax_amount,id,))
            cr.execute('UPDATE account_invoice_line SET Line_total = %s  WHERE id=%s', (tax_total,id,)) 
        #-----------------------------------------------------------------------------------            
            if line.invoice_id:
                cur = line.invoice_id.currency_id
                res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])
        return res  

    _inherit= "account.invoice.line"
    _description = "account.invoice.line"  

    _columns = {
        'tax_percent' : fields.float('tax_percent'),    # percentage of the tax 
        'tax_amount' : fields.float('tax_amount'),      # amount of the tax
        'line_total' : fields.float('line_total'),      # calculate line tax + line amount
        'price_subtotal': fields.function(_amount_line, string='Subtotal', type="float",digits_compute= dp.get_precision('Account'), store=True),       
            }


account_invoice_line()

__openerp__.py:

{
    "name" : "csysc_inh_account_inv_tax",
    "version" : "1.0",
    "author" : "Company System Controll LTD",
    "website" : "",
    "category" : "Generic Modules/Others",
    "depends" : ["base","account"],
    "description" : "Overvrite account invoice line. Put and calculate tax by line.",
    "init_xml" : [],
    "demo_xml" : [],
    "update_xml" : [],
    "active": False,
    "installable": True
}

__init__.py:

import account_invoice

Comment: I use update sql,. because the orm write methode is always call _amount_line methode, so I want to avoid the never ending story.. :-)

If you want to modify the report of the invoices, now you can find the new, and hopefully filled records, when you browse that in Libreoffice report designer.

In the report designer. 1. Join to the server 2. Modify report >> account.invoice 3. Go to the second section. 4. Insert the field. >> [[ l.tax_amount ]] 5. Save report. 7. Send to the server.

or direct in rml open the addons/account/report/acount_print_invoice.rml modify Table 7 and Table8
- modify the table description:

<blockTable colWidths="185.0,70.0,80.0,60.0,**50.0**,50.0,85.0" style="Table7">
  <tr>
    <td>
      <para style="terp_tblheader_General">Description</para>
    </td>
    <td>
      <para style="terp_tblheader_General_Centre">Taxes</para>
    </td>
    <td>
      <para style="terp_tblheader_General_Right">Quantity</para>
    </td>
    <td>
      <para style="terp_tblheader_General_Right">Unit Price</para>
    </td>
    <td>
      <para style="terp_tblheader_General_Right">Disc.(%)</para>
    </td>
    <td>
      <para style="terp_tblheader_General_Right">Tax amount</para>
    </td>
    <td>
      <para style="terp_tblheader_General_Right">Price</para>
    </td>
  </tr>
</blockTable>

and Table 8 modify also: (put the data record)

<para style="terp_default_2">[[ repeatIn(o.invoice_line,'l') ]]</para>
  <blockTable colWidths="185.0,70.0,80.0,60.0,50.0,85.0" style="Table8">
    <tr>
      <td>
        <para style="terp_default_9">[[ l.name ]]</para>
      </td>
      <td>
        <para style="terp_default_Centre_9">[[ ', '.join([ lt.name or '' for lt in l.invoice_line_tax_id ]) ]]</para>
      </td>
      <td>
        <para style="terp_default_Right_9">[[ formatLang(l.quantity)]] [[ (l.uos_id and l.uos_id.name) or '' ]]</para>
      </td>
      <td>
        <para style="terp_default_Right_9">[[ formatLang(l.price_unit) ]]</para>
      </td>
      <td>
        <para style="terp_default_Centre_9">[[ formatLang(l.discount, dp='Account') ]] </para>
      </td>
      **<td>
        <para style="terp_default_9">[[ l.tax_amount ]]</para>
      </td>**
      <td>
        <para style="terp_default_Right_9">[[ formatLang(l.price_subtotal, dp='Account', currency_obj=o.currency_id) ]]</para>
      </td>
    </tr>
    <tr>
      <td>
        <para style="terp_default_Note">[[ format(l.note or '') or removeParentNode('tr') ]]</para>
      </td>
      <td>
        <para style="terp_default_9">
          <font color="white"> </font>
        </para>
      </td>
      <td>
        <para style="terp_default_Right_9">
          <font color="white"> </font>
        </para>
      </td>
      <td>
        <para style="terp_default_Right_9">
          <font color="white"> </font>
        </para>
      </td>
      <td>
        <para style="terp_default_Right_9">
          <font color="white"> </font>
        </para>
      </td>
      <td>
        <para style="terp_default_Right_9">
          <font color="white"> </font>
        </para>
      </td>
      <td>
        <para style="terp_default_Right_9">
          <font color="white"> </font>
        </para>
      </td>
    </tr>
  </blockTable>

What is the situation now? 1. The program is running? 2. You should restart your server, after change something in python. 3. Price subtotal is change by auto, if you create a new invoice line. May you forget the restart. :-)

klacus
on 5/7/13, 2:12 AM

In libre office, you can copy a field from existing field, and rename it to [[o.tax_amount]] >> this should be your new record from your account.invoice.line object. The SQL update is must be done from system side, when you install the module. You can check it by PGAdmin. (Must be find out the new records in account_invoice_line table)

klacus
on 5/7/13, 10:57 PM

Ok I checked. Please be note the report has two object: o.recordname >> come from account.invoice l.recordname >> come from account.invoice.line object. So your case you need to add by l.tax_amount. Sorry about, because I did not check the account_print_invoice.rml, I wrote down all of my head. :-( But try this way, and never give up! :-)

klacus
on 5/8/13, 1:34 AM

I refreshed the answer, please check, how to modify the report. Like a small how to :-)

klacus
on 5/9/13, 1:45 AM

Hi. Please check the table. Do you have a data in the table of account_invoice_line? (I mean the new records.)

klacus
on 5/14/13, 12:59 AM

You check by PgAdmin? What kind of tool use for the coding? Eclipse? Can you debug the code by breakpoint?

klacus
on 5/14/13, 3:10 AM

Hi, Yes i checked by PgAdmin. I copy and pasted your code with notepad. How can i debug the cde?

my
on 5/15/13, 1:16 AM

HI! I applied this modification in OERP 7.0, account/account_invoice.py. But when I try to create an Invoice from a Sales order I got this error: File "/home/openerp/server/openerp/addons/account/account_invoice.py", line 1395, in _amount_line for r in taxes['taxes']: # listing the result list UnboundLocalError: local variable 'id' referenced before assignment

Sajt Mano
on 9/24/13, 9:23 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

0 follower(s)

Stats

Asked: 4/20/13, 4:14 AM
Seen: 6178 times
Last updated: 3/16/15, 8:10 AM