mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[IMP] : black, isort, prettier
This commit is contained in:
@@ -3,17 +3,18 @@
|
||||
|
||||
import itertools
|
||||
from collections import namedtuple
|
||||
|
||||
from odoo.fields import Date
|
||||
|
||||
Criteria = namedtuple(
|
||||
'Criteria',
|
||||
"Criteria",
|
||||
[
|
||||
'when', # Contract line relatively to today (BEFORE, IN, AFTER)
|
||||
'has_date_end', # Is date_end set on contract line (bool)
|
||||
'has_last_date_invoiced', # Is last_date_invoiced set on contract line
|
||||
'is_auto_renew', # Is is_auto_renew set on contract line (bool)
|
||||
'has_successor', # Is contract line has_successor (bool)
|
||||
'predecessor_has_successor',
|
||||
"when", # Contract line relatively to today (BEFORE, IN, AFTER)
|
||||
"has_date_end", # Is date_end set on contract line (bool)
|
||||
"has_last_date_invoiced", # Is last_date_invoiced set on contract line
|
||||
"is_auto_renew", # Is is_auto_renew set on contract line (bool)
|
||||
"has_successor", # Is contract line has_successor (bool)
|
||||
"predecessor_has_successor",
|
||||
# Is contract line predecessor has successor (bool)
|
||||
# In almost of the cases
|
||||
# contract_line.predecessor.successor == contract_line
|
||||
@@ -23,12 +24,11 @@ Criteria = namedtuple(
|
||||
# If contract_line.predecessor.successor != False
|
||||
# and contract_line is canceled, we don't allow uncancel
|
||||
# else we re-link contract_line and its predecessor
|
||||
'canceled', # Is contract line canceled (bool)
|
||||
"canceled", # Is contract line canceled (bool)
|
||||
],
|
||||
)
|
||||
Allowed = namedtuple(
|
||||
'Allowed',
|
||||
['plan_successor', 'stop_plan_successor', 'stop', 'cancel', 'uncancel'],
|
||||
"Allowed", ["plan_successor", "stop_plan_successor", "stop", "cancel", "uncancel"],
|
||||
)
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ def _expand_none(criteria):
|
||||
variations = []
|
||||
for attribute, value in criteria._asdict().items():
|
||||
if value is None:
|
||||
if attribute == 'when':
|
||||
variations.append(['BEFORE', 'IN', 'AFTER'])
|
||||
if attribute == "when":
|
||||
variations.append(["BEFORE", "IN", "AFTER"])
|
||||
else:
|
||||
variations.append([True, False])
|
||||
else:
|
||||
@@ -53,7 +53,7 @@ def _add(matrix, criteria, allowed):
|
||||
|
||||
CRITERIA_ALLOWED_DICT = {
|
||||
Criteria(
|
||||
when='BEFORE',
|
||||
when="BEFORE",
|
||||
has_date_end=True,
|
||||
has_last_date_invoiced=False,
|
||||
is_auto_renew=True,
|
||||
@@ -68,7 +68,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='BEFORE',
|
||||
when="BEFORE",
|
||||
has_date_end=True,
|
||||
has_last_date_invoiced=False,
|
||||
is_auto_renew=False,
|
||||
@@ -83,7 +83,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='BEFORE',
|
||||
when="BEFORE",
|
||||
has_date_end=True,
|
||||
has_last_date_invoiced=False,
|
||||
is_auto_renew=False,
|
||||
@@ -98,7 +98,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='BEFORE',
|
||||
when="BEFORE",
|
||||
has_date_end=False,
|
||||
has_last_date_invoiced=False,
|
||||
is_auto_renew=False,
|
||||
@@ -113,7 +113,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='IN',
|
||||
when="IN",
|
||||
has_date_end=True,
|
||||
has_last_date_invoiced=False,
|
||||
is_auto_renew=True,
|
||||
@@ -128,7 +128,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='IN',
|
||||
when="IN",
|
||||
has_date_end=True,
|
||||
has_last_date_invoiced=False,
|
||||
is_auto_renew=False,
|
||||
@@ -143,7 +143,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='IN',
|
||||
when="IN",
|
||||
has_date_end=True,
|
||||
has_last_date_invoiced=False,
|
||||
is_auto_renew=False,
|
||||
@@ -158,7 +158,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='IN',
|
||||
when="IN",
|
||||
has_date_end=False,
|
||||
has_last_date_invoiced=False,
|
||||
is_auto_renew=False,
|
||||
@@ -173,7 +173,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='BEFORE',
|
||||
when="BEFORE",
|
||||
has_date_end=True,
|
||||
has_last_date_invoiced=True,
|
||||
is_auto_renew=True,
|
||||
@@ -188,7 +188,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='BEFORE',
|
||||
when="BEFORE",
|
||||
has_date_end=True,
|
||||
has_last_date_invoiced=True,
|
||||
is_auto_renew=False,
|
||||
@@ -203,7 +203,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='BEFORE',
|
||||
when="BEFORE",
|
||||
has_date_end=True,
|
||||
has_last_date_invoiced=True,
|
||||
is_auto_renew=False,
|
||||
@@ -218,7 +218,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='BEFORE',
|
||||
when="BEFORE",
|
||||
has_date_end=False,
|
||||
has_last_date_invoiced=True,
|
||||
is_auto_renew=False,
|
||||
@@ -233,7 +233,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='IN',
|
||||
when="IN",
|
||||
has_date_end=True,
|
||||
has_last_date_invoiced=True,
|
||||
is_auto_renew=True,
|
||||
@@ -248,7 +248,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='IN',
|
||||
when="IN",
|
||||
has_date_end=True,
|
||||
has_last_date_invoiced=True,
|
||||
is_auto_renew=False,
|
||||
@@ -263,7 +263,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='IN',
|
||||
when="IN",
|
||||
has_date_end=True,
|
||||
has_last_date_invoiced=True,
|
||||
is_auto_renew=False,
|
||||
@@ -278,7 +278,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='IN',
|
||||
when="IN",
|
||||
has_date_end=False,
|
||||
has_last_date_invoiced=True,
|
||||
is_auto_renew=False,
|
||||
@@ -293,7 +293,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='AFTER',
|
||||
when="AFTER",
|
||||
has_date_end=True,
|
||||
has_last_date_invoiced=None,
|
||||
is_auto_renew=True,
|
||||
@@ -308,7 +308,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='AFTER',
|
||||
when="AFTER",
|
||||
has_date_end=True,
|
||||
has_last_date_invoiced=None,
|
||||
is_auto_renew=False,
|
||||
@@ -323,7 +323,7 @@ CRITERIA_ALLOWED_DICT = {
|
||||
uncancel=False,
|
||||
),
|
||||
Criteria(
|
||||
when='AFTER',
|
||||
when="AFTER",
|
||||
has_date_end=True,
|
||||
has_last_date_invoiced=None,
|
||||
is_auto_renew=False,
|
||||
@@ -377,10 +377,10 @@ for c in CRITERIA_ALLOWED_DICT:
|
||||
def compute_when(date_start, date_end):
|
||||
today = Date.today()
|
||||
if today < date_start:
|
||||
return 'BEFORE'
|
||||
return "BEFORE"
|
||||
if date_end and today > date_end:
|
||||
return 'AFTER'
|
||||
return 'IN'
|
||||
return "AFTER"
|
||||
return "IN"
|
||||
|
||||
|
||||
def compute_criteria(
|
||||
|
||||
Reference in New Issue
Block a user