Skip to content
Extraits de code Groupes Projets
Valider 4725b2a3 rédigé par Juliana's avatar Juliana
Parcourir les fichiers

[UPD]Update arborescence documents

parent 02024baa
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -192,71 +192,65 @@ class OperationsService(Component):
"id": operation.id,
"name": operation.name,
}
if type == "invoice":
# Récupération de toutes les factures liées à l'opération spécifiée
acc_account_ids = self.env["acc.account"].search(
[("acc_operation_id", "=", _id), ("state", "=", "published")]
)
datas["documents"] = (
acc_account_ids.mapped(
lambda n: {
"id": n.id,
"name": n.name,
"date": n.date,
"start_date": n.start_date,
"end_date": n.end_date,
"amount_total": n.amount_total,
"url": base_url + n.get_portal_url(report_type="pdf"),
}
)
if acc_account_ids
else []
)
# Récupération de toutes les factures externes
# liées à l'opération spécifiée
domain = [("acc_operation_id", "=", _id)]
domain += [
("type", "=", "facture"),
]
acc_contract_ids = self.env["acc.contract"].search(domain)
datas["factures_externes"] = (
acc_contract_ids.mapped(
acc_contract_ids_f = self.env["acc.contract"].search(domain)
invoice_exist = False
if acc_contract_ids_f or acc_account_ids:
invoice_exist = True
# Récupération de tous les contrats liés à l'opération spécifiée
domain_c = [("acc_operation_id", "=", _id)]
domain_pmo = [("acc_operation_id", "=", _id)]
role = self._get_role(operation)
if role.get("isConsumer") or role.get("isProductor"):
domain_c += [
("type", "!=", "convention"),
("type", "!=", "all"),
("type", "!=", False),
]
if role.get("isPmo"):
domain_pmo += [("type", "!=", False)]
acc_contract_ids = self.env["acc.contract"].sudo().search(domain_pmo)
else:
acc_contract_all = self.env["acc.contract"].sudo().search([
("acc_operation_id", "=", _id), ("type", "=", "all"),
])
acc_contract_ids = self.env["acc.contract"].search(domain_c)
acc_contract_ids += acc_contract_all
contract_exist = False
if acc_contract_ids:
contract_exist = True
if type == "invoice" and invoice_exist:
datas["documents"] = (
acc_account_ids.mapped(
lambda n: {
"id": n.id,
"name": n.name,
"date": n.date,
"start_date": n.start_date,
"end_date": n.end_date,
"type": n.type,
"url": base_url + n.get_portal_url(),
"amount_total": n.amount_total,
"url": base_url + n.get_portal_url(report_type="pdf"),
}
)
if acc_contract_ids
if acc_account_ids
else []
)
elif type == "other":
# Récupération de tous les contrats liés à l'opération spécifiée
domain = [("acc_operation_id", "=", _id)]
role = self._get_role(operation)
# if role.get("isConsumer") or role.get("isProductor"):
# domain += [
# ("type", "!=", "convention"),
# ("type", "!=", "all"),
# ("type", "!=", False),
# ]
# if role.get("isPmo"):
# domain_pmo += [("type", "!=", False)]
# acc_contract_ids = self.env["acc.contract"].sudo().search(domain_pmo)
# else:
acc_contract_ids = self.env["acc.contract"].sudo().search([
("acc_operation_id", "=", _id), ("type", "=", "all"),
])
# acc_contract_ids = self.env["acc.contract"].search(domain)
# acc_contract_ids += acc_contract_all
datas["other"] = (
acc_contract_ids.mapped(
datas["factures_externes"] = (
acc_contract_ids_f.mapped(
lambda n: {
"id": n.id,
"name": n.name,
......@@ -266,29 +260,10 @@ class OperationsService(Component):
"url": base_url + n.get_portal_url(),
}
)
if acc_contract_ids
if acc_contract_ids_f
else []
)
else:
# Récupération de tous les contrats liés à l'opération spécifiée
domain = [("acc_operation_id", "=", _id)]
domain_pmo = [("acc_operation_id", "=", _id)]
role = self._get_role(operation)
if role.get("isConsumer") or role.get("isProductor"):
domain += [
("type", "!=", "convention"),
("type", "!=", "all"),
("type", "!=", False),
]
if role.get("isPmo"):
domain_pmo += [("type", "!=", False)]
acc_contract_ids = self.env["acc.contract"].sudo().search(domain_pmo)
else:
# acc_contract_all = self.env["acc.contract"].sudo().search([
# ("acc_operation_id", "=", _id), ("type", "=", "all"),
# ])
acc_contract_ids = self.env["acc.contract"].search(domain)
# acc_contract_ids += acc_contract_all
elif type == "contract" or (not invoice_exist and contract_exist):
datas["contracts"] = (
acc_contract_ids.mapped(
......@@ -304,6 +279,8 @@ class OperationsService(Component):
if acc_contract_ids
else []
)
datas["contract_exist"] = contract_exist
datas["invoice_exist"] = invoice_exist
return datas
@restapi.method(
......@@ -751,6 +728,8 @@ class OperationsService(Component):
},
},
"id": {"type": "integer"},
"invoice_exist": {"type": "boolean"},
"contract_exist": {"type": "boolean"},
"name": {"type": "string"},
"documents": {
"nullable": True,
......@@ -798,21 +777,6 @@ class OperationsService(Component):
},
},
},
"other": {
"nullable": True,
"type": "list",
"schema": {
"type": "dict",
"schema": {
"id": {"type": "integer"},
"name": {"type": "string"},
"type": {"type": "string", "nullable": True},
"url": {"type": "string", "nullable": True},
"seller": {"type": "string", "nullable": True},
"buyer": {"type": "string", "nullable": True},
},
},
},
}
def _validator_get_pmo(self):
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter