From 901a58a9d159e484079be9926970c6a4e86ab822 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Laporte?= <stephane.laporte@enercoop.org>
Date: Mon, 14 Apr 2025 17:31:31 +0200
Subject: [PATCH] [CLN]
---
models/acc_priority_group_counter.py | 38 ++++++++++++------
static/src/css/custom.css | 2 +-
views/acc_priority_group_counter_views.xml | 35 ++++++++++------
..._repartition_keys_compute_wizard_views.xml | 40 +++++++++----------
4 files changed, 69 insertions(+), 46 deletions(-)
diff --git a/models/acc_priority_group_counter.py b/models/acc_priority_group_counter.py
index 426efd3..d3774ee 100644
--- a/models/acc_priority_group_counter.py
+++ b/models/acc_priority_group_counter.py
@@ -39,9 +39,16 @@ class AccPriorityGroupCounter(models.Model):
string="Counter domain", compute="_compute_acc_counter_id_domain"
)
- acc_counter_share = fields.Float(string='Quote-part', help="Part de la production affectée à ce PRM, au prorata de l'ensemble des parts affectées aux autres PRMs")
- group_type_algo = fields.Selection(related="acc_priority_group_id.type_algo", readonly=True)
- acc_counter_percentage = fields.Float(compute="_compute_acc_counter_percentage", store=False)
+ acc_counter_share = fields.Float(
+ string="Quote-part",
+ help="Part de la production affectée à ce PRM, au prorata de l'ensemble des parts affectées aux autres PRMs",
+ )
+ group_type_algo = fields.Selection(
+ related="acc_priority_group_id.type_algo", readonly=True
+ )
+ acc_counter_percentage = fields.Float(
+ compute="_compute_acc_counter_percentage", store=False
+ )
# ------------------------------------------------------
# SQL Constraints
@@ -55,11 +62,15 @@ class AccPriorityGroupCounter(models.Model):
# Computed fields / Search Fields
# ------------------------------------------------------
- @api.depends('acc_priority_group_id.acc_priority_group_counter_ids', "acc_counter_share")
+ @api.depends(
+ "acc_priority_group_id.acc_priority_group_counter_ids", "acc_counter_share"
+ )
def _compute_acc_counter_percentage(self):
for record in self:
total_share = record.acc_priority_group_id.total_share
- record.acc_counter_percentage = record.acc_counter_share / total_share if total_share else 0
+ record.acc_counter_percentage = (
+ record.acc_counter_share / total_share if total_share else 0
+ )
@api.depends("acc_counter_id", "acc_priority_group_id")
def _compute_acc_counter_id_domain(self):
@@ -121,14 +132,15 @@ class AccPriorityGroupCounter(models.Model):
return group_ids
def action_open_counter_share_form(self):
- print('action_open_counter_share_form')
return {
- 'type': 'ir.actions.act_window',
- 'name': 'Modifier la quote-part du point de soutirage',
- 'res_model': 'acc.priority.group.counter',
- 'view_mode': 'form',
- 'target': 'new',
- 'res_id': self.id,
- 'view_id': self.env.ref('oacc_repartition_keys.acc_operation_priority_group_counter_share_form').id,
+ "type": "ir.actions.act_window",
+ "name": "Modifier la quote-part du point de soutirage",
+ "res_model": "acc.priority.group.counter",
+ "view_mode": "form",
+ "target": "new",
+ "res_id": self.id,
+ "view_id": self.env.ref(
+ "oacc_repartition_keys.acc_operation_priority_group_counter_share_form"
+ ).id,
#'context': {'default_field_name': 'Auto-filled Text'}
}
diff --git a/static/src/css/custom.css b/static/src/css/custom.css
index 3585319..996e8d2 100644
--- a/static/src/css/custom.css
+++ b/static/src/css/custom.css
@@ -1,3 +1,3 @@
.oacc_quick_create.o_form_editable .o_cell .o_form_label {
- margin-bottom: 0 !important;
+ margin-bottom: 0 !important;
}
diff --git a/views/acc_priority_group_counter_views.xml b/views/acc_priority_group_counter_views.xml
index 3f6eb4e..24da09c 100644
--- a/views/acc_priority_group_counter_views.xml
+++ b/views/acc_priority_group_counter_views.xml
@@ -8,7 +8,7 @@
<form string="My Model">
<div>
<group>
- <field name="acc_counter_share" style="width: 15em;"/>
+ <field name="acc_counter_share" style="width: 15em;" />
</group>
</div>
</form>
@@ -34,14 +34,14 @@
<field name="acc_counter_id_domain" invisible="1" />
<group>
<field
- name="acc_counter_id"
- options="{'no_create_edit': True, 'no_create': True}"
- domain="acc_counter_id_domain"
- />
+ name="acc_counter_id"
+ options="{'no_create_edit': True, 'no_create': True}"
+ domain="acc_counter_id_domain"
+ />
</group>
- <field name="group_type_algo" invisible="1"/>
+ <field name="group_type_algo" invisible="1" />
<group attrs="{'invisible': [('group_type_algo', '!=', 'quotepart')]}">
- <field name="acc_counter_share" style="width: 15em;"/>
+ <field name="acc_counter_share" style="width: 15em;" />
</group>
</form>
</field>
@@ -87,16 +87,27 @@
<div class="o_kanban_record_body">
<div><field name="counter_owner" /></div>
<div><field name="counter_street" /></div>
- <field name="group_type_algo" invisible="1"/>
- <group attrs="{'invisible': [('group_type_algo', '!=', 'quotepart')]}">
+ <field name="group_type_algo" invisible="1" />
+ <group
+ attrs="{'invisible': [('group_type_algo', '!=', 'quotepart')]}"
+ >
<div class="d-flex justify-content-between">
<div>
<div>
- Quote-part: <field name="acc_counter_share"/>
- (<field name="acc_counter_percentage" widget="percentage"/>)
+ Quote-part: <field
+ name="acc_counter_share"
+ />
+ (<field
+ name="acc_counter_percentage"
+ widget="percentage"
+ />)
</div>
</div>
- <div class="align-self-end"><button name="action_open_counter_share_form" type="object" class="btn btn-sm btn-primary text-end">Modifier</button></div>
+ <div class="align-self-end"><button
+ name="action_open_counter_share_form"
+ type="object"
+ class="btn btn-sm btn-primary text-end"
+ >Modifier</button></div>
</div>
</group>
</div>
diff --git a/wizard/acc_repartition_keys_compute_wizard_views.xml b/wizard/acc_repartition_keys_compute_wizard_views.xml
index 4f37235..ec45d9e 100644
--- a/wizard/acc_repartition_keys_compute_wizard_views.xml
+++ b/wizard/acc_repartition_keys_compute_wizard_views.xml
@@ -6,31 +6,31 @@
<field name="arch" type="xml">
<form string="Calcul des clés de repartition">
<button
- class="btn btn-primary"
- name="compute_keys"
- type="object"
- string="Lancer le calcul"
- />
+ class="btn btn-primary"
+ name="compute_keys"
+ type="object"
+ string="Lancer le calcul"
+ />
<footer>
<button
- class="btn btn-primary"
- name="get_csv"
- type="object"
- string="Génerer CSV"
- />
+ class="btn btn-primary"
+ name="get_csv"
+ type="object"
+ string="Génerer CSV"
+ />
<button
- class="btn btn-primary"
- name="send_keys"
- type="object"
- string="Envoyer les clés"
- />
+ class="btn btn-primary"
+ name="send_keys"
+ type="object"
+ string="Envoyer les clés"
+ />
<button
- class="btn btn-secondary text-end"
- name="ignore"
- type="object"
- string="Fermer"
- />
+ class="btn btn-secondary text-end"
+ name="ignore"
+ type="object"
+ string="Fermer"
+ />
</footer>
</form>
</field>
--
GitLab