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