diff --git a/netforce_clinic/migrations/__init__.py b/netforce_clinic/migrations/__init__.py index d5e40e0..5243c2e 100644 --- a/netforce_clinic/migrations/__init__.py +++ b/netforce_clinic/migrations/__init__.py @@ -15,4 +15,5 @@ from . import clinic_setting #from . import reimport10to15 #from . import add_missing_dlz # pending #from . import validate_cycle_item -from . import update_line_amount +#from . import update_line_amount +#from . import fix_tracking diff --git a/netforce_clinic/migrations/fix_tracking.py b/netforce_clinic/migrations/fix_tracking.py new file mode 100644 index 0000000..e16017e --- /dev/null +++ b/netforce_clinic/migrations/fix_tracking.py @@ -0,0 +1,30 @@ +import csv +import xlrd + +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.fix.tracking" + _version="2.12.5" + def migrate(self): + set_active_company(1) + set_active_user(1) + cond=[ + ['state','in',['waiting_payment','paid']], + ] + + for inv in get_model('account.invoice').search_browse(cond): + dpt=inv.department_id + branch=dpt.branch_id + track_id=branch_id.track_id.id + for line in inv.lines: + if line.track_id and line.track_id.id!=track_id: + line.write({ + 'track_id': track_id, + }) + print("update tracking %s ... "%(inv.number)) + +Migration.register() diff --git a/netforce_clinic/migrations/update_line_amount.py b/netforce_clinic/migrations/update_line_amount.py index f687788..0223247 100644 --- a/netforce_clinic/migrations/update_line_amount.py +++ b/netforce_clinic/migrations/update_line_amount.py @@ -9,7 +9,6 @@ from netforce.database import get_connection class Migration(migration.Migration): _name="clinic.update.line.amount" _version="2.12.5" - def migrate(self): set_active_company(1) set_active_user(1)