Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Dự án
- MRP
Câu hỏi này đã bị gắn cờ
Hi MouBou, Try this
import datetime
month = datetime.strptime(self.date_invoice, '%Y-%m-%d').strftime('%m')
For different formats
http://strftime.org/
I hope it helps you, regards.
Deear Jose, i am trying to do the same, but generating a new field x_MES_FACTURA as a calculated field related to invoice_date
for record in self:
record[x_MES_FACTURA] = datetime.strptime(self.invoice_date, '%Y-%m-%d').strftime('%m')
but it does not work. Where is my error??
Thanks
below i am posting a general,solution :
you can try this
from datetime import datetime
datetime_fomat = '%Y-%m-%d'
date="2014-06-15"
strp_date = datetime.strptime(date, datetime_fomat)#strp_date = datetime.strptime(str(self.date_invoice), datetime_fomat)print strp_date.month
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký