From 774c4beac416404235395f017f743c91f193d05e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20-=20Le=20Filament?= <remi@le-filament.com>
Date: Thu, 18 Nov 2021 14:01:17 +0100
Subject: [PATCH] [ENH] Pre-Commit

---
 models/res_partner.py       |  9 ++++++---
 models/sale_order.py        |  9 +++++----
 models/sale_project.py      |  7 ++-----
 views/res_partner_views.xml | 30 +++++++++++++++++++++++-------
 4 files changed, 36 insertions(+), 19 deletions(-)

diff --git a/models/res_partner.py b/models/res_partner.py
index 55d7ac4..23f3de1 100644
--- a/models/res_partner.py
+++ b/models/res_partner.py
@@ -48,11 +48,14 @@ class ResPartner(models.Model):
     # ------------------------------------------------------
     def action_view_partner_projects(self):
         self.ensure_one()
-        action = self.env["ir.actions.actions"]._for_xml_id("ap_sale_project.action_sale_project")
-        action['domain'] = [
-            ('partner_id', 'child_of', self.id),
+        action = self.env["ir.actions.actions"]._for_xml_id(
+            "ap_sale_project.action_sale_project"
+        )
+        action["domain"] = [
+            ("partner_id", "child_of", self.id),
         ]
         return action
+
     # ------------------------------------------------------
     # Business methods
     # ------------------------------------------------------
diff --git a/models/sale_order.py b/models/sale_order.py
index 2148437..0b3ee2c 100644
--- a/models/sale_order.py
+++ b/models/sale_order.py
@@ -30,9 +30,10 @@ class SaleOrder(models.Model):
         current_inter = list()
         for project in self.sale_project_ids:
             for inter in project.intervention_ids:
-                current_inter.append(
-                    (project.id, inter.intervention_type_id.id))
+                current_inter.append((project.id, inter.intervention_type_id.id))
         for sol in self.order_line:
-            if sol.product_id and (sol.sale_project_id.id, sol.product_id.id)\
-                    not in current_inter:
+            if (
+                sol.product_id
+                and (sol.sale_project_id.id, sol.product_id.id) not in current_inter
+            ):
                 sol.unlink()
diff --git a/models/sale_project.py b/models/sale_project.py
index 42f21f4..d9b86b7 100644
--- a/models/sale_project.py
+++ b/models/sale_project.py
@@ -207,7 +207,7 @@ class SaleProject(models.Model):
     # ------------------------------------------------------
     def update_order_lines(self):
         # group by intervention_type for current project
-        lines = self.env['sale.intervention'].read_group(
+        lines = self.env["sale.intervention"].read_group(
             (("project_id", "=", self.id),),
             ("price", "intervention_length", "plant_qty"),
             "intervention_type_id",
@@ -239,10 +239,7 @@ class SaleProject(models.Model):
                     data.update(
                         {
                             "order_id": self.sale_order_id.id,
-                            "name": "Projet "
-                            + self.name
-                            + " - "
-                            + product_tmpl.name,
+                            "name": "Projet " + self.name + " - " + product_tmpl.name,
                             "product_id": product_tmpl.product_variant_id.id,
                             "sale_project_id": self.id,
                         }
diff --git a/views/res_partner_views.xml b/views/res_partner_views.xml
index a1c9023..9e17f2c 100644
--- a/views/res_partner_views.xml
+++ b/views/res_partner_views.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8" ?>
 <odoo>
     <data>
 
@@ -8,8 +8,13 @@
             <field name="inherit_id" ref="base.view_partner_form" />
             <field name="arch" type="xml">
                 <div name="button_box" position="inside">
-                    <button type="object" class="oe_stat_button" icon="fa-pagelines" name="action_view_partner_projects"
-                        context="{'default_partner_id': active_id}">
+                    <button
+                        type="object"
+                        class="oe_stat_button"
+                        icon="fa-pagelines"
+                        name="action_view_partner_projects"
+                        context="{'default_partner_id': active_id}"
+                    >
                         <div class="o_form_field o_stat_info">
                             <span class="o_stat_value">
                                 <field name="sale_project_count" />
@@ -25,13 +30,24 @@
         <record model="ir.ui.view" id="partner_kanban_view_ap">
             <field name="name">res.partner.kanban.ap.inherit</field>
             <field name="model">res.partner</field>
-            <field name="inherit_id" ref="base.res_partner_kanban_view"/>
+            <field name="inherit_id" ref="base.res_partner_kanban_view" />
             <field name="arch" type="xml">
                 <field name="mobile" position="after">
-                    <field name="sale_project_count"/>
+                    <field name="sale_project_count" />
                 </field>
-                <xpath expr="//span[hasclass('oe_kanban_partner_links')]" position="inside">
-                    <span t-if="record.sale_project_count.value>0" class="badge badge-pill"><i class="fa fa-pagelines" role="img" aria-label="Projets" title="Projets"/><t t-esc="record.sale_project_count.value"/></span>
+                <xpath
+                    expr="//span[hasclass('oe_kanban_partner_links')]"
+                    position="inside"
+                >
+                    <span
+                        t-if="record.sale_project_count.value>0"
+                        class="badge badge-pill"
+                    ><i
+                            class="fa fa-pagelines"
+                            role="img"
+                            aria-label="Projets"
+                            title="Projets"
+                        /><t t-esc="record.sale_project_count.value" /></span>
                 </xpath>
             </field>
         </record>
-- 
GitLab