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()