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

[FIX]Error merge conflict

parent 51cf1474
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -276,7 +276,7 @@ class AuthService(Component):
return {}
@restapi.method(
[(["/my-account"], "GET")],
[(["/mon-compte"], "GET")],
input_param=restapi.CerberusValidator("_validator_get_my_account"),
output_param=restapi.CerberusValidator("_validator_return_my_account"),
cors="*",
......@@ -284,17 +284,18 @@ class AuthService(Component):
)
def get_my_account(self):
user_id = self.env["res.users"].browse(self.request.uid)
user = {
"company": user_id.partner_id.parent_id.name,
"company": user_id.partner_id.parent_id.name or "",
"name": user_id.name,
"firstname": user_id.firstname,
"firstname": user_id.firstname or "",
"lastname": user_id.lastname,
"login": user_id.login,
}
return user
@restapi.method(
[(["/my-account"], "POST")],
[(["/mon-compte"], "POST")],
input_param=restapi.CerberusValidator("_validator_set_my_account"),
output_param=restapi.CerberusValidator("_validator_return_my_account"),
cors="*",
......@@ -311,9 +312,9 @@ class AuthService(Component):
}
)
user = {
"company": user_id.partner_id.parent_id.name,
"company": user_id.partner_id.parent_id.name or "",
"name": user_id.name,
"firstname": user_id.firstname,
"firstname": user_id.firstname or "",
"lastname": user_id.lastname,
"login": user_id.login,
}
......@@ -411,7 +412,7 @@ class AuthService(Component):
"login": {"type": "string"},
"firstname": {"type": "string", "nullable": True},
"lastname": {"type": "string", "nullable": True},
"name": {"type": "string"},
"name": {"type": "string", "nullable": True},
"company": {"type": "string", "nullable": True},
}
......
# © 2021 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import base64
from datetime import datetime
from odoo import SUPERUSER_ID
from odoo.exceptions import AccessError
from odoo.http import content_disposition, request
from odoo.addons.base_rest import restapi
from odoo.addons.component.core import Component
......@@ -106,6 +103,27 @@ class OperationsService(Component):
power_tot = (0, 0)
cons_rate = prod_rate = 0
nb_conso = (
self.env["acc.counter"]
.sudo()
.search_count(
[
("acc_operation_id", "=", operation.id),
("is_delivery", "=", True),
]
)
)
nb_prod = (
self.env["acc.counter"]
.sudo()
.search_count(
[
("acc_operation_id", "=", operation.id),
("is_injection", "=", True),
]
)
)
datas = {
"role": role,
"id": operation.id,
......@@ -121,8 +139,8 @@ class OperationsService(Component):
if operation.distribution_key
else None,
"pmo": operation.sudo().pmo_id.name,
"consumer_nb": len(operation.sudo().acc_delivery_ids),
"productor_nb": len(operation.sudo().acc_injection_ids),
"consumer_nb": nb_conso,
"productor_nb": nb_prod,
"power_install": power_install,
"image": operation.image_256.decode("utf-8")
if operation.image_256
......@@ -162,13 +180,12 @@ class OperationsService(Component):
"""
operation = self.env["acc.operation"].browse(_id)
role = self._get_role(operation)
base_url = self.env['ir.config_parameter'].sudo().get_param(
'web.base.url')
base_url = self.env["ir.config_parameter"].sudo().get_param("web.base.url")
if not role.get("isIn"):
return AccessError()
type = self.request.params.get("type", False)
self.request.params.get("type", False)
datas = {
"role": role,
......@@ -192,21 +209,36 @@ class OperationsService(Component):
}
) if acc_account_ids else []
else:
# 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)]
)
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"),
}
)
# Récupération de toutes les factures liées à 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"):
domain += [("type", "=", "achat")]
if role.get("isProductor"):
domain += [("type", "=", "vente")]
if role.get("isConsumer") or role.get("isProductor"):
domain += [("type", "=", "vente_achat")]
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(domain)
datas["contracts"] = acc_contract_ids.mapped(lambda n: {
datas["contracts"] = acc_contract_ids.mapped(
lambda n: {
"id": n.id,
"name": n.name,
"start_date": n.start_date,
......@@ -215,6 +247,8 @@ class OperationsService(Component):
"url": base_url + n.get_portal_url(),
}
) if acc_contract_ids else []
}
)
return datas
@restapi.method(
......@@ -625,6 +659,7 @@ class OperationsService(Component):
"id": {"type": "integer"},
"name": {"type": "string"},
"documents": {
"nullable": True,
"type": "list",
"schema": {
"type": "dict",
......@@ -640,6 +675,7 @@ class OperationsService(Component):
},
},
"contracts": {
"nullable": True,
"type": "list",
"schema": {
"type": "dict",
......
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