To automate analytic distribution in purchase orders, ensure you're using the correct syntax to update One2many fields. In your code, analytic_distribution should be written as a write operation on line, not dictionary-style assignment. Try this:
for record in records:
tag_ids = [record.x_studio_compte_analytique.id]
for line in record.order_line:
line.write({'analytic_distribution': [(6, 0, tag_ids)]})
Also, make sure analytic_distribution is a Many2many field. This approach correctly assigns the analytic tag to each line. Test it on sample data to confirm it updates as expected.