<commit_before># -*- coding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Management Solution
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

import time
from lxml import etree

from openerp.osv import fields, osv
from openerp import tools
from openerp.tools.translate import _

class one2many_mod2(fields.one2many):
    def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
        if context is None:
            context = {}
        res = {}
        for id in ids:
            res[id] = []
        ids2 = None
        if 'journal_id' in context:
            journal = obj.pool.get('account.journal').browse(cr, user, context['journal_id'], context=context)
            pnum = int(name[7]) -1
            plan = journal.plan_id
            if plan and len(plan.plan_ids) > pnum:
                acc_id = plan.plan_ids[pnum].root_analytic_id.id
                ids2 = obj.pool[self._obj].search(cr, user, [(self._fields_id,'in',ids),('analytic_account_id','child_of',[acc_id])], limit=self._limit)
        if ids2 is None:
            ids2 = obj.pool[self._obj].search(cr, user, [(self._fields_id,'in',ids)], limit=self._limit)
        for r in obj.pool[self._obj]._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'):
            res[r[self._fields_id]].append( r['id'] )
        return res

class account_analytic_line(osv.osv):
    _inherit = 'account.analytic.line'
    _description = 'Analytic Line'

    def _get_amount(self, cr, uid, ids, name, args, context=None):
        res = {}
        for id in ids:
            res.setdefault(id, 0.0)
        for line in self.browse(cr, uid, ids, context=context):
            amount = line.move_id and line.move_id.amount_currency * (line.percentage / 100) or 0.0
            res[line.id] = amount
        return res

    _columns = {
        'amount_currency': fields.function(_get_amount, string="Amount Currency", type="float", store=True, help="The amount expressed in the related account currency if not equal to the company one.", readonly=True),
        'percentage': fields.float('Percentage')
    }


class account_analytic_plan(osv.osv):
    _name = "account.analytic.plan"
    _description = "Analytic Plan"
    _columns = {
        'name': fields.char('Analytic Plan', size=64, required=True, select=True),
        'plan_ids': fields.one2many('account.analytic.plan.line', 'plan_id', 'Analytic Plans'),
    }


class account_analytic_plan_line(osv.osv):
    _name = "account.analytic.plan.line"
    _description = "Analytic Plan Line"
    _order = "sequence, id"
    _columns = {
        'plan_id': fields.many2one('account.analytic.plan','Analytic Plan',required=True),
        'name': fields.char('Plan Name', size=64, required=True, select=True),
        'sequence': fields.integer('Sequence'),
        'root_analytic_id': fields.many2one('account.analytic.account', 'Root Account', help="Root account of this plan.", required=False),
        'min_required': fields.float('Minimum Allowed (%)'),
        'max_required': fields.float('Maximum Allowed (%)'),
    }
    _defaults = {
        'min_required': 100.0,
        'max_required': 100.0,
    }


class account_analytic_plan_instance(osv.osv):
    _name = "account.analytic.plan.instance"<commit_msg>[FIX] Account analytic plan line name..<commit_after># -*- coding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Management Solution
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

import time
from lxml import etree

from openerp.osv import fields, osv
from openerp import tools
from openerp.tools.translate import _

class one2many_mod2(fields.one2many):
    def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
        if context is None:
            context = {}
        res = {}
        for id in ids:
            res[id] = []
        ids2 = None
        if 'journal_id' in context:
            journal = obj.pool.get('account.journal').browse(cr, user, context['journal_id'], context=context)
            pnum = int(name[7]) -1
            plan = journal.plan_id
            if plan and len(plan.plan_ids) > pnum:
                acc_id = plan.plan_ids[pnum].root_analytic_id.id
                ids2 = obj.pool[self._obj].search(cr, user, [(self._fields_id,'in',ids),('analytic_account_id','child_of',[acc_id])], limit=self._limit)
        if ids2 is None:
            ids2 = obj.pool[self._obj].search(cr, user, [(self._fields_id,'in',ids)], limit=self._limit)
        for r in obj.pool[self._obj]._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'):
            res[r[self._fields_id]].append( r['id'] )
        return res

class account_analytic_line(osv.osv):
    _inherit = 'account.analytic.line'
    _description = 'Analytic Line'

    def _get_amount(self, cr, uid, ids, name, args, context=None):
        res = {}
        for id in ids:
            res.setdefault(id, 0.0)
        for line in self.browse(cr, uid, ids, context=context):
            amount = line.move_id and line.move_id.amount_currency * (line.percentage / 100) or 0.0
            res[line.id] = amount
        return res

    _columns = {
        'amount_currency': fields.function(_get_amount, string="Amount Currency", type="float", store=True, help="The amount expressed in the related account currency if not equal to the company one.", readonly=True),
        'percentage': fields.float('Percentage')
    }


class account_analytic_plan(osv.osv):
    _name = "account.analytic.plan"
    _description = "Analytic Plan"
    _columns = {
        'name': fields.char('Analytic Plan', size=64, required=True, select=True),
        'plan_ids': fields.one2many('account.analytic.plan.line', 'plan_id', 'Analytic Plans'),
    }


class account_analytic_plan_line(osv.osv):
    _name = "account.analytic.plan.line"
    _description = "Analytic Plan Line"
    _order = "sequence, id"
    _columns = {
        'plan_id': fields.many2one('account.analytic.plan','Analytic Plan',required=True),
        'name': fields.char('Axis Name', size=64, required=True, select=True),
        'sequence': fields.integer('Sequence'),
        'root_analytic_id': fields.many2one('account.analytic.account', 'Root Account', help="Root account of this plan.", required=False),
        'min_required': fields.float('Minimum Allowed (%)'),
        'max_required': fields.float('Maximum Allowed (%)'),
    }
    _defaults = {
        'min_required': 100.0,
        'max_required': 100.0,
    }


class account_analytic_plan_instance(osv.osv):
    _name = "account.analytic.plan.instance"
{'fraction_non_alphanumeric': 0.15750120598166908, 'fraction_numerical': 0.010371442354076218, 'mean_word_length': 3.218209562563581, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4226050', 'n_tokens_mistral': 2586, 'n_tokens_neox': 2415, 'n_words': 684}