From: Ludovic CHEVALIER Date: Fri, 4 Mar 2022 14:28:08 +0000 (+0100) Subject: [PYTHON] +budget customization X-Git-Tag: production~12 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%40%20%27icone_supprimer_signature%27%20=%3E%20%27Delete%20this%20signature%27%2C%20%27icone_valider_signature%27%20=%3E%20%27Validate%20this%20signature%27%2C%20%27image_administrer_rubrique%27%20=%3E%20%27You%20can%20manage%20this%20section%27%2C-%27impossible_modifier_login_auteur%27%20=%3E%20%27Login%20cannot%20be%20changed.%27%2C-%27impossible_modifier_pass_auteur%27%20=%3E%20%27Password%20cannot%20be%20changed.%27%2C%20%27info_1_article%27%20=%3E%20%271%20article%27%2C-%27info_1_article_syndique%27%20=%3E%20%271%20syndicated%20article%27%2C%20%27info_1_auteur%27%20=%3E%20%271%20author%27%2C%20%27info_1_message%27%20=%3E%20%271%20message%27%2C%20%27info_1_mot_cle%27%20=%3E%20%271%20keyword%27%2C%20%27info_1_rubrique%27%20=%3E%20%271%20section%27%2C-%27info_1_site%27%20=%3E%20%271%20site%27%2C%20%27info_1_visiteur%27%20=%3E%20%271%20visitor%27%2C%20%27info_activer_cookie%27%20=%3E%20%27You%20can%20activate%20an%20%3Cb%3Eadministration%20cookie%3C/b%3E%2C%20which%20allows%20you%20%20to%20switch%20easily%20between%20the%20public%20site%20and%20the%20private%20area.%27%2C%20%27info_activer_menu_developpement%27%20=%3E%20%27Show%20the%20Development%20menu%27%2C%20%27info_admin_etre_webmestre%27%20=%3E%20%27Give%20me%20web%20administrator%20rights%27%2C-%27info_admin_gere_rubriques%27%20=%3E%20%27This%20administrator%20manages%20the%20following%20sections:%27%2C-%27info_admin_gere_toutes_rubriques%27%20=%3E%20%27This%20administrator%20manages%20%3Cb%3Eall%20the%20sections%3C/b%3E.%27%2C-%27info_admin_gere_toutes_rubriques_2%27%20=%3E%20%27I%20manage%20%3Cb%3Eall%20the%20sections%3C/b%3E%27%2C%20%27info_admin_je_suis_webmestre%27%20=%3E%20%27I%20am%20a%20%3Cb%3Ewebmaster%3C/b%3E%27%2C%20%27info_admin_statuer_webmestre%27%20=%3E%20%27Give%20webmaster%20rights%20to%20this%20administrator%20%27%2C%20%27info_admin_webmestre%27%20=%3E%20%27This%20administrator%20is%20%3Cb%3Ewebmaster%3C/%27.%20sinon%28find_in_path%28%27css/leaflet.markercluster.css%27%29%2Cfind_in_path%28%27lib/leaflet/plugins/leaflet.markercluster.css%27%29%29%20.%27?a=commitdiff_plain;h=66a75bcaa27668c4af43efffa8286997eb046743;p=burette%2Flhc.git [PYTHON] +budget customization --- diff --git a/__openerp__.py b/__openerp__.py index c0aee7c..d5d5ed5 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -2,7 +2,7 @@ ############################################################################## # # lhc module for OpenERP, Customize OpenERP for L'Heureux Cyclage Copyright -# (C) 2013-2020 L'Heureux Cyclage () +# (C) 2013-2022 L'Heureux Cyclage () # # This file is a part of lhc_custom_oe # @@ -33,12 +33,14 @@ Custom module for L'Heureux Cyclage - Customing for professionnal training activities; - Event management optimization; - Add some partners fields; +- Budget module customization; - … """, 'author': 'L\'Heureux Cyclage', 'website': 'http://www.heureux-cyclage.org', 'depends': [ 'account', + 'account_budget', 'analytic', 'document', 'event', diff --git a/lhc.py b/lhc.py index de5776a..494773c 100644 --- a/lhc.py +++ b/lhc.py @@ -2,7 +2,7 @@ ############################################################################## # # lhc module for OpenERP, Customize OpenERP for L'Heureux Cyclage Copyright -# (C) 2013-2020 L'Heureux Cyclage () +# (C) 2013-2022 L'Heureux Cyclage () # # This file is a part of lhc_custom_oe # @@ -24,6 +24,7 @@ from openerp.osv import osv from openerp.osv import orm from openerp.osv import fields +from openerp.tools.translate import _ import openerp.addons.decimal_precision as dp @@ -145,7 +146,7 @@ class event_registration(orm.Model): } def onchange_contact_id(self, cr, uid, ids, contact, partner, context=None): - """Concat phone with mobile phone if exist. If mobile exist and not + """Contcat phone with mobile phone if exist. If mobile exist and not phone, add mobile number""" vals = super(event_registration, self).onchange_contact_id(cr, uid, ids, contact, partner, context) addr_obj = self.pool.get('res.partner') @@ -160,4 +161,37 @@ class event_registration(orm.Model): return vals +class crossovered_budget_lines(orm.Model): + _inherit = 'crossovered.budget.lines' + + def _prac_amt(self, cr, uid, ids, context=None): + """Calculate pratical amount even if there is no analytic account""" + res = {} + result = 0.0 + if context is None: + context = {} + account_obj = self.pool.get('account.account') + + for line in self.browse(cr, uid, ids, context=context): + acc_ids = [x.id for x in line.general_budget_id.account_ids] + if not acc_ids: + raise osv.except_osv(_('Error!'),_("The Budget '%s' has no accounts!") % ustr(line.general_budget_id.name)) + acc_ids = account_obj._get_children_and_consol(cr, uid, acc_ids, context=context) + date_to = line.date_to + date_from = line.date_from + + if line.analytic_account_id.id: + res = super(crossovered_budget_lines, self)._prac_amt(cr, uid, ids, context) + else: + cr.execute("SELECT SUM(credit) - SUM(debit) FROM account_move_line WHERE (date " + "between to_date(%s,'yyyy-mm-dd') AND to_date(%s,'yyyy-mm-dd')) AND " + "account_id=ANY(%s)", (date_from, date_to,acc_ids,)) + result = cr.fetchone()[0] + if result is None: + result = 0.00 + res[line.id] = result + + return res + + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: