Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
1465 Переглядів

Hello, this is my first post in the forum :)

I'm trying to automate the analytic distribution in purchase order because, some orders may have tens of lines and I want to avoid errors while copying the distribution. Mass modification is not available for the lines in Studio so I try to make an atumated action with code :

Model id purchase.order, trigger is update and I have a ManyToOne field related to analytic accounts called x_studio_compte_analytique. Here is my code.
I tried to check if record.x_studio_compte_analytique.id is ok => yes, it displays the good ID

Any idea ?

for record in records:
  tag_ids = [record.x_studio_compte_analytique.id]
​#tag_ids = [6,7] doesn't work either
  for line in record.order_line:
    line['analytic_distribution']=[(6, 0, tag_ids)]

Аватар
Відмінити
Автор Найкраща відповідь

Ok, I've found my mistake.
analytic_distribution is a json

The right code is :

for record in records:
  analytic_account_id=record.x_studio_compte_analytique.id
  for line in record.order_line:
    line['analytic_distribution']={str(analytic_account_id): 100.0}
Аватар
Відмінити

Hi Emmanuel,

I’ve set up the analytic distribution with the following structure:

Project

Department

Branch

Location

Now, I want to automate the analytic distribution such that whenever a record is created and a customer is selected on the sale order, the Location (point 4) in the distribution should be automatically populated.

I’ve written logic that fetches the location-related analytic account from the customer and adds it to the sale order’s analytic distribution. However, the issue is that it's currently being added under 1. Project instead of 4. Location.

Do you have any idea how we can specifically target the 4th column (Location) in the analytic distribution?

Thanks in advance!
Best regards,

Related Posts Відповіді Переглядів Дія
0
трав. 24
937
1
бер. 24
812
1
січ. 24
875
1
жовт. 22
1765
1
трав. 22
2103