Odoo sequence reset insist using UTC - odoo

I am using Odoo sequence for a form number. This sequence is set to reset every month. But I have noticed an issue in the sequence reset time.
The sequence turns out resetting every UTC not at server timezone which is UTC +8. So when a transaction happened at 1 July 7 AM (UTC + 8) the sequence is still not being reset. The reset happened on 1 July at 8 AM (UTC).
How can I make the sequence reset based on my timezone? The server timezone is already UTC + 8.

Two Options:
Check the timezone of your database. Do this in your postgres db terminal with the command:
show timezone;
You should expect your local timezone or UTC
If you check the model behind the feature, in the postgress console:
\d ir_sequence_date_range
You may notice that the fields related to the range of the dates (date_from, date_to) were created as "date" and not "datetime" so it gonna miss the hours.
Also, in the form view, the is not possible to set the time:
sequence_form
So an alternative is change the data type of the column from date to datetime. To do this you must extend the model and over write the field something like this:
class IrSequenceDateRangeExtended(models.Model):
_inherit = 'ir.sequence.date_range'
date_from = fields.Datetime(string='From', required=True)
date_to = fields.Datetime(string='To', required=True)
Then, after update you should be able to set the time to the date.
I hope it helps you.

Related

Set automatic date and time in json using kql or anything

I have a json object and in that I have date and time and want that date and time to be set automatically meaning it should read computer's date and time automatically every day when the application is in run? Can anyone help how to do that?
I don't have any solution for this.

React Table shows entries based on User Time zone not UTC

I have a table (react/Nodejs) which reads the entries from db and list it in the table. All entries in db are UTC, however depending on the user time zone the table is showing different data. For example in the attached snapshot our week on header is from Sep 19 to Sep 25 but the table shows Sep 26 entry which is outside of the range. That only happens with users on (UTC-xxx) time and not for user on (UTC+xxx). Your help is appreciated? Table Image
Use a timezone library to render it with a specific timezone
The problem is caused when formatting the object to be rendered in the UI, so probably the method you are using is as you say taking into account the users timezone and not a specific one that you set.
To achieve this, you can use a library like moment timezone. Or a variant compatible with your libraries.
Hope it helps.

How to save date into database with current time?

I have a table in database, one of the row adds add while something was done/acomplished. And it works fine. But.. it doesn't add current time. When I prints out date from db, it shows 2016-12-13 00:00. Instead of for example 2016-12-13 15:32. How do I add current time?
This is how my sql looks
[example_date] DATE NOT NULL,
The date data type does not have a time component. You want either datetime or datetime2 (or perhaps smalldatetime):
example_datetime DATETIME NOT NULL,
You can review the documentation for the various date/time data types here.

Local Time & UTC Confusion C#, SQL Server

I am storing all dates to SQL Server as a UTC date time. I have Time Zone Id for each user stored in user profile as well.
Now when user requests data back, I want to display local time of user for each record using the Time Zone I have stored in profile for the particular user.
What is an easiest and optimized way (as I am processing heaps of records at the same time) to convert all dates and time to particular time zone on the fly while returning data? Either in SQL or in C# would be fine...
Very important question is, let's say there is a record created from Sydney when there was Day Light Saving "ON" and now Day Light Saving is "OFF". As the record was created when Day Light Saving was "ON", will it still convert the same time or will it return conversion as per current time zone status (which is Day Light Saving is "OFF")???
People only see those records which they had created from the particular
let's say there is a record created from Sydney when there was Day Light Saving "ON" and now Day Light Saving is "OFF". As the record was created when Day Light Saving was "ON", will it still convert the same time or will it return conversion as per current time zone status (which is Day Light Saving is "OFF")
The record contains an UTC date and time. This is going to fall into a DST ON or DST OFF period, deterministic. Is irrelevant whether the DST is in effect now. The opposite (storing local time, trying to extract UTC) is undetermined because of the overlap times when the DST changes (a small range of local times cannot be deterministically converted to UTC if they fall into the 60 mins that occurs twice when DST come into effect, assuming a 60 min DST).
As for the question: transform the date in your presentation layer. Use TimeZoneInfo.ConvertTimeFromUtc.

how to insert current time automatically in table in oracle forms?

I have a problem in oracle forms.
My database is consisting of a main table,table name is (buy_order_customer) which has (b_order_id,customer_id,b_date,b_time).
I'd like to insert the current time automatically in the b_time column, I'm able to insert the current date in the b_date column but I can't do the same with b_time.
Both b_date, and b_time is of type 'date'.
can any one help please?
thanks in advance.
In Oracle DB a DATE datatype always contain both date and time (even if you don't display them.
So, if you inserted the current date into b_date then you already have the current time as well.
Try this:
SELECT to_char(b_date, 'mm-dd-yyyy hh24:mi:ss')
FROM buy_order_customer
and see that you have the time as well
I think you mean the initialvalue to fill these fields in a form at runtime.
If I'm right then you need one of the following system variables:
$$DATE$$ retrieves the current operating system date (client-side).
$$DATETIME$$ retrieves the current operating system date and time.
$$DBDATE$$ retrieves the current database date.
$$DBDATETIME$$ retrieves the current date and time from the local database.
I don't know any system variable to retrieve only the time.
If it is for displaying purposes you need to use dateformat masks on your fields.