Skip to Content
Menu
This question has been flagged

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);

Avatar
Discard

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

Related Posts Replies Views Activity
4
Dec 21
5685
2
Mar 15
3236
1
Sep 24
234
2
Aug 24
358
3
Jul 24
2393