diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-05-05 13:57:17 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-05-05 13:57:17 +0700 |
| commit | f716974b222fdbaeb41ef95c391451e993b9825e (patch) | |
| tree | ec5de43d4022fa87207d061761f5e49d4ac60a92 | |
| parent | fdb223d9f940f252470b316cbb01fdc8d209d3c9 (diff) | |
change salesperson sales order if salesperson in lead changes and add tag for website
| -rwxr-xr-x | indoteknik_custom/models/crm_lead.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/indoteknik_custom/models/crm_lead.py b/indoteknik_custom/models/crm_lead.py index bd5cdd26..b40bed6e 100755 --- a/indoteknik_custom/models/crm_lead.py +++ b/indoteknik_custom/models/crm_lead.py @@ -18,6 +18,11 @@ class CrmLead(models.Model): operator_name = fields.Char('Operator Name', help='Operator yang membalas') order_id = fields.Many2one('sale.order', string='Sales Order', help='Link ke sales order id') + @api.onchange('user_id') + def _change_salesperson_so(self): + if self.order_id: + self.order_id.user_id = self.user_id + def revert_to_leads(self): opportunities = self.env['crm.lead'].search([ ('type', '=', 'opportunity'), @@ -49,12 +54,16 @@ class CrmLead(models.Model): # ('id', '=', 12523) ], limit=1000) for lead in leads: - tags = self.env['crm.tag'].search([('id', '>', 0)]) input_tags = [] - for tag in tags: - if tag.name.lower() in lead.body_html_lead.lower(): - input_tags.append(tag.id) - lead.tag_ids = input_tags + if "Ada Quotation dari Website" in lead.name: + input_tags.append(1509) + lead.tag_ids = input_tags + else: + tags = self.env['crm.tag'].search([('id', '>', 0)]) + for tag in tags: + if tag.name.lower() in lead.body_html_lead.lower(): + input_tags.append(tag.id) + lead.tag_ids = input_tags if not lead.partner_id: continue |
