You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
799 B

  1. # Copyright (C) 2018 - Today: GRAP (http://www.grap.coop)
  2. # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. import logging
  5. _logger = logging.getLogger(__name__)
  6. def _create_column(cr, table_name, column_name, column_type):
  7. # pylint: disable=sql-injection
  8. req = "ALTER TABLE %s ADD COLUMN %s %s" % (
  9. table_name, column_name, column_type)
  10. cr.execute(req)
  11. def pre_init_hook(cr):
  12. _logger.info(
  13. "Compute stock_picking.partner_name for existing pickings")
  14. _create_column(cr, 'stock_picking', 'partner_name', 'VARCHAR')
  15. cr.execute("""
  16. UPDATE stock_picking sp
  17. SET partner_name = rp.name
  18. FROM res_partner rp
  19. WHERE sp.partner_id = rp.id;
  20. """)