Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
2789 มุมมอง

Hi, Odoo cannot generate a CRM opportunity automatically when a sales quotation is generate?  I saw a thread here about developer mode (which we activated) but I cannot see how to do this.  Thank you.  


Thank you.  

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello Premier Property Management Co. Ltd.

Please find code in comment. 

I hope this will help you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

อวตาร
ละทิ้ง

When you can create a sale order create an opportunity in the order
from "Other Info --> Opportunity" so you can be added exiting lead to link this order,
or create a new one for this sale order.

Or, you can create an automatic opportunity so add the below example.

class SaleOrderInherit(models.Model):
_inherit = 'sale.order'

def create(self, vals)
""" Generate opportunity automatically when order is saved """
res = super(SaleOrderInherit, self).create(vals)
if res.partner_id:
opportunity_id = self.env['crm.lead'].create({
'name': res.name + "Opportunity",
'partner_id': res.partner_id,
})
res.opportunity_id = opportunity_id.id
return res

ผู้เขียน

Thank you. Is this custom code or standard functionality? We are using Odoo online, and do not want to custom code anything because then we lose support. Thanks. I am in the "Other info" tab of the quote screen, but I cannot see where to link this quote or to create an opportunity.

คำตอบที่ดีที่สุด

Hi,

In Odoo, you can generate a CRM opportunity automatically when a sales quotation is created by using the 'sale.order' model's 'create' method and the 'crm.lead' model.Here is an example of a new function that creates a CRM opportunity when a sales quotation is created:

class SaleOrder(models.Model):
_inherit = 'sale.order'

@api.model
def create(self, vals):
# Create a new opportunity
opportunity = self.env['crm.lead'].create({
'name': vals.get('name', ''),
'partner_id': vals.get('partner_id', False),
})
# Link the opportunity to the quotation
vals['opportunity_id'] = opportunity.id
quotation = super(SaleOrder, self).create(vals)
return quotation

In this example, when a new quotation is created, a new opportunity is created with the name of the quotation and the customer of the quotation. The opportunity is linked to the quotation using the opportunity_id field.

Regards

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ค. 23
1252
Hide Sales Menu in CRM แก้ไขแล้ว
1
มิ.ย. 23
1774
3
มี.ค. 15
9113
0
มี.ค. 15
2869
How can I structure my Sales process? แก้ไขแล้ว
1
มี.ค. 15
5726