Python实例2:使用BeforeSave事件-1原创
66人赞赏了该文章
335次浏览
未经作者许可,禁止转载编辑于2024年04月10日 11:32:34
实例描述:费用预提单中根据业务日期与创建日期的年月判断,给凭证日期赋值,以解决三方系统传递单据后业务日期所在年月不在当前会计期间,生成凭证异常问题。
实例效果:
注册python:
python代码:
def BeforeSave(f):
# 获取业务日期
billDate = this.Model.GetValue('FDATE')
# 获取创建日期
creatDate = this.Model.GetValue('FCREATEDATE')
# 判断业务日期与创建日期年月
if billDate.Year == creatDate.Year and billDate.Month<creatDate.Month:
this.Model.SetValue("F_account_Date",creatDate)
F_account_Date = this.Model.GetValue('F_account_Date')
else:
this.Model.SetValue("F_account_Date",billDate)
F_account_Date = this.Model.GetValue('F_account_Date')
#this.View.ShowMessage("保存成功!"+ "账单日期为:"+str(billDate) + ",创建日期为:"+str(creatDate) + ",业务日期所属年月小于创建日期所属年月时,凭证日期为创建日期!否则为业务日期!")
ResetAccountDate.zip(0.48KB)
推荐阅读