def migrate(cr, version):

    # Rename lngth into packaging_length
    if column_exists(cr, "product_packaging", "packaging_length"):
        cr.execute("UPDATE product_packaging SET packaging_length = lngth")
    elif column_exists(cr, "product_packaging", "lngth"):
        rename_column(cr, "product_packaging", "lngth", "packaging_length")
示例#2
0
    def update_db_column(self, model, column):
        """ Create/update the column corresponding to ``self``.

            For creation of geo column

            :param model: an instance of the field's model
            :param column: the column's configuration (dict)
                           if it exists, or ``None``
        """
        # the column does not exist, create it

        if not column:
            create_geo_column(model._cr, model._table, self.name,
                              self.geo_type, self.srid, self.dim, self.string)
            return

        if column['udt_name'] == self.column_type[0]:
            return

        self.update_geo_db_column(model)

        if column['udt_name'] in self.column_cast_from:
            sql.convert_column(model._cr, model._table, self.name,
                               self.column_type[1])
        else:
            newname = (self.name + '_moved{}').format
            i = 0
            while sql.column_exists(model._cr, model._table, newname(i)):
                i += 1
            if column['is_nullable'] == 'NO':
                sql.drop_not_null(model._cr, model._table, self.name)
            sql.rename_column(model._cr, model._table, self.name, newname(i))
            sql.create_column(model._cr, model._table, self.name,
                              self.column_type[1], self.string)
def migrate(cr, version):
    # Rename estimated_pack_weight into estimated_pack_weight_kg
    if column_exists(cr, "stock_quant_package", "estimated_pack_weight"):
        rename_column(
            cr,
            "stock_quant_package",
            "estimated_pack_weight",
            "estimated_pack_weight_kg",
        )
示例#4
0
def migrate(cr, version):
    # Rename lnght into packaging_length
    if column_exists(cr, "product_packaging", "lnght"):
        rename_column(cr, "product_packaging", "lnght", "packaging_length")

        # Convert old hard-coded uom values (mm)
        # into new default uom values (m)
        cr.execute(
            """
        UPDATE product_packaging
        SET
        packaging_length = packaging_length/1000,
        height = height/1000,
        width = width/1000,
        """
        )
def migrate(cr, version):
    sql.rename_column(cr, "res_partner", "auto_archive", "auto_archive_spread")
def migrate(cr, version):
    if column_exists(cr, "res_partner", "state"):
        if column_exists(cr, "res_partner", "old_state"):
            cr.execute("ALTER TABLE res_partner DROP COLUMN old_state")
        rename_column(cr, "res_partner", "state", "old_state")
示例#7
0
def migrate(cr, version):
    if column_exists(cr, "delay_export", "user_id"):
        rename_column(cr, "delay_export", "user_id", "__temp_user_id")
示例#8
0
def migrate(cr, version):
    if column_exists(cr, "res_partner", "shopinvader_enabled"):
        rename_column(cr, "res_partner", "shopinvader_enabled",
                      "is_shopinvader_active")
示例#9
0
def migrate(cr, version):
    if column_exists(cr, "res_partner", "commerce_enabled"):
        rename_column(cr, "res_partner", "commerce_enabled",
                      "is_commerce_active")
示例#10
0
def rename_amt_to_invoice(cr):
    if (not sql.column_exists(cr, 'sale_order_line', 'risk_amount') and
            sql.column_exists(cr, 'sale_order_line', 'amt_to_invoice')):
        sql.rename_column(
            cr, 'sale_order_line', 'amt_to_invoice', 'risk_amount')