Zada1100
Zada1100

Reputation: 41

Odoo 8 store=False not working

I'm creating a simple form that you have to enter a password so the action can be executed but I can't figure out how not to store the password in the database. When I put store=False my module doesn't compile. Also I would like to know if there's a way to hide the password while the user is writing it.

The best would be to not create any table in the database but I need to create a model cause I have a button that call a method. I don't know if there's a way to avoid creating a table.

siteweb_migration_wizard.py

# -*- coding: utf-8 -*-

from openerp import models, fields, api, tools

class SitewebMigrationWizard(models.TransientModel):
    _name = 'siteweb.migration'

    password = fields.Char(string="Mot de passe", store=False)


    @api.multi
    def migration(self):
        password = self.password

        print(password)

siteweb_migration_wizard.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

        <record model="ir.ui.view" id="siteweb_migration_wizard_form">
            <field name="name">siteweb.migration.form</field>
            <field name="model">siteweb.migration</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Migrer" version="8.0">
                    <p>Voulez-vous vraiment migrer vers la BD du site?</p>
                    <group>
                        <field name="password"/>
                    </group>
                    <button string="Confirmer" type="object" name="migration"/>
                    <button string="Annuler" class="oe_highlight" special="cancel"/>
                </form>
            </field>
        </record>

        <record id="action_siteweb_migration" model="ir.actions.act_window">
            <field name="name">Migration du site</field>
            <field name="res_model">siteweb.migration</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="siteweb_migration_wizard_form"/>
            <field name="multi">True</field>
            <field name="target">new</field>
        </record>

        <menuitem action="action_siteweb_migration" id="menu_siteweb_migration" name="Migration du site"
                  parent="siteweb_createch.menu_siteweb"/>

    </data>
</openerp>

Upvotes: 0

Views: 472

Answers (2)

Jxckxx
Jxckxx

Reputation: 1

you can just simple use the PASSWORD since you have declared it as var name of self.password. SO: password = False

Upvotes: 0

JordyRitzen
JordyRitzen

Reputation: 702

Some points to keep in mind

  • "store" is a parameter for calculated fields. It defines if it should calculate the value each time you open the record or calculate it only when it's edited.
  • After you've hit the confirm button it saves the current data. I'd suggest that you'd set the password to False in the migration method
@api.multi
def migration(self):
    password = self.password
    print(password)
    self.password = False
  • Even when it's stored it's not stored for long. The scheduler for cleaning Transient models will delete the record after a while

Upvotes: 1

Related Questions