From e0d2fae5d57a47e7b6fc6fcd2ddfe95be14897e0 Mon Sep 17 00:00:00 2001
From: benjamin <benjamin@le-filament.com>
Date: Wed, 30 Mar 2022 11:00:23 +0200
Subject: [PATCH] [add] partner member number on view contribution

---
 models/account_invoice.py | 4 ++++
 views/account_invoice.xml | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/models/account_invoice.py b/models/account_invoice.py
index 16c9033..4396b6b 100755
--- a/models/account_invoice.py
+++ b/models/account_invoice.py
@@ -45,6 +45,10 @@ class ScopAccountInvoice(models.Model):
         related='partner_id.ur_id',
         store=True
     )
+    partner_member_number = fields.Char(
+        string='N° Adhérent',
+        related='partner_id.member_number',
+    )
     contribution_id = fields.Many2one(
         comodel_name='scop.contribution',
         string='Ligne de cotisation')
diff --git a/views/account_invoice.xml b/views/account_invoice.xml
index a63f118..4bf5833 100644
--- a/views/account_invoice.xml
+++ b/views/account_invoice.xml
@@ -24,6 +24,9 @@
                 <xpath expr="//field[@name='partner_id']" position="attributes">
                     <attribute name="string">Adhérent</attribute>
                 </xpath>
+                <xpath expr="//field[@name='partner_id']" position="after">
+                    <field name="partner_member_number" readonly="1"/>
+                </xpath>
                 <xpath expr="//field[@name='date_invoice']" position="attributes">
                     <attribute name="string">Date de cotisation</attribute>
                 </xpath>
@@ -59,7 +62,9 @@
             <field name="mode">primary</field>
             <field name="inherit_id" ref="account.invoice_tree_with_onboarding"/>
             <field name="arch" type="xml">
-
+                <xpath expr="//field[@name='partner_id']" position="before">
+                    <field name="partner_member_number" readonly="1"/>
+                </xpath>
                 <xpath expr="//field[@name='partner_id']" position="attributes">
                     <attribute name="string">Adhérent</attribute>
                 </xpath>
-- 
GitLab