From dc2d4b1219b38a8fce71052bc5df12bb534d5c80 Mon Sep 17 00:00:00 2001 From: jordan <jordan@le-filament.com> Date: Wed, 3 Mar 2021 11:04:14 +0100 Subject: [PATCH] [fix] default_payment_term_id in cgscop_cotisation --- models/res_company.py | 7 +++++++ models/res_config_settings.py | 8 ++++++++ models/scop_cotisation.py | 14 +++++++++++++- views/res_config_settings.xml | 7 +++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/models/res_company.py b/models/res_company.py index c356d0c..f346618 100644 --- a/models/res_company.py +++ b/models/res_company.py @@ -13,6 +13,13 @@ class ScopCotisationCompany(models.Model): string='Journal des cotisations', domain="[('type', '=', 'sale')]" ) + + contribution_default_payment_term_id = fields.Many2one( + comodel_name='account.payment.term', + string="Conditions de paiement par défaut pour les cotisations", + domain=[('is_contribution', '=', True)], + ) + tag_cotiz_id = fields.Many2one( comodel_name='res.partner.category', string='Etiquette de cotisation', diff --git a/models/res_config_settings.py b/models/res_config_settings.py index 55d713f..714396c 100644 --- a/models/res_config_settings.py +++ b/models/res_config_settings.py @@ -18,6 +18,14 @@ class CotisationsConfigSettings(models.TransientModel): string='Journal des cotisations', domain="[('type', '=', 'sale')]") + contribution_default_payment_term_id = fields.Many2one( + comodel_name='account.payment.term', + related="company_id.contribution_default_payment_term_id", + readonly=False, + string="Conditions de paiement par défaut pour les cotisations", + domain=[('is_contribution', '=', True)], + ) + tag_cotiz_id = fields.Many2one( comodel_name='res.partner.category', related="company_id.tag_cotiz_id", diff --git a/models/scop_cotisation.py b/models/scop_cotisation.py index d1b34e6..1297deb 100644 --- a/models/scop_cotisation.py +++ b/models/scop_cotisation.py @@ -2,7 +2,6 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import models, fields, api -from odoo.exceptions import UserError from datetime import date @@ -11,6 +10,19 @@ class ScopCotisation(models.AbstractModel): _name = "scop.cotisation" _description = "Base des cotisations" + @api.model + def default_get(self, fields): + """ + Attribue la valeur des conditions de paiments par + défault à la base de cotisation + :param fields: + :return: + """ + res = super(ScopCotisation, self).default_get(fields) + res['payment_term_id'] = self.env.user.company_id.\ + contribution_default_payment_term_id.id + return res + year = fields.Selection( [(year, str(year)) for year in range( fields.Datetime.now().year - 1, fields.Datetime.now().year + 2)], diff --git a/views/res_config_settings.xml b/views/res_config_settings.xml index f97b36a..3cd000f 100644 --- a/views/res_config_settings.xml +++ b/views/res_config_settings.xml @@ -29,6 +29,13 @@ </div> <field name="contribution_journal_id" options="{'no_open': True, 'no_create': True}"/> </div> + <div class="o_setting_right_pane"> + <label for="contribution_default_payment_term_id"/> + <div class="text-muted"> + Conditions de paiement par défault + </div> + <field name="contribution_default_payment_term_id" options="{'no_open': True, 'no_create': True}"/> + </div> <div class="o_setting_left_pane"/> <div class="o_setting_right_pane"> <label for="tag_cotiz_id"/> -- GitLab