Zada1100 Zada1100 - 1 year ago 177
Python Question

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.

# -*- 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)

def migration(self):
password = self.password



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

<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>
<field name="password"/>
<button string="Confirmer" type="object" name="migration"/>
<button string="Annuler" class="oe_highlight" special="cancel"/>

<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>

<menuitem action="action_siteweb_migration" id="menu_siteweb_migration" name="Migration du site"


Answer Source

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
def migration(self):
    password = self.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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download