fix
parent
b4296e54a3
commit
a881dfadda
|
@ -1,7 +1,7 @@
|
||||||
<form model="clinic.period">
|
<form model="clinic.period">
|
||||||
<head>
|
<head>
|
||||||
<button string="Options" dropdown="1">
|
<button string="Options" dropdown="1">
|
||||||
<!--<item string="Copy" method="copy"/>-->
|
<item string="Generate Period" method="gen_period"/>
|
||||||
</button>
|
</button>
|
||||||
</head>
|
</head>
|
||||||
<group form_layout="stacked">
|
<group form_layout="stacked">
|
||||||
|
@ -15,11 +15,11 @@
|
||||||
<field name="date_start"/>
|
<field name="date_start"/>
|
||||||
<field name="date_stop"/>
|
<field name="date_stop"/>
|
||||||
<field name="day_total"/>
|
<field name="day_total"/>
|
||||||
<field name="close"/>
|
<field name="state"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</group>
|
</group>
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Generate" type="default" icon="arrow-right" method="gen_period"/>
|
<button string="Close Period" type="danger" method="close_period"/>
|
||||||
</foot>
|
</foot>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<form model="clinic.report.labor.cost">
|
<form model="clinic.report.labor.cost">
|
||||||
<field name="period_id" span="2"/>
|
<field name="period_id" onchange="onchange_period" domain='[["state","=","open"]]' span="2"/>
|
||||||
<field name="date" mode="month" onchange="onchange_date" span="2"/>
|
<!--<field name="date" mode="month" onchange="onchange_date" span="2"/>-->
|
||||||
<field name="date_from" onchange="onchange_from" required="1" span="2"/>
|
<field name="date_from" onchange="onchange_from" required="1" span="2"/>
|
||||||
<field name="date_to" required="1" span="2"/>
|
<field name="date_to" required="1" span="2"/>
|
||||||
<field name="branch_id" onchange="onchange_branch" span="2"/>
|
<field name="branch_id" onchange="onchange_branch" span="2"/>
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Period(Model):
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
last_id=None
|
last_id=None
|
||||||
for line in obj.lines:
|
for line in obj.lines:
|
||||||
if line.close:
|
if line.state=='close':
|
||||||
last_id=line.id
|
last_id=line.id
|
||||||
res[obj.id]=last_id
|
res[obj.id]=last_id
|
||||||
return res
|
return res
|
||||||
|
@ -25,7 +25,7 @@ class Period(Model):
|
||||||
'lines': fields.One2Many("clinic.period.line","period_id", "Lines"),
|
'lines': fields.One2Many("clinic.period.line","period_id", "Lines"),
|
||||||
'last_period_id': fields.Many2One("clinic.period.line","Last Period",function="_get_last_period"),
|
'last_period_id': fields.Many2One("clinic.period.line","Last Period",function="_get_last_period"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_start(self,context={}):
|
def _get_start(self,context={}):
|
||||||
year=time.strftime("%Y")
|
year=time.strftime("%Y")
|
||||||
return '%s-01-01'%year
|
return '%s-01-01'%year
|
||||||
|
@ -40,6 +40,13 @@ class Period(Model):
|
||||||
'date_stop': _get_stop,
|
'date_stop': _get_stop,
|
||||||
'nmonth': 12,
|
'nmonth': 12,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def close_period(self,ids,context={}):
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
for line in obj.lines:
|
||||||
|
line.write({
|
||||||
|
'state': 'close',
|
||||||
|
})
|
||||||
|
|
||||||
def gen_period(self,ids,context={}):
|
def gen_period(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
|
|
|
@ -31,14 +31,18 @@ class PeriodLine(Model):
|
||||||
'date_stop': fields.Date("Date End"),
|
'date_stop': fields.Date("Date End"),
|
||||||
'day_total': fields.Integer("Duration (Day)",function="_get_total"),
|
'day_total': fields.Integer("Duration (Day)",function="_get_total"),
|
||||||
'state': fields.Selection([['open','Open'],['close','Close']],"State"),
|
'state': fields.Selection([['open','Open'],['close','Close']],"State"),
|
||||||
'close': fields.Boolean("Close"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
'state': 'open',
|
'state': 'open',
|
||||||
'close': False,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def delete(self,ids,context={}):
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
if obj.state=='close':
|
||||||
|
raise Exception("Can delete object which state is closed!")
|
||||||
|
super().delete(ids,context)
|
||||||
|
|
||||||
def create(self,vals,**kw):
|
def create(self,vals,**kw):
|
||||||
id=super().create(vals,**kw)
|
id=super().create(vals,**kw)
|
||||||
self.function_store([id])
|
self.function_store([id])
|
||||||
|
@ -74,5 +78,4 @@ class PeriodLine(Model):
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PeriodLine.register()
|
PeriodLine.register()
|
||||||
|
|
|
@ -38,7 +38,16 @@ class ReportLaborCost(Model):
|
||||||
date_to=defaults.get("date_to", self._get_date_to())
|
date_to=defaults.get("date_to", self._get_date_to())
|
||||||
report_type=defaults.get("report_type","cross")
|
report_type=defaults.get("report_type","cross")
|
||||||
print('defaults ', defaults)
|
print('defaults ', defaults)
|
||||||
|
yearnow=date_from.split("-")[0]
|
||||||
|
for period in get_model('clinic.period').search_browse([['name','=',yearnow]]):
|
||||||
|
for line in period.lines:
|
||||||
|
if line.state=='open':
|
||||||
|
period_id=line.id
|
||||||
|
date_from=line.date_start
|
||||||
|
date_to=line.date_stop
|
||||||
|
break
|
||||||
res={
|
res={
|
||||||
|
'period_id': period_id,
|
||||||
'date': time.strftime("%Y-%m-%d"),
|
'date': time.strftime("%Y-%m-%d"),
|
||||||
'date_from': date_from,
|
'date_from': date_from,
|
||||||
'date_to': date_to,
|
'date_to': date_to,
|
||||||
|
@ -344,6 +353,18 @@ class ReportLaborCost(Model):
|
||||||
nlines[-1]['qty']+=nline['qty'] or 0
|
nlines[-1]['qty']+=nline['qty'] or 0
|
||||||
nlines[-1]['cost']+=nline['cost'] or 0
|
nlines[-1]['cost']+=nline['cost'] or 0
|
||||||
nlines[-1]['total']+=nline['total'] or 0
|
nlines[-1]['total']+=nline['total'] or 0
|
||||||
|
|
||||||
|
def conv2line(keys=[],lines=[]):
|
||||||
|
lines2=[]
|
||||||
|
for key in keys:
|
||||||
|
no=0
|
||||||
|
vals={}
|
||||||
|
for line in lines:
|
||||||
|
vals[no]=line[key]
|
||||||
|
no+=1
|
||||||
|
lines2.append(vals)
|
||||||
|
return lines2
|
||||||
|
|
||||||
data={
|
data={
|
||||||
'company_name': '%s %s' % (company.name or "", sub_name),
|
'company_name': '%s %s' % (company.name or "", sub_name),
|
||||||
'date': date,
|
'date': date,
|
||||||
|
@ -351,7 +372,9 @@ class ReportLaborCost(Model):
|
||||||
'date_to': date_to,
|
'date_to': date_to,
|
||||||
'lines': lines,
|
'lines': lines,
|
||||||
'dlines': dlines,
|
'dlines': dlines,
|
||||||
|
'dlines2': conv2line(['name','qty','qty2','total_qty','cost'],dlines),
|
||||||
'nlines': nlines,
|
'nlines': nlines,
|
||||||
|
'nlines2': [],
|
||||||
'ctlines': ctlines,
|
'ctlines': ctlines,
|
||||||
'total_hdcase': total_hdcase,
|
'total_hdcase': total_hdcase,
|
||||||
'branch_id': branch_id,
|
'branch_id': branch_id,
|
||||||
|
@ -359,6 +382,15 @@ class ReportLaborCost(Model):
|
||||||
'show_detail': show_detail,
|
'show_detail': show_detail,
|
||||||
'report_type': report_type,
|
'report_type': report_type,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for key in ('name', 'qty', 'cost'):
|
||||||
|
no=0
|
||||||
|
vals={}
|
||||||
|
for nline in data['nlines']:
|
||||||
|
vals[no]=nline[key]
|
||||||
|
no+=1
|
||||||
|
data['nlines2'].append(vals)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def onchange_date(self,context={}):
|
def onchange_date(self,context={}):
|
||||||
|
@ -379,5 +411,13 @@ class ReportLaborCost(Model):
|
||||||
data=context['data']
|
data=context['data']
|
||||||
data['date_to']=data['date_from']
|
data['date_to']=data['date_from']
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def onchange_period(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
period_id=data['period_id']
|
||||||
|
period=get_model('clinic.period.line').browse(period_id)
|
||||||
|
data['date_from']=period.date_start
|
||||||
|
data['date_to']=period.date_stop
|
||||||
|
return data
|
||||||
|
|
||||||
ReportLaborCost.register()
|
ReportLaborCost.register()
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import time
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from calendar import monthrange
|
from calendar import monthrange
|
||||||
|
|
||||||
|
@ -161,21 +162,14 @@ class ClinicSetting(Model):
|
||||||
if user_id !=1:
|
if user_id !=1:
|
||||||
print("Only admin!!")
|
print("Only admin!!")
|
||||||
return
|
return
|
||||||
categ_ids=get_model('product.categ').search([['parent_id.code','=','MDC']])
|
datenow=time.strftime("%Y-%m-%d")
|
||||||
for prod in get_model("product").search_browse([['categ_id','in',categ_ids]]):
|
vdom=[
|
||||||
prod.write({
|
['visit_date','>',datenow],
|
||||||
'report_visible': True,
|
['state','=','pending'],
|
||||||
})
|
['manual','=',False],
|
||||||
#for dt in get_model("district").search_browse([]):
|
]
|
||||||
#name=(dt.name or "")[0:1]
|
visit_ids=get_model("clinic.visit").search(vdom)
|
||||||
#dt.write({
|
get_model("clinic.visit").delete(visit_ids)
|
||||||
#'sort_name': name,
|
|
||||||
#})
|
|
||||||
#for sdt in get_model("subdistrict").search_browse([]):
|
|
||||||
#name=(sdt.name or "")[0:1]
|
|
||||||
#sdt.write({
|
|
||||||
#'sort_name': name,
|
|
||||||
#})
|
|
||||||
print("Done!")
|
print("Done!")
|
||||||
|
|
||||||
def merge_staff(self,ids,context={}):
|
def merge_staff(self,ids,context={}):
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue