From d36d011f69ee1085448645d2541d4f4377d82c69 Mon Sep 17 00:00:00 2001
From: jordan <jordan@le-filament.com>
Date: Mon, 3 May 2021 12:21:18 +0200
Subject: [PATCH] [updtae] fields are monetary
---
models/scop_cotisations_idf.py | 21 +++++++++++++++------
models/scop_invoice_idf.py | 10 +++++++---
views/scop_cotisations_idf.xml | 31 +++++++++++++++++++------------
views/scop_invoice_idf.xml | 17 ++++++++++-------
4 files changed, 51 insertions(+), 28 deletions(-)
diff --git a/models/scop_cotisations_idf.py b/models/scop_cotisations_idf.py
index 64c0df5..7538fb0 100644
--- a/models/scop_cotisations_idf.py
+++ b/models/scop_cotisations_idf.py
@@ -32,12 +32,16 @@ class ScopCotisationsIDF(models.Model):
('pay', 'Paiment')],
string='Type', )
lettrage = fields.Char('Lettrage')
- debit = fields.Float(string='Débit')
- credit = fields.Float(string='Crédit')
- amount_residual = fields.Float(
+ currency_id = fields.Many2one(
+ comodel_name='res.currency',
+ string='Monnaie',
+ related='company_id.currency_id')
+ debit = fields.Monetary(string='Débit', currency_field='currency_id')
+ credit = fields.Monetary(string='Crédit', currency_field='currency_id')
+ amount_residual = fields.Monetary(
string='Reste à payer',
compute='_compute_amount_residual',
- store=True)
+ store=True, currency_field='currency_id')
state = fields.Selection(
string='Etat',
selection=[('no_invoice', 'Pas de cotisation associée'),
@@ -59,14 +63,19 @@ class ScopCotisationsIDF(models.Model):
required=False, readonly=True)
exoneration = fields.Boolean(
- string='Exoneration',
+ string='Exonération',
compute='_compute_exoneration',
store=True)
- cotiz_zero = fields.Boolean(string='Non appelé')
+ cotiz_zero = fields.Boolean(string='Non appelée')
# ------------------------------------------------------
# Computed fields
# ------------------------------------------------------
+ # @api.multi
+ # def _compute_currency(self):
+ # for r in self:
+ # r.currency_id = r.env
+
@api.depends('payment_or_refund_ids', 'debit',
'payment_or_refund_ids.debit', 'payment_or_refund_ids.debit')
@api.multi
diff --git a/models/scop_invoice_idf.py b/models/scop_invoice_idf.py
index 132956e..b8b51a9 100644
--- a/models/scop_invoice_idf.py
+++ b/models/scop_invoice_idf.py
@@ -32,12 +32,16 @@ class ScopinvoiceIDF(models.Model):
('pay', 'Paiment')],
string='Type',)
lettrage = fields.Char('Lettrage')
- debit = fields.Float(string='Débit')
- credit = fields.Float(string='Crédit')
+ currency_id = fields.Many2one(
+ comodel_name='res.currency',
+ string='Monnaie',
+ related='company_id.currency_id')
+ debit = fields.Monetary(string='Débit', currency_field='currency_id')
+ credit = fields.Monetary(string='Crédit', currency_field='currency_id')
amount_residual = fields.Float(
string='Reste à payer',
compute='_compute_amount_residual',
- store=True
+ store=True, currency_field='currency_id'
)
state = fields.Selection(
string='Etat',
diff --git a/views/scop_cotisations_idf.xml b/views/scop_cotisations_idf.xml
index 3be63e2..e1d8c32 100644
--- a/views/scop_cotisations_idf.xml
+++ b/views/scop_cotisations_idf.xml
@@ -31,9 +31,10 @@
<field name="partner_id"/>
<field name="year"/>
<field name="type"/>
- <field name="debit"/>
- <field name="credit"/>
- <field name='amount_residual'/>
+ <field name="currency_id" invisible="1"/>
+ <field name="debit" widget="monetary"/>
+ <field name="credit" widget="monetary"/>
+ <field name='amount_residual' widget="monetary"/>
<field name='invoice_id'/>
<field name='payment_or_refund_ids'/>
<field name='lettrage'/>
@@ -69,9 +70,10 @@
<group name="cotiz" string="Cotisation">
<field name="type"/>
<field name="name"/>
- <field name="credit" string="Montant" attrs="{'invisible': [('type', '=', 'inv')]}"/>
- <field name="debit" string="Montant" attrs="{'invisible': [('type', '!=', 'inv')]}"/>
- <field name="amount_residual"
+ <field name="currency_id" invisible="1"/>
+ <field name="credit" widget="monetary" string="Montant" attrs="{'invisible': [('type', '=', 'inv')]}"/>
+ <field name="debit" widget="monetary" string="Montant" attrs="{'invisible': [('type', '!=', 'inv')]}"/>
+ <field name="amount_residual" widget="monetary"
attrs="{'invisible': [('type', '!=', 'inv')]}"/>
<field name="invoice_id"
domain="[('partner_id', '=', partner_id), ('type', '=', 'inv'), ('amount_residual', '>', 0)]"
@@ -90,7 +92,8 @@
<field name="name"/>
<field name="year"/>
<field name="type"/>
- <field name="credit" string="Montant"/>
+ <field name="currency_id" invisible="1"/>
+ <field name="credit" widget="monetary" string="Montant"/>
<field name='lettrage'/>
<field name='exoneration'/>
<button name="action_open_payment" type="object"
@@ -127,7 +130,8 @@
<field name="arch" type="xml">
<pivot string="Cotisations IDF" display_quantity="True">
<field name="partner_id" type="row"/>
- <field name="amount_residual" type="measure"/>
+ <field name="currency_id" invisible="1"/>
+ <field name="amount_residual" type="measure" widget="monetary"/>
</pivot>
</field>
</record>
@@ -142,10 +146,13 @@
<field name="partner_id"/>
<filter name="with_issue" domain="[('state','in',['no_invoice', 'overpaid'])]" string="Erreur lettrage et/ou montant"/>
<separator/>
- <filter name="is_type_invoice" domain="[('type','=','inv')]" string="Factures"/>
- <filter name="inv_paid" domain="[('type','=','inv'),('state','=','paid')]" string="Factures payées"/>
- <filter name="inv_unpaid" domain="[('type','=','inv'),('state','=','awaiting_payments')]" string="Factures reste à payées"/>
- <filter name="inv_with_issue" domain="[('type','=','inv'),('state','=','overpaid')]" string="Factures en erreur"/>
+ <filter name="is_type_invoice" domain="[('type','=','inv')]" string="Cotisations"/>
+ <filter name="cotiz_paid" domain="[('type','=','inv'),('state','=','paid')]" string="Cotisations payées"/>
+ <filter name="cotiz_unpaid" domain="[('type','=','inv'),('state','=','awaiting_payments')]" string="Cotisations reste à payées"/>
+ <filter name="cotiz_with_issue" domain="[('type','=','inv'),('state','=','overpaid')]" string="Cotisations en erreur"/>
+ <separator/>
+ <filter name="cotiz_exo" domain="[('exoneration','=',True)]" string="Exonérations"/>
+ <filter name="cotiz_not_called" domain="[('type','=','inv'),('cotiz_zero','=',True)]" string="Cotisations non appelées"/>
<group expand="0" string="Group By">
<filter name="group_by_partner_id" string="Adhérent" context="{'group_by':'partner_id'}"/>
<separator/>
diff --git a/views/scop_invoice_idf.xml b/views/scop_invoice_idf.xml
index ab58336..2074f36 100644
--- a/views/scop_invoice_idf.xml
+++ b/views/scop_invoice_idf.xml
@@ -31,9 +31,10 @@
<field name="partner_id"/>
<field name="year"/>
<field name="type"/>
- <field name="credit"/>
- <field name="debit"/>
- <field name='amount_residual'/>
+ <field name="currency_id" invisible="1"/>
+ <field name="credit" widget="monetary"/>
+ <field name="debit" widget="monetary"/>
+ <field name='amount_residual' widget="monetary"/>
<field name='invoice_id'/>
<field name='payment_or_refund_ids'/>
<field name='lettrage'/>
@@ -65,9 +66,10 @@
<group name="invoice" string="Facture">
<field name="type"/>
<field name="name"/>
- <field name="credit" string="Montant" attrs="{'invisible': [('type', '=', 'inv')]}"/>
- <field name="debit" string="Montant" attrs="{'invisible': [('type', '!=', 'inv')]}"/>
- <field name="amount_residual"
+ <field name="currency_id" invisible="1"/>
+ <field name="credit" widget="monetary" string="Montant" attrs="{'invisible': [('type', '=', 'inv')]}"/>
+ <field name="debit" widget="monetary" string="Montant" attrs="{'invisible': [('type', '!=', 'inv')]}"/>
+ <field name="amount_residual" widget="monetary"
attrs="{'invisible': [('type', '!=', 'inv')]}"/>
<field name="invoice_id"
domain="[('partner_id', '=', partner_id), ('type', '=', 'inv'), ('amount_residual', '>', 0)]"
@@ -86,7 +88,8 @@
<field name="name"/>
<field name="year"/>
<field name="type"/>
- <field name="credit" string="Montant"/>
+ <field name="currency_id" invisible="1"/>
+ <field name="credit" string="Montant" widget="monetary"/>
<field name='lettrage'/>
<button name="action_open_payment" type="object"
string="Paiement / Avoir" icon="fa-eye"
--
GitLab