Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
2571 Widoki

In detail:

I have added 2 buttons Active and inactive in the form view. When i click active button the opportunity should move to Active column in kamban view. Same as when i click Inactive the opportunity should move to the inactive column in kamban view. Please help me to write the python code for the buttons.

button view:


kamban view:



Many thanks.

Awatar
Odrzuć
Najlepsza odpowiedź

You can do that as below :


Python code:


from odoo import models
class Lead(models.Model):
_inherit = "crm.lead"

def action_set_active(self):
self.stage_id = self._stage_find(domain=[('name', '=', 'Active')]).id

def action_set_inactive(self):
self.stage_id = self._stage_find(domain=[('name', '=', 'Inactive')]).id


Inherited CRM Form view:


<record id="crm_lead_view_form_update" model="ir.ui.view">
<field name="name">crm.lead.view.form.inherit.update</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_lead_view_form"/>
<field name="arch" type="xml">
<xpath expr="//header" position="inside">
<button name="action_set_active" string="Active" type="object" class="oe_highlight" />
<button name="action_set_inactive" string="Inactive" type="object" class="oe_highlight" />
</xpath>
</field>
</record>

Awatar
Odrzuć
Autor

Hi, I am facing this error:
forbidden opcode(s) in 'from odoo import models\r\n\r\nclass Lead(models.Model):\r\n _inherit = "crm.lead"\r\n\r\n def action_set_active(self):\r\n self.stage_id = self._stage_find(domain=[(\'name\', \'=\', \'Active\')]).id': IMPORT_NAME, IMPORT_FROM, LOAD_BUILD_CLASS

Hi, I have an issue in my provided code and I updated the code above and tested it in my local and its working. Could you please try it?

Autor

Hi Waleed Mohsen, I am facing this error :
forbidden opcode(s) in 'lambda': STORE_ATTR
I have pasted exactly your code in the active button(server action) but I am facing this. Kindly help

Powiązane posty Odpowiedzi Widoki Czynność
1
lis 22
3200
2
sie 22
3022
2
maj 22
2449
1
mar 22
2580
1
cze 24
3201