Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
1829 Представления

I have on creation trigger for a model filed  and current value is 

record.env["ir.sequence"].next_by_code("seq.fservice")


I want to update to check of a company id 


if company_id = old compnay od 

then 

record.env["ir.sequence"].next_by_code("seq.fservice")


else 

record.env["ir.sequence"].next_by_code("seq.fnewservice")


Аватар
Отменить

Could you please provide more clarity on your question so that we can offer you a suitable solution?

Автор

"I have an automated action that needs to be used in task creation for two different companies. The field called 'Job Number' needs to be auto-created with the prefix 'NO' or 'RO' depending on the company. I have a question regarding how to write Python expressions that can handle conditions such as 'if the company is A, then return sequence seq.company1sq, otherwise return seq.company2sq'."

I have found a way to fix this by creating a sequence with the same name for both companies. But I would like to know the solution to how can we write complex logic in automated action returns value for field

Лучший ответ

Hi, 

You can also try this method.

  • Add a Many2one field in the company model for sequence.
  • Connect the desired sequence.

  • Use the Python Code section in the Automated Action
	​company_id.sequence_id._next()



Аватар
Отменить
Лучший ответ

1. Go to Settings -> Technical -> Automation -> Automated Actions.

2. Create or edit the automated action related to your model.

3. In the Python Code section, add the below code snippet, if record.company_id.id == old_company_id:

    sequence_code = "seq.fservice"

else:

    sequence_code = "seq.fnewservice"

record['your_field'] = record.env["ir.sequence"].next_by_code(sequence_code)


This code snippet will set the default value for the specified field based on the company ID.


Hopw it helps

Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
июн. 25
1006
0
февр. 25
1300
1
янв. 25
1712
2
дек. 24
1433
1
нояб. 24
155