Add api_3P_tariffs
MM 3P products have the same attributes than their original counterparts (mm_tariff), but are cheaper. The MM condition to contract them is that the mobile customer already has a fiber contract with them (MM). If we want to apply these 3P tariffs, we must ask the ODOO db if a given customer has an active fiber contract with MM.
-
Add api_3P_tariff parameter to api_tariffs table and tariff class logic
-
Add api_3P_tariff code for UNL_10GB product
-
Check if customer has already a fiber contract with MM in order to apply the api_3P_tariff product variant instead of the original one.
-
Substitute old DB connection for an API call with the
_get_original_tariff
method
In [1]: from api.tariff import Tariff
In [2]: tariff = Tariff("SE_SC_REC_MOBILE_T_UNL_10240")
In [3]: tariff._customer_has_fiber_contract("1111", "ES41577430P")
Out[3]: False
In [4]: tariff.get_MM_tariff_code("1111", "41577430P")
Out[4]: '01t4I00004kYJH9QAO' # LA MAGNIFICA 10
In [5]: tariff._customer_has_fiber_contract("1111", "ES41581508S")
Out[5]: True
In [6]: tariff.get_MM_tariff_code("1111", "41581508S")
Out[6]: '01t4I00004kYnxVQAS' # 10GB_3P CABLEMOVIL