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

```

in xml

<button name="action_pass_value" type="object" string="Process Adjustment" class="oe_highlight" states="paid" attrs="{'invisible': ['|', ('state', '!=', 'paid'), ('is_adjusted_done', '=',True)]}"/>

in py

def action_pass_value(self): 

 return 

{ 'name': self.name, 'res_model': 'invoice.process.adjustment',

 'type': 'ir.actions.act_window',

 'context': {'current_id': self.id}, 

 'view_mode': 'form', 

 'view_type': 'form',

 'target': 'new', }


```

```

in Wizard

class InvoiceProcessAdjustment(models.TransientModel): 

 _name = 'invoice.process.adjustment'

act_id = fields.Integer(string='ID', default=lambda self: self._get_default_id())

@api.one 

 def _get_default_id(self): 

 if self.env.context.get('current_id'): 

 return self.env.context.get('current_id')


```

in wizard i can't get current_id value where i'm wrong pls correct me 





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

Hi,

What you can do is that the refer the working of the Mark as Lost button in the CRM Leads form view, on the button click the wizard will get opened and the lead_id is passed in the context and received in the wizard. Please have a look at it and see how it is done.


Also you can check whether the self.env.context.get('active_ids') can give you the id of the original record.


Thanks


Ảnh đại diện
Huỷ bỏ
Tác giả

you solution all time simple and out of the box .... :-)

:) and seems other answer is marked as resolved

Câu trả lời hay nhất

Hello,

Add context in button like below:

​<button name="action_pass_value"  type="object" string="Process Adjustment" class="oe_highlight" states="paid" attrs="{'invisible': ['|', ('state', '!=', 'paid'), ('is_adjusted_done', '=',True)]}" context="
context.get('current_id')"/>

Ảnh đại diện
Huỷ bỏ
Tác giả

no result

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 9 20
6023
1
thg 9 19
6502
0
thg 8 17
3342
0
thg 3 15
4388
1
thg 2 24
2955