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

Order invoice line by product reference in invoice

By
Aitzol
on 5/13/13, 5:41 AM 2,819 views

I'd like to be able to order invoice lines by product reference in Invoice report (account.account_invoices). Is it possible to use repeatIn function so that the list contain invoice line ordered by product reference?

1
herbert6453
On 5/22/13, 10:46 AM

I don't know how to call the python build-in function "sorted" inside a rml file.

a) But you can define a own sort method in the account_print_invoice.py file.

add before the line report_sxw.report_sxw(

def sortByDefault_code(theList):
    theList.sort(key=lambda x: x.default_code, reverse=False)
    return theList  

self.localcontext.update({
    'sortByDefault_code':sortByDefault_code,
})

-- add the same spaces before def and self as already found before def in the account_print_invoice.py file

-- the shiftings in every line are important in python

b) change o.invoice_line to sortByDefault_code(o.invoice_line) in account_print_invoice.rml

<para style="terp_default_1">[[ repeatIn(sortByDefault_code(o.invoice_line),'l') ]]</para>

c) restart the openerp server

Hi, Could you help me change the order on a Purchase order print so the order is in Scheduled Date (date_planned)? Many thanks.

Kevin
on 7/2/15, 10:34 AM
0
Anne-Sylvie Burri
On 11/4/13, 4:23 AM

Hi everybody,

I just tried the previous solution but it doesn't work. What I wanna do is sort my invoice lines by name.

Someone could help me ?

I tried with the following code :

def sortByDefault_code(account_invoice):
    account_invoice.sort(key=lambda x: x.name, reverse=False)
    return account_invoice  

self.localcontext.update({
    'sortByDefault_code':sortByDefault_code,
})

Thanks in advance.

JMB

Did you also modify the RML file as herbert6453 mentioned?

Aitzol
on 11/5/13, 6:11 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: 5/13/13, 5:41 AM
Seen: 2819 times
Last updated: 3/16/15, 8:10 AM