From b9f8fbdd4695955398287565e9b6086f2f158055 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Wed, 24 Feb 2016 17:49:42 +0700 Subject: [PATCH] pass branch_id to get the right number of GI --- netforce_clinic/layouts/clinic_prod_form.xml | 4 +-- netforce_clinic/migrations/__init__.py | 5 ++-- .../migrations/update_pick_out_number.py | 29 +++++++++++++++++++ netforce_clinic/models/hd_case.py | 3 +- 4 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 netforce_clinic/migrations/update_pick_out_number.py diff --git a/netforce_clinic/layouts/clinic_prod_form.xml b/netforce_clinic/layouts/clinic_prod_form.xml index 01800df..9cc9294 100644 --- a/netforce_clinic/layouts/clinic_prod_form.xml +++ b/netforce_clinic/layouts/clinic_prod_form.xml @@ -14,8 +14,8 @@ - - + + diff --git a/netforce_clinic/migrations/__init__.py b/netforce_clinic/migrations/__init__.py index 7d09b35..ab2e437 100644 --- a/netforce_clinic/migrations/__init__.py +++ b/netforce_clinic/migrations/__init__.py @@ -7,5 +7,6 @@ #from . import restore_picking #from . import rename_dbl_hdcase_number #from . import reset_hdcase_number -from . import remove_dbl_contact -from . import update_invoice +#from . import remove_dbl_contact +#from . import update_invoice +from . import update_pick_out_number diff --git a/netforce_clinic/migrations/update_pick_out_number.py b/netforce_clinic/migrations/update_pick_out_number.py new file mode 100644 index 0000000..c954cea --- /dev/null +++ b/netforce_clinic/migrations/update_pick_out_number.py @@ -0,0 +1,29 @@ +from netforce.model import get_model +from netforce import migration +from netforce.access import set_active_user, set_active_company +from netforce.database import get_connection + +class Migration(migration.Migration): + _name="clinic.update.pick.out.number" + _version="2.12.5" + + def migrate(self): + set_active_company(1) + set_active_user(1) + db=get_connection() + count=0 + for pick in get_model('stock.picking').search_browse([]): + journal=pick.journal_id + sequence=journal.sequence_id + branch=sequence.branch_id + prefix=sequence.prefix + if prefix not in pick.number: + new_number=pick.number.replace(pick.number[0:6],prefix) + pick.write({ + 'number': new_number, + }) + count+=1 + print("update %s to %s"%(pick.number, new_number)) + print("total ", count) + +Migration.register() diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 71228f2..0c6b9f5 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -866,7 +866,8 @@ class HDCase(Model): context={ 'pick_type': 'out', 'journal_id': pick_vals['journal_id'], - 'date': obj.date + 'date': obj.date, + 'branch_id': obj.branch_id.id, } pick_id=picking_obj.create(pick_vals,context=context) pick=picking_obj.browse(pick_id)