In Projects Module I created a automated action, which creates a new Project name, based on some fields from the sales order. When a project is automatically created from an confirmed sales order the automated action works fine.
Problem is that when I want to create an project manually, the automated action is also called, but there is no sales order behind the project, from which the name could be created.
How can I id the automated action beeing called, when I want to create an project manually ?
The code from my automated action:
name = record.sale_order_id.partner_id.name
shortage = ("".join(name.split()[0]))
sum_of_qty = 0
fc_numbers = []
for line_id in record.sale_line_id.order_id.line :
if line_id.x_studio_product_type == "service" and line_id.x_studio_create_on_order == "task_in_project" :
sum_of_qty += int(line_id.product_uom_qty)
if not line_id.x_studio_fc:
fc_numbers.append("TBD")
elif line_id.x_studio_fc not in fc_numbers :
fc_numbers.append(line_id.x_studio_fc)
record["name"] = (' / '.join(fc_numbers) + " - " + record.sale_order_id.name + " - " + shortage + " - " + str(sum_of_qty) +" MT")