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

I am finding Invoices not booked in the correct period. I don't want this. How do I find them? Fix them? Prevent this from happening?

By
Ray Carnes
on 6/2/15, 6:39 PM 480 views

How do I find them:

With this SQL:


select origin, reference, number, ai.state, date_invoice::date, account_period.name as wrong_period_name, account_period.id as wrong_period_id, account_period.date_start, account_period.date_stop,

(select account_period.id from account_period,account_invoice where account_invoice.id = ai.id and account_invoice.date_invoice::date >= date_start::date and account_invoice.date_invoice::date <= date_stop::date) as right_period_id,

(select account_period.name from account_period,account_invoice where account_invoice.id = ai.id and account_invoice.date_invoice::date >= date_start::date and account_invoice.date_invoice::date <= date_stop::date) as right_period_name

from account_invoice ai, account_period where ai.period_id = account_period.id and ( date_invoice::date < account_period.date_start::date or date_invoice::date > account_period.date_stop::date);

How do you fix them:

With this SQL:

update account_invoice ai set period_id = (select account_period.id from account_period where ai.date_invoice::date >= date_start::date and ai.date_invoice &lt;= date_stop::date) from account_period where ai.period_id = account_period.id and ( date_invoice::date &lt; account_period.date_start::date or date_invoice::date > account_period.date_stop::date);

You can prevent them by making the period field readonly, and letting Odoo calculate the value based on the date (instead of giving the user the ability to edit it).

Bista Solutions US, Ray Carnes
on 6/2/15, 6:40 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

1 follower(s)

Stats

Asked: 6/2/15, 6:39 PM
Seen: 480 times
Last updated: 6/2/15, 6:40 PM