diff --git a/models/res_company.py b/models/res_company.py index c356d0c3796995d44d523e843b25475b116037a8..f3466180e9f570be6977378f3d5db8be9859241c 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 55d713f81eacd6b9e6c5051aba845cea2579991f..714396c9f305f40bc63cea3d1a355e7b04d36ce1 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 d1b34e6fac987671624ded69ce7752e99c6d8503..1297deb6cbc48edcea4aa7229683bc35dd19da12 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 f97b36ad4962d78d1d9b9c34cb8c4f2cad56bcc7..3cd000f26b42bf369c2f52e148ec125fe2dd6de2 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"/>