2 答案
Hi,
Did you keep any relation in the crm.lead model to understand from which record the lead get generated ? or any field in sale.order model store the value of created opportunity ?
If yes, using that field, you can access the opportunity and update the stage when changes done inside the sale order.
If not. first you have to keep the relation, using the studio add a new field and keep the relation in it.
Thanks
I configured an automated action that creates an opportunity based on a manually created sales order. I added a custom field called "Sales Order" in the opportunity. This custom field is populated by the automated action with the following:
Sales Order (crm.lead) Python expression record.id
So if I understood you question correctly, yes I have a relation between both. But now based on that relation I want to have an automated action that changes the stage of the generated opportunity based on a manually change of status of the related sales order. I tried to code a line but I get an error message:
update = env['crm.lead'].search([(' x_studio_many2one_field_ZvJsh'.id,'=', record.id)])
if update:
env['crm.lead'].set({'stage_id': '14'})
thanks for your help
This is the error message I get an I already got it before, I think its related to the type of my custom field:
ValueError: <class 'AttributeError'>: "'str' object has no attribute 'id'" while evaluating
"# Available variables:\n# - env: Odoo Environment on which the action is triggered\n# - model: Odoo Model of the record on which the action is triggered; is a void recordset\n# - record: record on which the action is triggered; may be void\n# - records: recordset of all records on which the action is triggered in multi-mode; may be void\n# - time, datetime, dateutil, timezone: useful Python libraries\n# - log: log(message, level='info'): logging function to record debug information in ir.logging table\n# - UserError: Warning Exception to use with raise\n# To return an action, assign: action = {...}\n\ncrm_rec = env['crm.lead'].search([(' x_studio_many2one_field_ZvJsh'.id,'=', record.id)], limit=1)\nif crm_rec:\n crm_rec['stage_id'] = 4"
hi,I succeeded with this mode. you create a automated action that set model sale order , set Trigger: on update ,set Trigger field: status(sale order) and set domin according change status , also action to do:execute python code than ;
update = env['crm.lead'].search([(' x_studio_many2one_field_ZvJsh.id' ,'=', record.id)])
if update:
env['crm.lead'].write({'stage_id': 4})
so
x_studio_many2one_field_ZvJsh is many2one field to created in
opportunity and related sale order
We tried to do something like this, but it doesn't work
update = env['crm.lead'].search([('sales_order_id','=', record.id)])
if update:
env['crm.lead'].write({'field': 'value'})
Can someone help us?