Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 59d0eb6d6f18caf809e04f1bf652418bcde5b863
  • 12.0-evo-202003 par défaut
  • 14-RV-20250324
  • 14-RV-20240830
  • 14-RV-20231222
  • 12-RV-Bug_ecrasement_date_radiation
  • 12-RV-revision-staff
  • 12-RV-copadev
  • 12-RV-Correctif-open-instagram
  • 12-RV-Tree-Coop-Ajout-effectif
  • 12.0-RV-Instagram
  • 12.0-RV-segment_visibility
  • 12.0 protégée
  • 12.0-RV-Abonnements
14 résultats

res_partner.py

Blame
  • Bifurcation depuis Le Filament / Confédération Générale des SCOP / cgscop_partner
    Le projet source a une visibilité limitée.
    account_move.py 2,68 Kio
    # © 2021 Le Filament (<http://www.le-filament.com>)
    # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
    
    from odoo import fields, models
    
    
    class ScopAccountMove(models.Model):
        _inherit = "account.move"
    
        bordereau_id = fields.Many2one(
            comodel_name="scop.bordereau",
            string="Bordereau de rattachement",
            ondelete="cascade",
            required=False,
        )
        cotisation_cg_id = fields.Many2one(related="bordereau_id.base_cotisation_cg")
        amount_cg_calculated = fields.Monetary(
            string="Montant cotisation annuel",
            currency_field="company_currency_id",
            readonly=True,
        )
        nb_quarter = fields.Selection(related="bordereau_id.nb_quarter")
        cotiz_quarter = fields.Selection(
            string="Trimestre",
            selection=[("1", "1"), ("2", "2"), ("3", "3"), ("4", "4")],
            required=False,
        )
        amount_called = fields.Monetary(
            string="Montant Appelé",
            currency_field="company_currency_id",
            compute="_compute_amount_called",
        )
        refund_contribution_type = fields.Selection(
            [
                ("correction", "Correction"),
                ("exemption", "Exonération"),
                ("cancel", "Annulation"),
            ],
            string="Type d'avoir de cotisation",
        )
    
        # ------------------------------------------------------
        # Compute fields
        # ------------------------------------------------------
        def _compute_amount_called(self):
            for invoice in self:
                if invoice.move_type == "out_invoice":
                    payment_ids = invoice.move_line_payment_ids
                    refund_ids = payment_ids.mapped("move_id").filtered(
                        lambda r: r.move_type == "out_refund"
                    )
                    invoice.amount_called = invoice.amount_total_signed + sum(
                        refund_ids.mapped("amount_total_signed")
                    )
                else:
                    invoice.amount_called = 0
    
        # ------------------------------------------------------
        # Override parent
        # ------------------------------------------------------
    
        # ------------------------------------------------------
        # Actions buttons
        # ------------------------------------------------------
        def reset_bordereau(self):
            self.ensure_one()
            self.bordereau_id = False
    
        def view_cotiz(self):
            form_view = self.env.ref(
                "cgscop_cotisation_cg.invoice_form_scop_cg_inherited"
            ).id
            return {
                "name": "Cotisation",
                "type": "ir.actions.act_window",
                "res_model": "account.move",
                "views": [[form_view, "form"]],
                "res_id": self.id,
                "target": "current",
            }