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.

25 lines
886 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright (C) 2017 - Today: GRAP (http://www.grap.coop)
  3. # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. import logging
  6. _logger = logging.getLogger(__name__)
  7. def _create_column(cr, table_name, column_name, column_type):
  8. _logger.info("Fast creation of the column %s.%s" % (
  9. table_name, column_name))
  10. req = "ALTER TABLE %s ADD COLUMN %s %s" % (
  11. table_name, column_name, column_type)
  12. cr.execute(req)
  13. def pre_init_hook(cr):
  14. _create_column(cr, 'pos_order_line', 'purchase_price', 'numeric')
  15. _create_column(cr, 'pos_order_line', 'margin', 'numeric')
  16. _create_column(cr, 'pos_order_line', 'margin_percent', 'numeric')
  17. _create_column(cr, 'pos_order', 'margin', 'numeric')
  18. _create_column(cr, 'pos_order', 'margin_percent', 'numeric')