Skip to content
Snippets Groups Projects
__init__.py 1.21 KiB
Newer Older
  • Learn to ignore specific revisions
  • # © 2022 Le Filament (<http://www.le-filament.com>)
    # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
    
    from odoo import SUPERUSER_ID, api
    
    from . import models, report, wizard
    
    
    
    def _configure_journals(cr, registry):
        """Setting journal and property field (if needed)"""
    
        env = api.Environment(cr, SUPERUSER_ID, {})
    
        # if we already have a coa installed, create journal and set property field
    
        company_ids = env["res.company"].search([("chart_template_id", "!=", False)])
    
    
        for company_id in company_ids:
    
            journal_id = (
                env["account.journal"]
                .search(
                    [
                        ("name", "=", "Cotisations"),
                        ("company_id", "=", company_id.id),
                        ("type", "=", "sale"),
                    ],
                    limit=1,
                )
                .id
            )
    
            if not journal_id:
    
                env["account.journal"].create(
                    {
                        "name": "Cotisations",
                        "type": "sale",
                        "code": "COT",
                        "company_id": company_id.id,
                        "show_on_dashboard": False,
                        "sequence": 6,
                    }
                )