Advertisement
Guest User

Untitled

a guest
Jan 21st, 2021
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1.         pool = Pool()
  2.         PackageType = pool.get('stock.package.type')
  3.         cursor = Transaction().connection.cursor()
  4.         sql_table = cls.__table__()
  5.         package_type = PackageType.__table__()
  6.         table = cls.__table_handler__(module_name)
  7.         dimension_columns = ['length', 'length_uom', 'height', 'height_uom',
  8.                     'width', 'width_uom']
  9.         dimension_exists = any(
  10.             table.column_exist('length') for c in dimension_columns)
  11.  
  12.         super().__register__(module_name)
  13.  
  14.         # Migration from 5.8: Update dimensions on package from package_type
  15.         if not dimension_exists:
  16.             cursor.execute(*sql_table.update(
  17.                 columns=[Column(sql_table, c) for c in dimension_columns],
  18.                 values=package_type.select(
  19.                     *[Column(package_type, c) for c in dimension_columns],
  20.                     where=package_type.id == sql_table.type)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement