Odoo Help

0

How to save the values of fields ?

By
karim bryant
on 9/13/18, 11:29 AM 82 views

  hello, I would like to save the changes in the wizard. When I change the date of my wizard and validate, the dates do not change. What i put in my wizard.py ?

xml wizard :

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

        <record id="change_date_expense_sheet_form" model="ir.ui.view">
            <field name="name">Change date expense sheet</field>
            <field name="model">edit.date.expense.sheet.wizard</field>
            <field name="priority">1</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Change Date Expense Sheet">
                  <sheet>
                      <group >
                          <field name="validation_date"/>
                      </group>
                    </sheet>
                  <footer>
                      <button string="Validate" class="oe_highlight" type="object" name="validate_modifications"/>
                      <button string="Cancel" special="cancel"/>
                  </footer>
                </form>
            </field>
        </record>

        <record id="change_expense_sheet_action" model="ir.actions.act_window">
            <field name="name">Change Date Expense Sheet</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">edit.date.expense.sheet.wizard</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="rp_hr.change_date_expense_sheet_form"/>
            <field name="view_mode">form</field>
            <field name="target">new</field>
        </record>

    </data>
</odoo>
                                                                                        

python :

# -*- coding: utf-8 -*-
from odoo import models, fields, api, _


class EditDateExpenseSheetWizard(models.TransientModel):
    _name = 'edit.date.expense.sheet.wizard'

    validation_date = fields.Date(string="New validation date")

    @api.multi
    def validate_modifications(self):
        self.ensure_one()
        print "validate_modifications"

        return {'type': 'ir.actions.act_window.close'}

                                                                                        



Tanks a lot.

0
Sushma
On 9/14/18, 10:47 AM

Hi Karim,

I didn't get much your query, but if in case you want to show any default date value to wizard validation_date field you can use default.

Although please go through below points regarding wizards:

1. Wizards describe interactive sessions with the user (or dialog boxes) through dynamic forms. A wizard is simply a model that extends the class TransientModel instead of Model. The class TransientModel extends Model and reuse all its existing mechanisms, with the following particularities:

2. Wizard records are not meant to be persistent; they are automatically deleted from the database after a certain time. This is why they are called transient.

3. Wizard models do not require explicit access rights: users have all permissions on wizard records.

4. Wizard records may refer to regular records or wizard records through many2one fields, but regular records cannot refer to wizard records through a many2one field.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 9/13/18, 11:29 AM
Seen: 82 times
Last updated: 9/14/18, 10:47 AM