跳至内容
菜单
此问题已终结
2 回复
5944 查看

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

形象
丢弃
最佳答案

Using datetime.timedelta


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

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

形象
丢弃
最佳答案

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.

形象
丢弃
相关帖文 回复 查看 活动
0
2月 16
5317
2
3月 15
5227
1
7月 19
3229
1
9月 16
7899
6
6月 21
25609