Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
10131 มุมมอง

i have a code like

'leave_from' : fields.date("Cuti Dari Tanggal", required=True),

'leave_until' : fields.date("Cuti Sampai Dengan", required=True),

and 1 fields to accomodate them

'leave_taken' : fields.function(function_diambil_cuti, method=True, string='Cuti Diambil(hari)', type='float'),

and what i have to do to subtract the leave_until fields and leave_from fields to get the DAY without calculate saturday and sunday and fill the leave_taken fields with the result ?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

You can use like this here create the date

 'leave_from' : fields.date("Leave Date", required=True), 

 'leave_from' : fields.date("Leave Until", required=True),


def _date_cal(self, cr, uid, ):

     leave_taken = (leave_from-leave_from).days
อวตาร
ละทิ้ง
ผู้เขียน

no effect, still got error :(

คำตอบที่ดีที่สุด
 i = leave_from
cnt = 0
 while (i <leave_until): if="" (="" i.weekday()="=" 5="" or="" i.weekday()="=" 6):="" cnt="cnt+0" else:="" cnt="cnt+1" i++="" leave_taken="cnt</pre">
อวตาร
ละทิ้ง

i = leave_from cnt = 0 while (i <leave_until): if i.weekday()==5 or i.weekday()==6: cnt=cnt+0 else: cnt= cnt+1 i++ leave_taken =cnt

คำตอบที่ดีที่สุด

Hi pls chk this code.....

maturity_date and deposit_date are two date fields from a same class .By this code u can easily calculate number of days between two dates try this

def calc_maturity_amount(self,cr,uid,ids,context=None):

     num=self.read(cr,uid,ids,['maturity_date','deposit_date','deposit_amount','intr_rate'],context=context)
       dateformat="%Y-%m-%d"
     interst_rate=num[0]['intr_rate']

     d1=datetime.strptime(num[0]['maturity_date'],dateformat)
     d2=datetime.strptime(num[0]['deposit_date'],dateformat)
     v1=d1-d2
     total_days=v1.days
อวตาร
ละทิ้ง
ผู้เขียน

what 'deposit_amount' means??

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มิ.ย. 20
5594
4
ก.ค. 16
5215
2
ธ.ค. 19
4984