Odoo Help

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 733 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

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

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