Skip to content
Snippets Groups Projects
Commit 078af4c4 authored by Benjami's avatar Benjami
Browse files

Added button in crm to create company :black_square_button:

parent 567727d1
No related branches found
No related tags found
2 merge requests!253[REL] Release 06/11/23,!191V1 imrpvements to CompanyEasyCreation wizard (CRM Lead execution)🙋‍
......@@ -36,6 +36,15 @@ class CrmLead(models.Model):
help="Community related to this Lead",
)
finished = fields.Boolean(
related="stage_id.is_won",
readonly=True,
)
company_hierarchy_level = fields.Selection(
related="company_id.hierarchy_level",
readonly=True,
)
def _create_map_place_proposal(self):
if not self.env.user.company_id.coordinator:
raise UserError(
......@@ -345,6 +354,21 @@ class CrmLead(models.Model):
"target": "new",
}
def action_create_community(self):
default_company_vals = {
'default_{}'.format(field): value
for field, value in self._get_default_community_wizard().items()
}
return {
'type': 'ir.actions.act_window',
'name': 'Create community',
'res_model': 'account.multicompany.easy.creation.wiz',
'view_mode': 'form',
'target': 'new',
'context': default_company_vals,
}
class CrmTags(models.Model):
_inherit = "crm.tag"
......
......@@ -14,7 +14,7 @@
<field name="search_view_id" ref="crm.view_crm_case_opportunities_filter" />
</record>
-->
<record id="ce_crm_lead_view_form" model="ir.ui.view">
<record id="ce_crm_lead_view_form" model="ir.ui.view">
<field name="name">ce.crm.lead.view.form</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_lead_view_form" />
......@@ -22,11 +22,21 @@
<xpath expr="//sheet" position="before">
<header>
<button
name="action_assign_crm_to_coordinator_company"
type="object"
string="Assing CRM to coordinator company"
groups="energy_communities.group_platform_manager"
/>
name="action_assign_crm_to_coordinator_company"
type="object"
string="Assing CRM to coordinator company"
groups="energy_communities.group_platform_manager"
/>
<field name="source_id" invisible="1"/>
<field name="finished" invisible="1"/>
<field name="company_hierarchy_level" invisible="1"/>
<button
name="action_create_community"
type="object"
string="Create community"
groups="energy_communities.group_admin"
attrs="{'invisible': ['|', '|', ('source_id', '!=', %(ce_source_creation_ce_proposal)d), ('finished', '=', False), ('company_hierarchy_level', '!=', 'coordinator')]}"
/>
</header>
</xpath>
</field>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment