migrate picking

production
watcha.h 2015-10-21 11:28:27 +07:00
parent dbf0d685c3
commit 210ddcc5a8
6 changed files with 42 additions and 16 deletions

View File

@ -9,8 +9,9 @@
</head> </head>
<separator string="Visit"/> <separator string="Visit"/>
<group form_layout="stacked"> <group form_layout="stacked">
<field name="find_dlz"/> <field name="find_dlz" span="3"/>
<field name="picking_auto"/> <field name="hdcase_picking_auto" span="3"/>
<field name="dlz_picking_auto" span="3"/>
</group> </group>
<separator string="HD Case"/> <separator string="HD Case"/>
<group form_layout="stacked"> <group form_layout="stacked">

View File

@ -3,4 +3,5 @@
#from . import conv_bal #from . import conv_bal
#from . import tb_ap_import #from . import tb_ap_import
#from . import check_seq #from . import check_seq
from . import del_gi #from . import del_gi
from . import restore_picking

View File

@ -0,0 +1,33 @@
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.restore.picking"
_version="2.12.1"
def migrate(self):
set_active_user(1)
set_active_company(1)
#remove all good issued from dlz
total_del=0
for dlz in get_model('clinic.dialyzer').search_browse([]):
for pick in dlz.pickings:
print('del pick ',pick.number)
pick.delete()
total_del+=1
print('total delete ', total_del)
fmt='%Y-%m-%d %H:%M:%S'
datenow=time.strftime(fmt)
dom=[
['date','>=','2015-01-01'],
['date','<=',datenow],
]
for hdcase in get_model("clinic.hd.case").search_browse(dom):
if not hdcase.pickings:
print('gen picking for %s in %s'%(hdcase.number, hdcase.date))
hdcase.make_pickings()
Migration.register()

View File

@ -117,7 +117,7 @@ class Dialyzer(Model):
st=get_model("clinic.setting").browse(1) st=get_model("clinic.setting").browse(1)
stock_journal=st.stock_journal_id stock_journal=st.stock_journal_id
if st.picking_auto: if st.dlz_picking_auto:
wh_loc_id=None wh_loc_id=None
cust_loc_id=None cust_loc_id=None
department=obj.department_id department=obj.department_id

View File

@ -758,14 +758,11 @@ class HDCase(Model):
def make_pickings(self,ids,context={}): def make_pickings(self,ids,context={}):
st=get_model('clinic.setting').browse(1) st=get_model('clinic.setting').browse(1)
if not st.picking_auto: if not st.hdcase_picking_auto:
return return
obj=self.browse(ids[0]) obj=self.browse(ids[0])
# no picking
if not obj.lines: if not obj.lines:
return return
patient=obj.patient_id patient=obj.patient_id
partner=patient.partner_id partner=patient.partner_id
if not partner: if not partner:
@ -777,7 +774,6 @@ class HDCase(Model):
break break
if not ship_address_id: if not ship_address_id:
patient.simple_address() patient.simple_address()
#raise Exception("contact %s dont'have address with type shipping"%partner.name)
# default journal # default journal
cust_loc_id=None cust_loc_id=None
wh_loc_id=None wh_loc_id=None
@ -789,7 +785,6 @@ class HDCase(Model):
if stock_journal: if stock_journal:
wh_loc_id=stock_journal.location_from_id.id wh_loc_id=stock_journal.location_from_id.id
cust_loc_id=stock_journal.location_to_id.id cust_loc_id=stock_journal.location_to_id.id
print("get location from stock journal %s "%(stock_journal.name))
pick_vals={ pick_vals={
"type": "out", "type": "out",
'journal_id': stock_journal.id, 'journal_id': stock_journal.id,
@ -806,8 +801,6 @@ class HDCase(Model):
if not res: if not res:
raise Exception("Customer location not found") raise Exception("Customer location not found")
cust_loc_id=res[0] cust_loc_id=res[0]
#XXX
no_lines=context.get('no_line') or False no_lines=context.get('no_line') or False
if no_lines: if no_lines:
return return
@ -832,13 +825,10 @@ class HDCase(Model):
if prod_ids and prod.id not in prod_ids or prod.id in prod_exist_ids: if prod_ids and prod.id not in prod_ids or prod.id in prod_exist_ids:
continue continue
prod_exist_ids.append(prod.id) prod_exist_ids.append(prod.id)
#XXX
dpt_prods=get_model('clinic.department.product').get_location(obj.department_id.id,prod.id) dpt_prods=get_model('clinic.department.product').get_location(obj.department_id.id,prod.id)
if dpt_prods: if dpt_prods:
print("get location from menu department products")
wh_loc_id=dpt_prods.get('wh_loc_id') wh_loc_id=dpt_prods.get('wh_loc_id')
cust_loc_id=dpt_prods.get('cust_loc_id') cust_loc_id=dpt_prods.get('cust_loc_id')
#pick_vals['journal_id']=dpt_prods.get('journal_id')
if not wh_loc_id: if not wh_loc_id:
wh_loc_id=prod.location_id.id wh_loc_id=prod.location_id.id
if wh_loc_id: if wh_loc_id:

View File

@ -64,7 +64,8 @@ class ClinicSetting(Model):
'staff_from_id': fields.Many2One("clinic.staff","Staff From"), 'staff_from_id': fields.Many2One("clinic.staff","Staff From"),
'staff_to_id': fields.Many2One("clinic.staff","Staff To"), 'staff_to_id': fields.Many2One("clinic.staff","Staff To"),
'product_categ_view': fields.Many2Many("product.categ","Product Category View"), 'product_categ_view': fields.Many2Many("product.categ","Product Category View"),
'picking_auto': fields.Boolean("Picking Auto"), 'hdcase_picking_auto': fields.Boolean("HDCase Auto Picking"),
'dlz_picking_auto': fields.Boolean("DLZ Auto Picking"),
} }
_defaults={ _defaults={