From 210ddcc5a85941e5c7ed527b997df5bba42f41c0 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Wed, 21 Oct 2015 11:28:27 +0700 Subject: [PATCH] migrate picking --- netforce_clinic/layouts/clinic_setting.xml | 5 +-- netforce_clinic/migrations/__init__.py | 3 +- netforce_clinic/migrations/restore_picking.py | 33 +++++++++++++++++++ netforce_clinic/models/dialyzer.py | 2 +- netforce_clinic/models/hd_case.py | 12 +------ netforce_clinic/models/setting.py | 3 +- 6 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 netforce_clinic/migrations/restore_picking.py diff --git a/netforce_clinic/layouts/clinic_setting.xml b/netforce_clinic/layouts/clinic_setting.xml index cd4bf92..b683086 100644 --- a/netforce_clinic/layouts/clinic_setting.xml +++ b/netforce_clinic/layouts/clinic_setting.xml @@ -9,8 +9,9 @@ - - + + + diff --git a/netforce_clinic/migrations/__init__.py b/netforce_clinic/migrations/__init__.py index 24348b7..8bbdb6c 100644 --- a/netforce_clinic/migrations/__init__.py +++ b/netforce_clinic/migrations/__init__.py @@ -3,4 +3,5 @@ #from . import conv_bal #from . import tb_ap_import #from . import check_seq -from . import del_gi +#from . import del_gi +from . import restore_picking diff --git a/netforce_clinic/migrations/restore_picking.py b/netforce_clinic/migrations/restore_picking.py new file mode 100644 index 0000000..e1852a8 --- /dev/null +++ b/netforce_clinic/migrations/restore_picking.py @@ -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() diff --git a/netforce_clinic/models/dialyzer.py b/netforce_clinic/models/dialyzer.py index a70dad1..ac97b11 100644 --- a/netforce_clinic/models/dialyzer.py +++ b/netforce_clinic/models/dialyzer.py @@ -117,7 +117,7 @@ class Dialyzer(Model): st=get_model("clinic.setting").browse(1) stock_journal=st.stock_journal_id - if st.picking_auto: + if st.dlz_picking_auto: wh_loc_id=None cust_loc_id=None department=obj.department_id diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index d428623..954f2dc 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -758,14 +758,11 @@ class HDCase(Model): def make_pickings(self,ids,context={}): st=get_model('clinic.setting').browse(1) - if not st.picking_auto: + if not st.hdcase_picking_auto: return - obj=self.browse(ids[0]) - # no picking if not obj.lines: return - patient=obj.patient_id partner=patient.partner_id if not partner: @@ -777,7 +774,6 @@ class HDCase(Model): break if not ship_address_id: patient.simple_address() - #raise Exception("contact %s dont'have address with type shipping"%partner.name) # default journal cust_loc_id=None wh_loc_id=None @@ -789,7 +785,6 @@ class HDCase(Model): 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)) pick_vals={ "type": "out", 'journal_id': stock_journal.id, @@ -806,8 +801,6 @@ class HDCase(Model): if not res: raise Exception("Customer location not found") cust_loc_id=res[0] - - #XXX no_lines=context.get('no_line') or False if no_lines: 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: continue prod_exist_ids.append(prod.id) - #XXX dpt_prods=get_model('clinic.department.product').get_location(obj.department_id.id,prod.id) if dpt_prods: - print("get location from menu department products") wh_loc_id=dpt_prods.get('wh_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: wh_loc_id=prod.location_id.id if wh_loc_id: diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py index 9236b17..9a542d0 100644 --- a/netforce_clinic/models/setting.py +++ b/netforce_clinic/models/setting.py @@ -64,7 +64,8 @@ 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"), + 'hdcase_picking_auto': fields.Boolean("HDCase Auto Picking"), + 'dlz_picking_auto': fields.Boolean("DLZ Auto Picking"), } _defaults={