# Allowed analytic accounts for a customer or supplier in invoices

**URL:** https://discuss.tryton.org/t/allowed-analytic-accounts-for-a-customer-or-supplier-in-invoices/3448
**Category:** Developer
**Created:** [November 11, 2020, 8:41pm UTC](https://discuss.tryton.org/t/allowed-analytic-accounts-for-a-customer-or-supplier-in-invoices/3448 "2020-11-11T20:41:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nlopez73](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/nlopez73/32/1310_2.png) [@nlopez73](https://discuss.tryton.org/u/nlopez73)
#### Post date: [November 11, 2020, 8:41pm UTC](https://discuss.tryton.org/t/allowed-analytic-accounts-for-a-customer-or-supplier-in-invoices/3448/1 "2020-11-11T20:41:57Z")

</div>

Hi all,

We need to restrict allowed analytic accouts for an invoice line. Allowed accounts depend on invoice’s party. The first option seems to be to implement an o2m between party and account and a domain …

another approach?

Thanks in advance

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [November 11, 2020, 9:43pm UTC](https://discuss.tryton.org/t/allowed-analytic-accounts-for-a-customer-or-supplier-in-invoices/3448/2 "2020-11-11T21:43:38Z")

</div>

Hi Nicolas,

Why you need such restriction? Normally the analytic accounts are not linked to a party.

With all the information we can provide better advices

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [November 11, 2020, 11:29pm UTC](https://discuss.tryton.org/t/allowed-analytic-accounts-for-a-customer-or-supplier-in-invoices/3448/3 "2020-11-11T23:29:43Z")

</div>

I think it could make sense to limit the usage of analytic account on document based on party (but it is only one possibility). But such constraint could never be enforced at the account move level.  
For such use case, I would add a `Many2Many` on analytic account to list the authorized parties. Then on invoice, sale and purchase lines (in short all `AnalyticMixin`) I would extend the domain with a clause like `('parties', 'in', Eval('analytic_party'))` (and of course add a `Function` field on the lines to compute party).

I’m not sure if it is an enough common practice to become a standard module.
