Skip to Content
Menu
This question has been flagged
2694 Views

Hello, 

I'm new here, we all know that we can customize pipeline by sales team, in my case in order to create Pipelines under Pipeline I  created  a new  menuitem with four pipelines, now I want  when I click on "Pipeline" button the systems refers me to customized fields for each pipe (just like the system of sales team).

Code:

from odoo import models, fields, api
from odoo.tools.safe_eval import safe_eval

class Add_new_pipe(models.Model):
_name = 'pipe.new'

name = fields.Char(string='Phase Name')
othertest = fields.Char('Field 1')
nexttest = fields.Char('Field 2')
zidtest = fields.Char('Field 3')
hadatest = fields.Char('Field 4')
awtanitest = fields.Char('Field 5')
barakatest = fields.Char('Field 6')
safitest = fields.Char('Field 7')

@api.model
def action_your_pipeline(self):
action = self.env.ref('crm.crm_lead_opportunities_tree_view').read()[0]
user_pipes = self.env.name.id
if not user_pipes:
user_pipes = self.search([], limit=1).id
action['help'] = """<p class='oe_view_nocontent_create'>Click here to add new opportunities</p><p>
Looks like you are not a member of a sales team. You should add yourself
as a member of one of the sales team.
</p>"""
if user_pipes:
action['help'] += "<p>As you don't belong to any sales team, Odoo opens the first one by default.</p>"

action_context = safe_eval(action['context'], {'uid': self.env.uid})
if user_pipes:
action_context['default_pipes'] = user_pipes

tree_view_id = self.env.ref('crm.crm_case_tree_view_oppor').id
form_view_id = self.env.ref('crm.crm_case_form_view_oppor').id
kanb_view_id = self.env.ref('crm.crm_case_kanban_view_leads').id
action['views'] = [
[kanb_view_id, 'kanban'],
[tree_view_id, 'tree'],
[form_view_id, 'form'],
[False, 'graph'],
[False, 'calendar'],
[False, 'pivot']
]
action['context'] = action_context
return action


class Add_new_field_crm_stage(models.Model):
_inherit = 'crm.stage'

@api.model
def default_get(self, fields):

ctx = dict(self.env.context)
if ctx.get('default_pipes') and not ctx.get('crm_team_mono'):
ctx.pop('default_pipes')
return super(Add_new_field_crm_stage, self.with_context(ctx)).default_get(fields)

pipes = fields.Many2one('pipe.new','Pipe Name')
xml
<record id="crm_case_form_view_salesteams_opportunity" model="ir.actions.act_window">
<field name="name">Opportunities</field>
<field name="res_model">crm.lead</field>
<field name="view_mode">kanban,tree,graph,form,calendar,pivot</field>
<field name="domain">[('type','=','opportunity')]</field>
<field name="view_id" ref="crm.crm_case_kanban_view_leads"/>
<field name="search_view_id" ref="crm.view_crm_case_opportunities_filter"/>
<field name="context">{
'search_default_pipes': [active_id],
'default_pipes': active_id,
'default_type': 'opportunity',
'default_user_id': uid,
}
</field>
<field name="help" type="html">
<p>
Odoo helps you keep track of your sales pipeline to follow
up potential sales and better forecast your future revenues.
</p><p>
You will be able to plan meetings and log activities from
opportunities, convert them into quotations, attach related
documents, track all discussions, and much more.
</p>
</field>
</record>
button
<button class="btn btn-primary"
name="%(crm_case_form_view_salesteams_opportunity)d"
type="action">Pipeline</button>
Avatar
Discard
Related Posts Replies Views Activity
2
Nov 24
25099
2
May 24
5524
3
Mar 24
4965
0
Mar 24
264
3
Feb 24
11421