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

Onchange date plus 2 day

By
Susi
on 11/1/16, 4:07 AM 158 views

hi all i have inherit field 'end_date' : fields.date in object sale.order. And i have set product with internal category 'Umum'.

in sale order line i want if product_id.categ_id = Umum , field end date onchange plus (+)2 days.


If annyone can help me with example code. i would be very grateful. Thanks before

3

Using datetime.timedelta


date_1 = datetime.datetime.strptime(start_date, "%m/%d/%y")

end_date = date_1 + datetime.timedelta(days=2)

5

Nilmar Shereef

--Nilmar Shereef--
811
| 4 3 7
Calicut, India
--Nilmar Shereef--

Python Developer. Android Developer. .Net Developer

Nilmar Shereef
On 11/1/16, 5:07 AM

simply import the timedelta like below:

     from datetime import timedelta, datetime

 Then you can assign like below:

     date_today = fields.Date.today()           

    date_object = datetime.strptime(date_today, '%Y-%m-%d')

    v_date = date_object + timedelta(days=15)

Where 15 is the number of days to be added.!
I hope it may help you.
Thanks.

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: 11/1/16, 4:07 AM
Seen: 158 times
Last updated: 11/11/16, 7:00 AM