This technical note is written for developers, to help them solve the question of identifying the different sources of invoices/orders for the application of a partner discount.
The discount must check that the current transaction falls into one of the following cases, and activate itself if the settings allow it:
Any invoice/transaction (local_shop\Bill object) is considered a “brought” invoice if:
Invoices/transactions created under the partner's customer account only have to check one condition: being associated with a customerid matching the customerid associated with the Partner.
Consistency is therefore needed between: Partner→customerid and Bill→customerid,
Auto-generated purchase orders are invoices/purchase orders (local_shop/Bill) in which one of the order items is a product associated with a handler of type “registered_product”. As the condition is rather indirect, it should be examined how it could be made more explicit.
The invoice/order must also be associated with the customer “customerid” associated with the Partner object. Consistency is therefore needed between: Partner→customerid, Bill→customerid, and it must be checked that one of the products (BillItem) is of type “registered_product”.
In the current state of the shop, only automated transactions can buy products of type “registered_product”