prevent do gen picking from hdcase and dlz
parent
c31cd0ce8d
commit
4326614a04
|
@ -10,6 +10,7 @@
|
|||
<separator string="Visit"/>
|
||||
<group form_layout="stacked">
|
||||
<field name="find_dlz"/>
|
||||
<field name="picking_auto"/>
|
||||
</group>
|
||||
<separator string="HD Case"/>
|
||||
<group form_layout="stacked">
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
#from . import repost_invoice
|
||||
#from . import conv_bal
|
||||
#from . import tb_ap_import
|
||||
from . import check_seq
|
||||
#from . import check_seq
|
||||
from . import del_gi
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
import time
|
||||
|
||||
from netforce.model import get_model
|
||||
from netforce import migration
|
||||
from netforce.access import set_active_user, set_active_company
|
||||
|
||||
class Migration(migration.Migration):
|
||||
_name="clinic.del.gi"
|
||||
_version="2.12.0"
|
||||
|
||||
def migrate(self):
|
||||
set_active_user(1)
|
||||
set_active_company(1)
|
||||
#fmt='%Y-%m-%d %H:%M:%S'
|
||||
#datenow=time.strftime(fmt)
|
||||
dom=[
|
||||
['date','>=','2015-01-01 00:00:00'],
|
||||
['date','<=','2015-06-30 23:59:59'],
|
||||
['type','=','out'],
|
||||
]
|
||||
count=0
|
||||
for pick in get_model('stock.picking').search_browse(dom):
|
||||
print('del ', pick.date, pick.id, pick.number)
|
||||
pick.delete()
|
||||
count+=1
|
||||
|
||||
print("Delete From 2015-01-01 to 2015-06-30 Total is: ", count)
|
||||
|
||||
rows=open("/tmp/del_gi.csv","r").read()
|
||||
ids=[]
|
||||
for row in rows.split("\n"):
|
||||
try:
|
||||
r=row.split(",")
|
||||
idtxt=r[1]
|
||||
if idtxt.isnumeric():
|
||||
ids.append(int(idtxt))
|
||||
except Exception as e:
|
||||
print("ERROR ", e)
|
||||
count=0
|
||||
for id in ids:
|
||||
pick=get_model('stock.picking').browse(id)
|
||||
try:
|
||||
print('del ', pick.date, pick.id, pick.number)
|
||||
pick.delete()
|
||||
except Exception as e:
|
||||
print("ERROR ",e)
|
||||
count+=1
|
||||
print("Delete from file Total: ",count)
|
||||
|
||||
Migration.register()
|
|
@ -117,63 +117,64 @@ class Dialyzer(Model):
|
|||
st=get_model("clinic.setting").browse(1)
|
||||
stock_journal=st.stock_journal_id
|
||||
|
||||
wh_loc_id=None
|
||||
cust_loc_id=None
|
||||
department=obj.department_id
|
||||
if department:
|
||||
stock_journal=department.pick_out_journal_id
|
||||
if stock_journal:
|
||||
wh_loc_id=stock_journal.location_from_id.id
|
||||
cust_loc_id=stock_journal.location_to_id.id
|
||||
print("get location from stock journal %s "%(stock_journal.name))
|
||||
if st.picking_auto:
|
||||
wh_loc_id=None
|
||||
cust_loc_id=None
|
||||
department=obj.department_id
|
||||
if department:
|
||||
stock_journal=department.pick_out_journal_id
|
||||
if stock_journal:
|
||||
wh_loc_id=stock_journal.location_from_id.id
|
||||
cust_loc_id=stock_journal.location_to_id.id
|
||||
print("get location from stock journal %s "%(stock_journal.name))
|
||||
|
||||
if not stock_journal:
|
||||
raise Exception("Not found stock journal")
|
||||
if not stock_journal:
|
||||
raise Exception("Not found stock journal")
|
||||
pick_vals={
|
||||
"type": "out",
|
||||
'journal_id': stock_journal.id,
|
||||
'date': obj.date,
|
||||
"ref": obj.number,
|
||||
"related_id": "clinic.dialyzer,%s"%obj.id,
|
||||
"partner_id": obj.patient_id.partner_id.id,
|
||||
"ship_address_id": ship_address_id,
|
||||
"lines": [],
|
||||
"state": "draft",
|
||||
}
|
||||
|
||||
pick_vals={
|
||||
"type": "out",
|
||||
'journal_id': stock_journal.id,
|
||||
'date': obj.date,
|
||||
"ref": obj.number,
|
||||
"related_id": "clinic.dialyzer,%s"%obj.id,
|
||||
"partner_id": obj.patient_id.partner_id.id,
|
||||
"ship_address_id": ship_address_id,
|
||||
"lines": [],
|
||||
"state": "draft",
|
||||
}
|
||||
|
||||
if not cust_loc_id:
|
||||
res=get_model("stock.location").search([["type","=","customer"]])
|
||||
if not res:
|
||||
raise Exception("Customer location not found")
|
||||
cust_loc_id=res[0]
|
||||
|
||||
prod=obj.product_id
|
||||
if not wh_loc_id:
|
||||
wh_loc_id=prod.location_id.id # product -> tab inventory -> warehouse filed
|
||||
if not wh_loc_id:
|
||||
res=get_model("stock.location").search([["type","=","internal"]])
|
||||
if not cust_loc_id:
|
||||
res=get_model("stock.location").search([["type","=","customer"]])
|
||||
if not res:
|
||||
raise Exception("Warehouse not found")
|
||||
wh_loc_id=res[0]
|
||||
raise Exception("Customer location not found")
|
||||
cust_loc_id=res[0]
|
||||
|
||||
prod=obj.product_id
|
||||
if not wh_loc_id:
|
||||
wh_loc_id=prod.location_id.id # product -> tab inventory -> warehouse filed
|
||||
if not wh_loc_id:
|
||||
res=get_model("stock.location").search([["type","=","internal"]])
|
||||
if not res:
|
||||
raise Exception("Warehouse not found")
|
||||
wh_loc_id=res[0]
|
||||
|
||||
if prod.type=='stock':
|
||||
line_vals={
|
||||
"product_id": prod.id,
|
||||
"qty": 1,
|
||||
"uom_id": prod.uom_id.id,
|
||||
"location_from_id": wh_loc_id,
|
||||
"location_to_id": cust_loc_id,
|
||||
}
|
||||
pick_vals["lines"].append(("create",line_vals))
|
||||
picking_obj=get_model("stock.picking")
|
||||
context={
|
||||
'pick_type': 'out',
|
||||
'journal_id': pick_vals['journal_id'],
|
||||
}
|
||||
pick_id=picking_obj.create(pick_vals,context=context)
|
||||
pick=picking_obj.browse(pick_id)
|
||||
pick.set_done([pick_id])
|
||||
|
||||
if prod.type=='stock':
|
||||
line_vals={
|
||||
"product_id": prod.id,
|
||||
"qty": 1,
|
||||
"uom_id": prod.uom_id.id,
|
||||
"location_from_id": wh_loc_id,
|
||||
"location_to_id": cust_loc_id,
|
||||
}
|
||||
pick_vals["lines"].append(("create",line_vals))
|
||||
picking_obj=get_model("stock.picking")
|
||||
context={
|
||||
'pick_type': 'out',
|
||||
'journal_id': pick_vals['journal_id'],
|
||||
}
|
||||
pick_id=picking_obj.create(pick_vals,context=context)
|
||||
pick=picking_obj.browse(pick_id)
|
||||
pick.set_done([pick_id])
|
||||
number=obj.number.replace("/","")
|
||||
if not number:
|
||||
department=obj.department_id
|
||||
|
|
|
@ -757,6 +757,10 @@ class HDCase(Model):
|
|||
})
|
||||
|
||||
def make_pickings(self,ids,context={}):
|
||||
st=get_model('clinic.setting').browse(1)
|
||||
if not st.picking_auto:
|
||||
return
|
||||
|
||||
obj=self.browse(ids[0])
|
||||
# no picking
|
||||
if not obj.lines:
|
||||
|
|
|
@ -64,6 +64,7 @@ class ClinicSetting(Model):
|
|||
'staff_from_id': fields.Many2One("clinic.staff","Staff From"),
|
||||
'staff_to_id': fields.Many2One("clinic.staff","Staff To"),
|
||||
'product_categ_view': fields.Many2Many("product.categ","Product Category View"),
|
||||
'picking_auto': fields.Boolean("Picking Auto"),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
|
|
|
@ -86,6 +86,7 @@ class VisitBoard(Model):
|
|||
defaults=self.default_get(context=context)
|
||||
department_id=defaults.get("department_id",None)
|
||||
branch_id=defaults.get("branch_id",None)
|
||||
context['branch_id']=branch_id
|
||||
state=defaults.get("state",'pending')
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
|
@ -96,6 +97,7 @@ class VisitBoard(Model):
|
|||
doctor_id=obj.doctor_id.id
|
||||
department_id=obj.department_id.id
|
||||
branch_id=obj.branch_id.id
|
||||
context['branch_id']=branch_id
|
||||
state=obj.state
|
||||
# auto generate visit day to day
|
||||
def auto_gen_visit(dom=[]):
|
||||
|
@ -147,7 +149,7 @@ class VisitBoard(Model):
|
|||
'visit_date': date_txt,
|
||||
'state': 'pending',
|
||||
}
|
||||
visit_id=get_model("clinic.visit").create(vals)
|
||||
visit_id=get_model("clinic.visit").create(vals,context=context)
|
||||
print('create new visit %s for %s'%(visit_id,pt.name))
|
||||
time_start='%s 00:00:00'%(date_from)
|
||||
time_stop='%s 23:59:59'%(date_to)
|
||||
|
|
Loading…
Reference in New Issue