Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
8366 Lượt xem

  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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

yes you have to use write() of active model

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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.


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 10 23
1603
3
thg 6 18
6925
2
thg 12 21
26211
1
thg 12 19
3510
0
thg 10 19
2838