تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
6691 أدوات العرض
Hello
I want to doisthe following

1. Aformis filled
2.when clickingon the "done" buttonanda dialog boxappears with twofields of the sameform
3.fills andclick onaccept thedialog
4.changes the status of"draft"to"done"
5.the two fieldson the form


my questionsis

1. the contextto pass dataused inthe actionorthe button
asseriouscontext

2.
aswould defineinpythonmove from"drafta" done "

Thank you


<header>
    <button name="%(action_done)d" type="action"
  string="done"
attrs="{'invisible': [('state','=', 'done')]}"
class="oe_highlight"/>
</header>
<sheet>
<field name="name"/>
<field name="field 1" attrs="{'invisible': ['!', ('state', '=', 'done')]}"/>
<field name="field 2" attrs="{'invisible': ['!', ('state', '=', 'done')]}""/>
</sheet>



          <field name="arch" type="xml">
<form>
<group class="oe_title">
<field name="field 1"/>
<field name="field 2"/>
</group>
<footer>
<button name="action_done" string="done" type="object" class="btn btn-sm btn-primary"/>
<button string="Cancel" class="btn btn-sm btn-default" special="cancel"/>
</footer>
</form>
</field>
 

    <record id="action_done" model="ir.actions.act_window">
<field name="name">done</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">model.model</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_model_done_form"/>
<field name="target">new</field>
    </record>

 

الصورة الرمزية
إهمال
أفضل إجابة

I believe you cannot do in this way.


First of all, in your "action_done", it does not have a res_id reference. To would meant that when you open up the form, the form does not know which record in the model to reference to and hence, your popup form will be empty.


What you can do is instead of using "%(action_done)d", you could create a method in your model.


@api.multi
def action_done(self):
 id = self.id
   return {
'name': self.name,
'res_model': 'module.Model',
'type': 'ir.actions.act_window',
'context': {},
'view_mode': 'form',
'view_type': 'form',
      'view_id': self.env.ref('module.my_form_view'),
'target': 'current',
}


and change your button to

<button name="action_done" type="object" .. />



الصورة الرمزية
إهمال
الكاتب أفضل إجابة

Thanks,

it worked

@api.multi
def action_done(self):
return {
'name': self.name,
'res_model': 'calendar.event',
'type': 'ir.actions.act_window',
'res_id': self.id,
'context': {},
'view_type': 'form',
'view_mode': 'form',
'views': [(self.env.ref('ceiinc_crm.view_calendar_event_done_form').id, 'form')],
'view_id': self.env.ref('ceiinc_crm.view_calendar_event_done_form').id,
'target': 'new',
الصورة الرمزية
إهمال