This question has been flagged
4 Replies
6540 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.

Avatar
Discard
Best Answer

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.

Avatar
Discard
Best Answer

yes you have to use write() of active model

Avatar
Discard
Author Best Answer

Tanks for your reply. It's not i want but it's cool. I understand default value in field.

I wanted is to save values in my database. It's fixed just with write.


Avatar
Discard