Default agent per party

Rational

On some companies a party is assigned to a commission agent. Assigning an agent to a party means that by default the sales generated for this party generate a commission to the agent. Some examples:

  1. A bussiness association refers the party to the company and it gets a commission for all the sales that generate this party.
  2. When working with neighboring communities (which is the final customer) normmally there is a company that is responisble of the maintenance of all the properties of the community and this company gets a commission for all the sales related to the neighbours assets that they manage.

Proposal

Add a rule engine on Party to allow to select the default agent based on a criteria. The default criterias will be:

  • Company
  • Start Date
  • End Date

This rule engine will be used to determine the default agent of the sale but the user should be able to change it latter.

Implementation

https://bugs.tryton.org/issue8654

I do not think the rule engine should be based on party. The party should be an optional criteria like any others.

I guess it will be implemented like the product_price_list_dates but which date will be taken?

When is the rule engine be triggered? I think it should be on quotation if the agent is empty.

I do not think it should be included in the commission module but as an extension of it.

Then probably it’s good to add also the current employee as pattern.

The sale_date date or the current date if empty.

That sound good to me.

The problem is that we do not have on the sale the employee who fill it. So it may be complicate to understand later the choice of the agent without this information.

I always though that we should add such fields on the sale, purchase and invoice like we did on shipment but that’s another topic.