From aebad6a8ee1afaf23dcc2777e93aee7c5e6996df Mon Sep 17 00:00:00 2001 From: eLBati Date: Tue, 30 Aug 2011 10:55:33 +0200 Subject: [PATCH 001/278] [FIX] http://wiki.openerp-italia.org/doku.php/moduli/l10n_it_iva_indetraibile [FIX] https://bugs.launchpad.net/openobject-italia/+bug/836847 bzr revid: lorenzo.battistini@agilebg.com-20110830085533-3tmpd2ai12exc9ai --- addons/l10n_it/__init__.py | 11 +- addons/l10n_it/__openerp__.py | 9 +- addons/l10n_it/account.py | 56 ++ addons/l10n_it/data/account.tax.template.csv | 86 +-- addons/l10n_it/i18n/it.po | 179 +---- addons/l10n_it/i18n/l10n_it.pot | 137 +--- addons/l10n_it/libroIVA.py | 54 -- addons/l10n_it/libroIVA_menu.xml | 16 - addons/l10n_it/libroIVA_view.xml | 47 -- addons/l10n_it/report.xml | 24 - addons/l10n_it/report/__init__.py | 2 - addons/l10n_it/report/libroIVA_credito.py | 79 --- addons/l10n_it/report/libroIVA_credito.rml | 203 ------ addons/l10n_it/report/libroIVA_debito.py | 80 --- addons/l10n_it/report/libroIVA_debito.rml | 195 ------ addons/l10n_it/report/normalized_oo2rml.xsl | 696 ------------------- addons/l10n_it/security/ir.model.access.csv | 3 - 17 files changed, 147 insertions(+), 1730 deletions(-) create mode 100644 addons/l10n_it/account.py delete mode 100644 addons/l10n_it/libroIVA.py delete mode 100644 addons/l10n_it/libroIVA_menu.xml delete mode 100644 addons/l10n_it/libroIVA_view.xml delete mode 100644 addons/l10n_it/report.xml delete mode 100644 addons/l10n_it/report/__init__.py delete mode 100644 addons/l10n_it/report/libroIVA_credito.py delete mode 100644 addons/l10n_it/report/libroIVA_credito.rml delete mode 100644 addons/l10n_it/report/libroIVA_debito.py delete mode 100644 addons/l10n_it/report/libroIVA_debito.rml delete mode 100644 addons/l10n_it/report/normalized_oo2rml.xsl delete mode 100644 addons/l10n_it/security/ir.model.access.csv diff --git a/addons/l10n_it/__init__.py b/addons/l10n_it/__init__.py index 026004bfa0f..f9126cd880e 100644 --- a/addons/l10n_it/__init__.py +++ b/addons/l10n_it/__init__.py @@ -1,13 +1,15 @@ -# -*- encoding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2010 -# Italian OpenERP Community () +# OpenERP Italian Community () # Servabit srl # Agile Business Group sagl # Domsense srl -# Albatos srl +# Albatos srl +# +# Copyright (C) 2011 +# Associazione OpenERP Italia () # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -24,5 +26,4 @@ # ############################################################################## -import libroIVA -import report +import account diff --git a/addons/l10n_it/__openerp__.py b/addons/l10n_it/__openerp__.py index 41161f67a70..0be022a6a80 100644 --- a/addons/l10n_it/__openerp__.py +++ b/addons/l10n_it/__openerp__.py @@ -3,12 +3,15 @@ # # OpenERP, Open Source Management Solution # Copyright (C) 2010 -# Italian OpenERP Community () +# OpenERP Italian Community () # Servabit srl # Agile Business Group sagl # Domsense srl # Albatos srl # +# Copyright (C) 2011 +# Associazione OpenERP Italia () +# # 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 @@ -39,9 +42,6 @@ Italian accounting chart and localization. "category" : "Finance", 'website': 'http://www.openerp-italia.org/', 'init_xml': [ - 'report.xml', - 'libroIVA_view.xml', - 'libroIVA_menu.xml', ], 'update_xml': [ 'data/account.account.type.csv', @@ -51,7 +51,6 @@ Italian accounting chart and localization. 'data/account.tax.template.csv', 'data/account.fiscal.position.template.csv', 'l10n_chart_it_generic.xml', - 'security/ir.model.access.csv', ], 'demo_xml': [ ], diff --git a/addons/l10n_it/account.py b/addons/l10n_it/account.py new file mode 100644 index 00000000000..98e4d5ae68b --- /dev/null +++ b/addons/l10n_it/account.py @@ -0,0 +1,56 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2011 +# Associazione OpenERP Italia () +# +# 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 . +# +############################################################################## + +from osv import fields, osv +import decimal_precision as dp +from decimal import * + +class account_tax(osv.osv): + + _inherit = 'account.tax' + + def compute_all(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None): + res = super(account_tax, self).compute_all(cr, uid, taxes, price_unit, quantity, address_id, product, partner) + + precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account') + tax_list = res['taxes'] + totalex = res['total'] + if len(tax_list) == 2: + for tax in tax_list: + if tax.get('balance',False): # Calcolo di imponibili e imposte per l'IVA parzialmente detraibile + deductible_base = totalex + ind_tax = tax_list[abs(tax_list.index(tax)-1)] + ind_tax_obj = self.browse(cr, uid, ind_tax['id']) + ded_tax_obj = self.browse(cr, uid, tax['id']) + base_ind = float(Decimal(str(totalex * ind_tax_obj.amount)).quantize(Decimal('1.'+precision*'0'), rounding=ROUND_HALF_UP)) + base_ded = float(Decimal(str(totalex - base_ind)).quantize(Decimal('1.'+precision*'0'), rounding=ROUND_HALF_UP)) + tax_total = float(Decimal(str(tax['balance'])).quantize(Decimal('1.'+precision*'0'), rounding=ROUND_HALF_UP)) + tax_ind = float(Decimal(str(tax_total * ind_tax_obj.amount)).quantize(Decimal('1.'+precision*'0'), rounding=ROUND_HALF_UP)) + tax_ded = tax_total - tax_ind + ind_tax['price_unit'] = base_ind + tax['price_unit'] = base_ded + ind_tax['amount'] = tax_ind + tax['amount'] = tax_ded + + return res + +account_tax() diff --git a/addons/l10n_it/data/account.tax.template.csv b/addons/l10n_it/data/account.tax.template.csv index cf9caeeb0d4..5be051ed009 100644 --- a/addons/l10n_it/data/account.tax.template.csv +++ b/addons/l10n_it/data/account.tax.template.csv @@ -1,40 +1,46 @@ -"id","description","chart_template_id:id","name","amount","parent_id:id","child_depend","type","account_collected_id:id","account_paid_id:id","type_tax_use","base_code_id:id","tax_code_id:id","ref_base_code_id:id","ref_tax_code_id:id" -"20a","20a","l10n_it_chart_template_generic","Iva al 20% (debito)","0.2",,"False","percent","2601","2601","sale","template_impcode_riscossa_20","template_ivacode_riscossa_20","template_impcode_riscossa_20","template_ivacode_riscossa_20" -"20b","20b","l10n_it_chart_template_generic","Iva al 20% (credito)","0.2",,"False","percent","1601","1601","purchase","template_impcode_pagata_20","template_ivacode_pagata_20","template_impcode_pagata_20","template_ivacode_pagata_20" -"10a","10a","l10n_it_chart_template_generic","Iva al 10% (debito)","0.1",,"False","percent","2601","2601","sale","template_impcode_riscossa_10","template_ivacode_riscossa_10","template_impcode_riscossa_10","template_ivacode_riscossa_10" -"10b","10b","l10n_it_chart_template_generic","Iva al 10% (credito)","0.1",,"False","percent","1601","1601","purchase","template_impcode_pagata_10","template_ivacode_pagata_10","template_impcode_pagata_10","template_ivacode_pagata_10" -"10AO","10AO","l10n_it_chart_template_generic","Iva al 10% indetraibile","1",,"True","percent",,,"purchase",,,, -"10AOa","10AOa","l10n_it_chart_template_generic","Iva al 10% indetraibile (1)","0","10AO","False","percent","1601","1601","purchase","template_impcode_pagata_10ind","template_ivacode_pagata_10ind","template_impcode_pagata_10ind","template_ivacode_pagata_10ind" -"10AOb","10AOb","l10n_it_chart_template_generic","Iva al 10% indetraibile (2)","0.1","10AO","False","percent",,,"purchase",,,, -"12a","12a","l10n_it_chart_template_generic","Iva 12% (debito)","0.12",,"False","percent","2601","2601","sale","template_impcode_riscossa_12","template_ivacode_riscossa_12","template_impcode_riscossa_12","template_ivacode_riscossa_12" -"12b","12b","l10n_it_chart_template_generic","Iva 12% (credito)","0.12",,"False","percent","1601","1601","purchase","template_impcode_pagata_12","template_ivacode_pagata_12","template_impcode_pagata_12","template_ivacode_pagata_12" -"2010","2010","l10n_it_chart_template_generic","Iva al 20% detraibile 10%","1",,"True","percent",,,"purchase",,,, -"2010a","2010a","l10n_it_chart_template_generic","Iva al 20% detraibile 10% (1)","0.02","2010","False","percent","1601","1601","purchase","template_impcode_pagata_20det10","template_ivacode_pagata_20det10","template_impcode_pagata_20det10","template_ivacode_pagata_20det10" -"2010b","2010b","l10n_it_chart_template_generic","Iva al 20% detraibile 10% (2)","0.18","2010","False","percent",,,"purchase",,,, -"2015","2015","l10n_it_chart_template_generic","Iva al 20% detraibile 15%","1",,"True","percent",,,"purchase",,,, -"2015a","2015a","l10n_it_chart_template_generic","Iva al 20% detraibile 15% (1)","0.03","2015","False","percent","1601","1601","purchase","template_impcode_pagata_20det15","template_ivacode_pagata_20det15","template_impcode_pagata_20det15","template_ivacode_pagata_20det15" -"2015b","2015b","l10n_it_chart_template_generic","Iva al 20% detraibile 15% (2)","0.17","2015","False","percent",,,"purchase",,,, -"2040","2040","l10n_it_chart_template_generic","Iva al 20% detraibile 40%","1",,"True","percent",,,"purchase",,,, -"2040a","2040a","l10n_it_chart_template_generic","Iva al 20% detraibile 40% (1)","0.08","2040","False","percent","1601","1601","purchase","template_impcode_pagata_20det40","template_ivacode_pagata_20det40","template_impcode_pagata_20det40","template_ivacode_pagata_20det40" -"2040b","2040b","l10n_it_chart_template_generic","Iva al 20% detraibile 40% (2)","0.12","2040","False","percent",,,"purchase",,,, -"20AO","20AO","l10n_it_chart_template_generic","Iva al 20% indetraibile","1",,"True","percent",,,"purchase",,,, -"20AOa","20AOa","l10n_it_chart_template_generic","Iva al 20% indetraibile (1)","0","20AO","False","percent","1601","1601","purchase","template_impcode_pagata_20ind","template_ivacode_pagata_20ind","template_impcode_pagata_20ind","template_ivacode_pagata_20ind" -"20AOb","20AOb","l10n_it_chart_template_generic","Iva al 20% indetraibile (2)","0.2","20AO","False","percent",,,"purchase",,,, -"20I5","20I5","l10n_it_chart_template_generic","IVA al 20% detraibile al 50%","1",,"True","percent",,,"purchase",,,, -"20I5a","20I5a","l10n_it_chart_template_generic","IVA al 20% detraibile al 50% (1)","0.1","20I5","False","percent","1601","1601","purchase","template_impcode_pagata_20det50","template_ivacode_pagata_20det50","template_impcode_pagata_20det50","template_ivacode_pagata_20det50" -"20I5b","20I5b","l10n_it_chart_template_generic","IVA al 20% detraibile al 50% (2)","0.1","20I5","False","percent",,,"purchase",,,, -"22a","22a","l10n_it_chart_template_generic","Iva 2% (debito)","0.02",,"False","percent","2601","2601","sale","template_impcode_riscossa_2","template_ivacode_riscossa_2","template_impcode_riscossa_2","template_ivacode_riscossa_2" -"22b","22b","l10n_it_chart_template_generic","Iva 2% (credito)","0.02",,"False","percent","1601","1601","purchase","template_impcode_pagata_2","template_ivacode_pagata_2","template_impcode_pagata_2","template_ivacode_pagata_2" -"4a","4a","l10n_it_chart_template_generic","Iva 4% (debito)","0.04",,"False","percent","2601","2601","sale","template_impcode_riscossa_4","template_ivacode_riscossa_4","template_impcode_riscossa_4","template_ivacode_riscossa_4" -"4b","4b","l10n_it_chart_template_generic","Iva 4% (credito)","0.04",,"False","percent","1601","1601","purchase","template_impcode_pagata_4","template_ivacode_pagata_4","template_impcode_pagata_4","template_ivacode_pagata_4" -"4AO","4AO","l10n_it_chart_template_generic","Iva al 4% indetraibile","1",,"True","percent",,,"purchase",,,, -"4AOa","4AOa","l10n_it_chart_template_generic","Iva al 4% indetraibile (1)","0","4AO","False","percent","1601","1601","purchase","template_impcode_pagata_4ind","template_ivacode_pagata_4ind","template_impcode_pagata_4ind","template_ivacode_pagata_4ind" -"4AOb","4AOb","l10n_it_chart_template_generic","Iva al 4% indetraibile (2)","0.04","4AO","False","percent",,,"purchase",,,, -"10I5","10I5","l10n_it_chart_template_generic","IVA al 10% detraibile al 50%","1",,"True","percent",,,"purchase",,,, -"10I5a","10I5a","l10n_it_chart_template_generic","IVA al 10% detraibile al 50% (1)","0.05","10I5","False","percent","1601","1601","purchase","template_impcode_pagata_10det50","template_ivacode_pagata_10det50","template_impcode_pagata_10det50","template_ivacode_pagata_10det50" -"10I5b","10I5b","l10n_it_chart_template_generic","IVA al 10% detraibile al 50% (2)","0.05","10I5","False","percent",,,"purchase",,,, -"4I5","4I5","l10n_it_chart_template_generic","IVA al 4% detraibile al 50%","1",,"True","percent",,,"purchase",,,, -"4I5a","4I5a","l10n_it_chart_template_generic","IVA al 4% detraibile al 50% (1)","0.02","4I5","False","percent","1601","1601","purchase","template_impcode_pagata_4det50","template_ivacode_pagata_4det50","template_impcode_pagata_4det50","template_ivacode_pagata_4det50" -"4I5b","4I5b","l10n_it_chart_template_generic","IVA al 4% detraibile al 50% (2)","0.02","4I5","False","percent",,,"purchase",,,, -"00a","00a","l10n_it_chart_template_generic","Esente IVA (debito)","0",,"False","percent","2601","2601","sale","template_impcode_riscossa_0","template_ivacode_riscossa_0","template_impcode_riscossa_0","template_ivacode_riscossa_0" -"00b","00b","l10n_it_chart_template_generic","Esente IVA (credito)","0",,"False","percent","1601","1601","purchase","template_impcode_pagata_0","template_ivacode_pagata_0","template_impcode_pagata_0","template_ivacode_pagata_0" +"id","description","chart_template_id:id","name","sequence","amount","parent_id:id","child_depend","type","account_collected_id:id","account_paid_id:id","type_tax_use","base_code_id:id","tax_code_id:id","ref_base_code_id:id","ref_tax_code_id:id","ref_base_sign","ref_tax_sign","price_include" +"20a","20a","l10n_it_chart_template_generic","Iva al 20% (debito)",,"0.2",,"False","percent","2601","2601","sale","template_impcode_riscossa_20","template_ivacode_riscossa_20","template_impcode_riscossa_20","template_ivacode_riscossa_20",-1,-1,"False" +"20b","20b","l10n_it_chart_template_generic","Iva al 20% (credito)",,"0.2",,"False","percent","1601","1601","purchase","template_impcode_pagata_20","template_ivacode_pagata_20","template_impcode_pagata_20","template_ivacode_pagata_20",-1,-1,"False" +"10a","10a","l10n_it_chart_template_generic","Iva al 10% (debito)",,"0.1",,"False","percent","2601","2601","sale","template_impcode_riscossa_10","template_ivacode_riscossa_10","template_impcode_riscossa_10","template_ivacode_riscossa_10",-1,-1,"False" +"10b","10b","l10n_it_chart_template_generic","Iva al 10% (credito)",,"0.1",,"False","percent","1601","1601","purchase","template_impcode_pagata_10","template_ivacode_pagata_10","template_impcode_pagata_10","template_ivacode_pagata_10",-1,-1,"False" +"10AO","10AO","l10n_it_chart_template_generic","Iva al 10% indetraibile",,"0.1",,"True","percent",,,"purchase","template_impcode_pagata_10ind",,"template_impcode_pagata_10ind",,-1,,"False" +"10AOa","10AOa","l10n_it_chart_template_generic","Iva al 10% indetraibile (D)","2","0","10AO","False","balance","1601","1601","purchase",,"template_ivacode_pagata_10ind",,"template_ivacode_pagata_10ind",,-1,"False" +"10AOb","10AOb","l10n_it_chart_template_generic","Iva al 10% indetraibile (I)","1","1","10AO","False","percent",,,"purchase",,,,,,,"False" +"12a","12a","l10n_it_chart_template_generic","Iva 12% (debito)",,"0.12",,"False","percent","2601","2601","sale","template_impcode_riscossa_12","template_ivacode_riscossa_12","template_impcode_riscossa_12","template_ivacode_riscossa_12",-1,-1,"False" +"12b","12b","l10n_it_chart_template_generic","Iva 12% (credito)",,"0.12",,"False","percent","1601","1601","purchase","template_impcode_pagata_12","template_ivacode_pagata_12","template_impcode_pagata_12","template_ivacode_pagata_12",-1,-1,"False" +"2010","2010","l10n_it_chart_template_generic","Iva al 20% detraibile 10%",,"0.2",,"True","percent",,,"purchase","template_impcode_pagata_20det10",,"template_impcode_pagata_20det10",,-1,,"False" +"2010a","2010a","l10n_it_chart_template_generic","Iva al 20% detraibile 10% (D)","2","0","2010","False","balance","1601","1601","purchase",,"template_ivacode_pagata_20det10",,"template_ivacode_pagata_20det10",,-1,"False" +"2010b","2010b","l10n_it_chart_template_generic","Iva al 20% detraibile 10% (I)","1","0.9","2010","False","percent",,,"purchase",,,,,,,"False" +"2015","2015","l10n_it_chart_template_generic","Iva al 20% detraibile 15%",,"0.2",,"True","percent",,,"purchase","template_impcode_pagata_20det15",,"template_impcode_pagata_20det15",,-1,,"False" +"2015a","2015a","l10n_it_chart_template_generic","Iva al 20% detraibile 15% (D)","2","0","2015","False","balance","1601","1601","purchase",,"template_ivacode_pagata_20det15",,"template_ivacode_pagata_20det15",,-1,"False" +"2015b","2015b","l10n_it_chart_template_generic","Iva al 20% detraibile 15% (I)","1","0.85","2015","False","percent",,,"purchase",,,,,,,"False" +"2040","2040","l10n_it_chart_template_generic","Iva al 20% detraibile 40%",,"0.2",,"True","percent",,,"purchase","template_impcode_pagata_20det40",,"template_impcode_pagata_20det40",,-1,,"False" +"2040a","2040a","l10n_it_chart_template_generic","Iva al 20% detraibile 40% (D)","2","0","2040","False","balance","1601","1601","purchase",,"template_ivacode_pagata_20det40",,"template_ivacode_pagata_20det40",,-1,"False" +"2040b","2040b","l10n_it_chart_template_generic","Iva al 20% detraibile 40% (I)","1","0.6","2040","False","percent",,,"purchase",,,,,,,"False" +"20AO","20AO","l10n_it_chart_template_generic","Iva al 20% indetraibile",,"0.2",,"True","percent",,,"purchase","template_impcode_pagata_20ind",,"template_impcode_pagata_20ind",,-1,,"False" +"20AOa","20AOa","l10n_it_chart_template_generic","Iva al 20% indetraibile (D)","2","0","20AO","False","balance","1601","1601","purchase",,"template_ivacode_pagata_20ind",,"template_ivacode_pagata_20ind",,-1,"False" +"20AOb","20AOb","l10n_it_chart_template_generic","Iva al 20% indetraibile (I)","1","1","20AO","False","percent",,,"purchase",,,,,,,"False" +"20I5","20I5","l10n_it_chart_template_generic","IVA al 20% detraibile al 50%",,"0.2",,"True","percent",,,"purchase","template_impcode_pagata_20det50",,"template_impcode_pagata_20det50",,-1,,"False" +"20I5b","20I5b","l10n_it_chart_template_generic","IVA al 20% detraibile al 50% (I)","1","0.5","20I5","False","percent",,,"purchase",,,,,,,"False" +"20I5a","20I5a","l10n_it_chart_template_generic","IVA al 20% detraibile al 50% (D)","2","0","20I5","False","balance","1601","1601","purchase",,"template_ivacode_pagata_20det50",,"template_ivacode_pagata_20det50",,-1,"False" +"22a","22a","l10n_it_chart_template_generic","Iva 2% (debito)",,"0.02",,"False","percent","2601","2601","sale","template_impcode_riscossa_2","template_ivacode_riscossa_2","template_impcode_riscossa_2","template_ivacode_riscossa_2",-1,-1,"False" +"22b","22b","l10n_it_chart_template_generic","Iva 2% (credito)",,"0.02",,"False","percent","1601","1601","purchase","template_impcode_pagata_2","template_ivacode_pagata_2","template_impcode_pagata_2","template_ivacode_pagata_2",-1,-1,"False" +"4a","4a","l10n_it_chart_template_generic","Iva 4% (debito)",,"0.04",,"False","percent","2601","2601","sale","template_impcode_riscossa_4","template_ivacode_riscossa_4","template_impcode_riscossa_4","template_ivacode_riscossa_4",-1,-1,"False" +"4b","4b","l10n_it_chart_template_generic","Iva 4% (credito)",,"0.04",,"False","percent","1601","1601","purchase","template_impcode_pagata_4","template_ivacode_pagata_4","template_impcode_pagata_4","template_ivacode_pagata_4",-1,-1,"False" +"4AO","4AO","l10n_it_chart_template_generic","Iva al 4% indetraibile",,"0.04",,"True","percent",,,"purchase","template_impcode_pagata_4ind",,"template_impcode_pagata_4ind",,-1,,"False" +"4AOa","4AOa","l10n_it_chart_template_generic","Iva al 4% indetraibile (D)","2","0","4AO","False","balance","1601","1601","purchase",,"template_ivacode_pagata_4ind",,"template_ivacode_pagata_4ind",,-1,"False" +"4AOb","4AOb","l10n_it_chart_template_generic","Iva al 4% indetraibile (I)","1","1","4AO","False","percent",,,"purchase",,,,,,,"False" +"10I5","10I5","l10n_it_chart_template_generic","IVA al 10% detraibile al 50%",,"0.1",,"True","percent",,,"purchase","template_impcode_pagata_10det50",,"template_impcode_pagata_10det50",,-1,,"False" +"10I5a","10I5a","l10n_it_chart_template_generic","IVA al 10% detraibile al 50% (D)","2","0","10I5","False","balance","1601","1601","purchase",,"template_ivacode_pagata_10det50",,"template_ivacode_pagata_10det50",,-1,"False" +"10I5b","10I5b","l10n_it_chart_template_generic","IVA al 10% detraibile al 50% (I)","1","0.5","10I5","False","percent",,,"purchase",,,,,,,"False" +"4I5","4I5","l10n_it_chart_template_generic","IVA al 4% detraibile al 50%",,"0.04",,"True","percent",,,"purchase","template_impcode_pagata_4det50",,"template_impcode_pagata_4det50",,-1,,"False" +"4I5a","4I5a","l10n_it_chart_template_generic","IVA al 4% detraibile al 50% (D)","2","0","4I5","False","balance","1601","1601","purchase",,"template_ivacode_pagata_4det50",,"template_ivacode_pagata_4det50",,-1,"False" +"4I5b","4I5b","l10n_it_chart_template_generic","IVA al 4% detraibile al 50% (I)","1","0.5","4I5","False","percent",,,"purchase",,,,,,,"False" +"00a","00a","l10n_it_chart_template_generic","Esente IVA (debito)",,"0",,"False","percent","2601","2601","sale","template_impcode_riscossa_0","template_ivacode_riscossa_0","template_impcode_riscossa_0","template_ivacode_riscossa_0",-1,-1,"False" +"00b","00b","l10n_it_chart_template_generic","Esente IVA (credito)",,"0",,"False","percent","1601","1601","purchase","template_impcode_pagata_0","template_ivacode_pagata_0","template_impcode_pagata_0","template_ivacode_pagata_0",-1,-1,"False" +"20a INC","20a INC","l10n_it_chart_template_generic","Iva al 20% (debito) INC",,"0.2",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_20","l10n_it.template_ivacode_riscossa_20","l10n_it.template_impcode_riscossa_20","l10n_it.template_ivacode_riscossa_20",-1,-1,"True" +"10a INC","10a INC","l10n_it_chart_template_generic","Iva al 10% (debito) INC",,"0.1",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_10","l10n_it.template_ivacode_riscossa_10","l10n_it.template_impcode_riscossa_10","l10n_it.template_ivacode_riscossa_10",-1,-1,"True" +"12a INC","12a INC","l10n_it_chart_template_generic","Iva 12% (debito) INC",,"0.12",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_12","l10n_it.template_ivacode_riscossa_12","l10n_it.template_impcode_riscossa_12","l10n_it.template_ivacode_riscossa_12",-1,-1,"True" +"22a INC","22a INC","l10n_it_chart_template_generic","Iva 2% (debito) INC",,"0.02",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_2","l10n_it.template_ivacode_riscossa_2","l10n_it.template_impcode_riscossa_2","l10n_it.template_ivacode_riscossa_2",-1,-1,"True" +"4a INC","4a INC","l10n_it_chart_template_generic","Iva 4% (debito) INC",,"0.04",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_4","l10n_it.template_ivacode_riscossa_4","l10n_it.template_impcode_riscossa_4","l10n_it.template_ivacode_riscossa_4",-1,-1,"True" +"00a INC","00a INC","l10n_it_chart_template_generic","Esente IVA (debito) INC",,"0",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_0","l10n_it.template_ivacode_riscossa_0","l10n_it.template_impcode_riscossa_0","l10n_it.template_ivacode_riscossa_0",-1,-1,"True" diff --git a/addons/l10n_it/i18n/it.po b/addons/l10n_it/i18n/it.po index 817a7e64b77..de209ab08fc 100644 --- a/addons/l10n_it/i18n/it.po +++ b/addons/l10n_it/i18n/it.po @@ -1,174 +1,43 @@ -# Italian translation for openobject-addons -# Copyright (c) 2011 Rosetta Contributors and Canonical Ltd 2011 -# This file is distributed under the same license as the openobject-addons package. -# FIRST AUTHOR , 2011. +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * l10n_it # msgid "" msgstr "" -"Project-Id-Version: openobject-addons\n" -"Report-Msgid-Bugs-To: FULL NAME \n" -"POT-Creation-Date: 2011-01-07 06:04+0000\n" -"PO-Revision-Date: 2011-02-15 15:37+0000\n" -"Last-Translator: FULL NAME \n" -"Language-Team: Italian \n" +"Project-Id-Version: OpenERP Server 6.0.2\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2011-08-11 20:06+0000\n" +"PO-Revision-Date: 2011-08-11 20:06+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-04-29 05:56+0000\n" -"X-Generator: Launchpad (build 12758)\n" - -#. module: l10n_it -#: model:ir.actions.report.xml,name:l10n_it.account_ita_libroIVA_debit -msgid "Registro acquisti" -msgstr "Registro acquisti" - -#. module: l10n_it -#: model:ir.actions.todo,note:l10n_it.config_call_account_template_generic -msgid "" -"Generate Chart of Accounts from a Chart Template. You will be asked to pass " -"the name of the company, the chart template to follow, the no. of digits to " -"generate the code for your accounts and Bank account, currency to create " -"Journals. Thus,the pure copy of chart Template is generated.\n" -"\tThis is the same wizard that runs from Financial " -"Management/Configuration/Financial Accounting/Financial Accounts/Generate " -"Chart of Accounts from a Chart Template." -msgstr "" -"Genera il Piano dei Conti da un Modello. Vi verrà richiesto di passare il " -"nome dell'azienda, il modello da seguire, il numero di decimali per generare " -"il codice dei tuoi conti e, per il conto della Banca, la valuta per creare " -"il Libro Giornale. Così una copia vergine del Piano dei Conti, derivatante " -"dal modello, viene generata.\n" -"\tQuesto è la stessa procedura automatica che viene lanciata da: Gestione " -"Finanziaria / Configurazione / Contabilità / Conti finanziari / Genera il " -"Piano dei conti da un modello." - -#. module: l10n_it -#: view:account.report_libroiva:0 -msgid "Anno Fiscale" -msgstr "Anno Fiscale" - -#. module: l10n_it -#: model:account.fiscal.position.template,name:l10n_it.it -msgid "Italia" -msgstr "Italia" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -#: report:l10n_it.report.libroIVA_debito:0 -msgid "REGISTRO IVA" -msgstr "REGISTRO IVA" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -#: report:l10n_it.report.libroIVA_debito:0 -msgid "Protocollo" -msgstr "Protocollo" - -#. module: l10n_it -#: model:account.fiscal.position.template,name:l10n_it.extra -msgid "Regime Extra comunitario" -msgstr "Regime Extra comunitario" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -msgid "VENDITE" -msgstr "VENDITE" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -#: report:l10n_it.report.libroIVA_debito:0 -msgid "Aliquota" -msgstr "Aliquota" - -#. module: l10n_it -#: field:account.report_libroiva,company_id:0 -msgid "Company" -msgstr "Azienda" - -#. module: l10n_it -#: field:account.report_libroiva,name:0 -msgid "Fiscal year" -msgstr "Anno fiscale" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -#: report:l10n_it.report.libroIVA_debito:0 -msgid "Numero" -msgstr "Numero" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_debito:0 -msgid "Fornitore" -msgstr "Fornitore" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_debito:0 -msgid "ACQUISTI" -msgstr "ACQUISTI" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" #. module: l10n_it #: model:ir.module.module,description:l10n_it.module_meta_information -msgid "" -"\n" +msgid "\n" " Piano dei conti italiano di un'impresa generica\n" " " -msgstr "" -"\n" +msgstr "\n" " Piano dei conti italiano di un'impresa generica\n" " " -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -msgid "Cliente" -msgstr "Cliente" - -#. module: l10n_it -#: model:ir.actions.report.xml,name:l10n_it.account_ita_libroIVA_credit -msgid "Registro vendite" -msgstr "Registro vendite" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -#: report:l10n_it.report.libroIVA_debito:0 -msgid "Periodo" -msgstr "Periodo" - -#. module: l10n_it -#: view:account.report_libroiva:0 -#: model:ir.actions.act_window,name:l10n_it.l10n_chart_it_report_libroIVA_action -#: model:ir.ui.menu,name:l10n_it.menu_report_l10n_chart_it_libroIVA -msgid "Registri IVA" -msgstr "Registri IVA" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -#: report:l10n_it.report.libroIVA_debito:0 -msgid "Imposta" -msgstr "Imposta" - -#. module: l10n_it -#: model:account.fiscal.position.template,name:l10n_it.intra -msgid "Regime Intra comunitario" -msgstr "Regime Intra comunitario" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -#: report:l10n_it.report.libroIVA_debito:0 -msgid "Data fattura" -msgstr "Data fattura" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -#: report:l10n_it.report.libroIVA_debito:0 -msgid "Imponibile" -msgstr "Imponibile" - #. module: l10n_it #: model:ir.module.module,shortdesc:l10n_it.module_meta_information msgid "Italy - Generic Chart of Accounts" msgstr "Italia - Piano dei conti generico" #. module: l10n_it -#: model:ir.model,name:l10n_it.model_account_report_libroiva -msgid "SQL view for libro IVA" -msgstr "Vista SQL per registro IVA" +#: model:ir.actions.todo,note:l10n_it.config_call_account_template_generic +msgid "Generate Chart of Accounts from a Chart Template. You will be asked to pass the name of the company, the chart template to follow, the no. of digits to generate the code for your accounts and Bank account, currency to create Journals. Thus,the pure copy of chart Template is generated.\n" +" This is the same wizard that runs from Financial Management/Configuration/Financial Accounting/Financial Accounts/Generate Chart of Accounts from a Chart Template." +msgstr "Genera il piano dei conti da un template. Verrà chiesto di indicare il nome dell'azienda, il piano dei conti da seguire, il numero di cifre per generare il codice dei conti, la valuta per creare i sezionali. Quindi, una semplice copia del template verrà generata.\n" +" Questo è lo stesso wizard che viene eseguito da Contabilità/Configurazione/Contabilità Generale/Assetto finanziario della nuova azienda" + +#. module: l10n_it +#: model:ir.model,name:l10n_it.model_account_tax +msgid "account.tax" +msgstr "account.tax" + diff --git a/addons/l10n_it/i18n/l10n_it.pot b/addons/l10n_it/i18n/l10n_it.pot index 7f210e4cd75..1c46674bb28 100644 --- a/addons/l10n_it/i18n/l10n_it.pot +++ b/addons/l10n_it/i18n/l10n_it.pot @@ -4,10 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: OpenERP Server 6.0.0-rc2\n" +"Project-Id-Version: OpenERP Server 6.0.2\n" "Report-Msgid-Bugs-To: support@openerp.com\n" -"POT-Creation-Date: 2011-01-07 06:04:30+0000\n" -"PO-Revision-Date: 2011-01-07 06:04:30+0000\n" +"POT-Creation-Date: 2011-08-11 20:06+0000\n" +"PO-Revision-Date: 2011-08-11 20:06+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -15,81 +15,6 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" -#. module: l10n_it -#: model:ir.actions.report.xml,name:l10n_it.account_ita_libroIVA_debit -msgid "Registro acquisti" -msgstr "" - -#. module: l10n_it -#: model:ir.actions.todo,note:l10n_it.config_call_account_template_generic -msgid "Generate Chart of Accounts from a Chart Template. You will be asked to pass the name of the company, the chart template to follow, the no. of digits to generate the code for your accounts and Bank account, currency to create Journals. Thus,the pure copy of chart Template is generated.\n" -" This is the same wizard that runs from Financial Management/Configuration/Financial Accounting/Financial Accounts/Generate Chart of Accounts from a Chart Template." -msgstr "" - -#. module: l10n_it -#: view:account.report_libroiva:0 -msgid "Anno Fiscale" -msgstr "" - -#. module: l10n_it -#: model:account.fiscal.position.template,name:l10n_it.it -msgid "Italia" -msgstr "" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -#: report:l10n_it.report.libroIVA_debito:0 -msgid "REGISTRO IVA" -msgstr "" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -#: report:l10n_it.report.libroIVA_debito:0 -msgid "Protocollo" -msgstr "" - -#. module: l10n_it -#: model:account.fiscal.position.template,name:l10n_it.extra -msgid "Regime Extra comunitario" -msgstr "" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -msgid "VENDITE" -msgstr "" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -#: report:l10n_it.report.libroIVA_debito:0 -msgid "Aliquota" -msgstr "" - -#. module: l10n_it -#: field:account.report_libroiva,company_id:0 -msgid "Company" -msgstr "" - -#. module: l10n_it -#: field:account.report_libroiva,name:0 -msgid "Fiscal year" -msgstr "" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -#: report:l10n_it.report.libroIVA_debito:0 -msgid "Numero" -msgstr "" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_debito:0 -msgid "Fornitore" -msgstr "" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_debito:0 -msgid "ACQUISTI" -msgstr "" - #. module: l10n_it #: model:ir.module.module,description:l10n_it.module_meta_information msgid "\n" @@ -97,59 +22,19 @@ msgid "\n" " " msgstr "" -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -msgid "Cliente" -msgstr "" - -#. module: l10n_it -#: model:ir.actions.report.xml,name:l10n_it.account_ita_libroIVA_credit -msgid "Registro vendite" -msgstr "" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -#: report:l10n_it.report.libroIVA_debito:0 -msgid "Periodo" -msgstr "" - -#. module: l10n_it -#: view:account.report_libroiva:0 -#: model:ir.actions.act_window,name:l10n_it.l10n_chart_it_report_libroIVA_action -#: model:ir.ui.menu,name:l10n_it.menu_report_l10n_chart_it_libroIVA -msgid "Registri IVA" -msgstr "" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -#: report:l10n_it.report.libroIVA_debito:0 -msgid "Imposta" -msgstr "" - -#. module: l10n_it -#: model:account.fiscal.position.template,name:l10n_it.intra -msgid "Regime Intra comunitario" -msgstr "" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -#: report:l10n_it.report.libroIVA_debito:0 -msgid "Data fattura" -msgstr "" - -#. module: l10n_it -#: report:l10n_it.report.libroIVA_credito:0 -#: report:l10n_it.report.libroIVA_debito:0 -msgid "Imponibile" -msgstr "" - #. module: l10n_it #: model:ir.module.module,shortdesc:l10n_it.module_meta_information msgid "Italy - Generic Chart of Accounts" msgstr "" #. module: l10n_it -#: model:ir.model,name:l10n_it.model_account_report_libroiva -msgid "SQL view for libro IVA" +#: model:ir.actions.todo,note:l10n_it.config_call_account_template_generic +msgid "Generate Chart of Accounts from a Chart Template. You will be asked to pass the name of the company, the chart template to follow, the no. of digits to generate the code for your accounts and Bank account, currency to create Journals. Thus,the pure copy of chart Template is generated.\n" +" This is the same wizard that runs from Financial Management/Configuration/Financial Accounting/Financial Accounts/Generate Chart of Accounts from a Chart Template." +msgstr "" + +#. module: l10n_it +#: model:ir.model,name:l10n_it.model_account_tax +msgid "account.tax" msgstr "" diff --git a/addons/l10n_it/libroIVA.py b/addons/l10n_it/libroIVA.py deleted file mode 100644 index a78c81ffdb3..00000000000 --- a/addons/l10n_it/libroIVA.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2010 -# Italian OpenERP Community () -# Servabit srl -# Agile Business Group sagl -# Domsense srl -# -# 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 . -# -############################################################################## - - -# ################################################################################## -# Questa vista SQL viene usata solo per far scegliere l'anno di pianificazione all'utente -# Viene infatti costruita una vista XML di tipo tree che contiene solo i diversi anni per i quali stata fatta almeno una pianificazione -# ################################################################################## - -from osv import fields, osv - -class l10n_chart_it_report_libroIVA (osv.osv): - _name = "account.report_libroiva" - _description = "SQL view for libro IVA" - _auto = False - _rec_name = "name" - #_order = "fiscal_year"; - - _columns = { - 'name': fields.char('Fiscal year',size=64), - 'company_id': fields.many2one('res.company', 'Company'), - } - - def init (self, cr) : - cr.execute("""DROP VIEW IF EXISTS account_report_libroiva""") - cr.execute(""" - CREATE VIEW account_report_libroiva AS ( - SELECT id, name, company_id FROM account_fiscalyear - )""") -l10n_chart_it_report_libroIVA() - - diff --git a/addons/l10n_it/libroIVA_menu.xml b/addons/l10n_it/libroIVA_menu.xml deleted file mode 100644 index 51e581ac11c..00000000000 --- a/addons/l10n_it/libroIVA_menu.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - diff --git a/addons/l10n_it/libroIVA_view.xml b/addons/l10n_it/libroIVA_view.xml deleted file mode 100644 index bbc905e6da0..00000000000 --- a/addons/l10n_it/libroIVA_view.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - l10n_chart_it_report_libroIVA_tree - account.report_libroiva - tree - - - - - - - - - - - l10n_chart_it_report_libroIVA_form - account.report_libroiva - form - -
- - -
-
- - - - Registri IVA - account.report_libroiva - - form - tree,form - - - -
-
diff --git a/addons/l10n_it/report.xml b/addons/l10n_it/report.xml deleted file mode 100644 index e0ba4a33daf..00000000000 --- a/addons/l10n_it/report.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - diff --git a/addons/l10n_it/report/__init__.py b/addons/l10n_it/report/__init__.py deleted file mode 100644 index be32155c675..00000000000 --- a/addons/l10n_it/report/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -import libroIVA_credito -import libroIVA_debito \ No newline at end of file diff --git a/addons/l10n_it/report/libroIVA_credito.py b/addons/l10n_it/report/libroIVA_credito.py deleted file mode 100644 index b48c81d2475..00000000000 --- a/addons/l10n_it/report/libroIVA_credito.py +++ /dev/null @@ -1,79 +0,0 @@ -import datetime -import time -from report import report_sxw -from osv import osv -import pooler - - -class l10n_chart_it_report_libroIVA_credito(report_sxw.rml_parse): - - def __init__(self, cr, uid, name, context): - super(l10n_chart_it_report_libroIVA_credito,self).__init__(cr,uid,name,context) - self.localcontext.update({ - 'time' : time, - 'get_company' : self.get_company, - 'get_periods' : self.get_periods, - 'get_lines' : self.get_lines, - }) - - - def get_company(self,fiscal_year): - #print 'COMP = ',fiscal_year - return "" - - def get_periods(self,fiscal_year): - #print 'Fiscal year id:',fiscal_year.id - obj=pooler.get_pool(self.cr.dbname).get('account.fiscalyear') - fy=obj.browse(self.cr,self.uid,fiscal_year.id) - #print 'Periods = ',fy.period_ids - res=[rec for rec in fy.period_ids] - #return fy.periods => non funziona?!? bool object !?!? - return res - - def get_invoices(self,period): - #print 'PERIOD = ',period.name - obj=pooler.get_pool(self.cr.dbname).get('account.invoice') - # Selezione tutte le fatture emesse nel periodo - self.cr.execute( """ - SELECT id FROM account_invoice - WHERE (state='open' OR state='paid') AND - period_id="""+str(period.id)+""" - AND (type='out_invoice' OR type='out_refund') - """) - ids=self.cr.fetchall() - #print 'IDS = ', - if ids: - ids=[id[0] for id in ids ] - invoices=obj.browse(self.cr,self.uid,ids) - #print 'INVOICES = ',invoices - return invoices - - def get_lines(self,fiscal_year): - res=[] - obj_fy=pooler.get_pool(self.cr.dbname).get('account.fiscalyear') - fy=obj_fy.browse(self.cr,self.uid,fiscal_year.id) - for period in fy.period_ids: - invoices=self.get_invoices(period) - for invoice in invoices: - d={'periodo': period.name} - d['protocollo']=invoice.number - #print 'PARTNER ',invoice.partner_id.name - causale=invoice.partner_id.name - #print 'CAUSALE = ',causale - d['causale']=causale - d['numero']=invoice.reference - d['data_doc']=invoice.date_invoice - for tax in invoice.tax_line: - #print '\tTAX: ',tax - d['aliquota']=tax.tax_code_id.name - d['imponibile']=tax.base - d['imposta']=tax.amount - res.append(d) - d={'periodo':'', 'protocollo':'', 'causale':'', 'numero':'', 'data_doc':'', } - return res - - - -report_sxw.report_sxw('report.l10n_it.report.libroIVA_credito','account.report_libroiva', - 'l10n_it/report/libroIVA_credito.rml', - parser=l10n_chart_it_report_libroIVA_credito,header=False) diff --git a/addons/l10n_it/report/libroIVA_credito.rml b/addons/l10n_it/report/libroIVA_credito.rml deleted file mode 100644 index 2b282f760b4..00000000000 --- a/addons/l10n_it/report/libroIVA_credito.rml +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [[ repeatIn(objects, 'o') ]] - - - - - [[ get_company(o) ]] - - - - - REGISTRO IVA - - - VENDITE - - - - - - - - [[ o.name ]] - - - - - - - Periodo - - - Protocollo - - - Cliente - - - Numero - - - Data fattura - - - Aliquota - - - Imponibile - - - Imposta - - - - - [[ repeatIn(get_lines(o), 'line') ]] - [[ line['periodo'] ]] - - - [[ line['protocollo'] ]] - - - [[ line['causale'] ]] - - - [[ line['numero'] ]] - - - [[ line['data_doc'] ]] - - - [[ line['aliquota'] ]] - - - [[ line['imponibile'] ]] - - - [[ line['imposta'] ]] - - - - - - - - - - - - - - - diff --git a/addons/l10n_it/report/libroIVA_debito.py b/addons/l10n_it/report/libroIVA_debito.py deleted file mode 100644 index c7720ab69a1..00000000000 --- a/addons/l10n_it/report/libroIVA_debito.py +++ /dev/null @@ -1,80 +0,0 @@ -import datetime -import time -from report import report_sxw -from osv import osv -import pooler - - -class l10n_chart_it_report_libroIVA_debito(report_sxw.rml_parse): - - def __init__(self, cr, uid, name, context): - super(l10n_chart_it_report_libroIVA_debito,self).__init__(cr,uid,name,context) - self.localcontext.update({ - 'time' : time, - 'get_company' : self.get_company, - 'get_periods' : self.get_periods, - 'get_lines' : self.get_lines, - }) - - - def get_company(self,fiscal_year): - #print 'COMP = ',fiscal_year - return "" - - - def get_periods(self,fiscal_year): - #print 'Fiscal year id:',fiscal_year.id - obj=pooler.get_pool(self.cr.dbname).get('account.fiscalyear') - fy=obj.browse(self.cr,self.uid,fiscal_year.id) - #print 'Periods = ',fy.period_ids - res=[rec for rec in fy.period_ids] - #return fy.periods => non funziona?!? bool object !?!? - return res - - def get_invoices(self,period): - #print 'PERIOD = ',period.name - obj=pooler.get_pool(self.cr.dbname).get('account.invoice') - # Selezione tutte le fatture emesse nel periodo - self.cr.execute( """ - SELECT id FROM account_invoice - WHERE (state='open' OR state='paid') AND - period_id="""+str(period.id)+""" - AND (type='in_invoice' OR type='in_refund') - """) - ids=self.cr.fetchall() - #print 'IDS = ', - if ids: - ids=[id[0] for id in ids ] - invoices=obj.browse(self.cr,self.uid,ids) - #print 'INVOICES = ',invoices - return invoices - - def get_lines(self,fiscal_year): - res=[] - obj_fy=pooler.get_pool(self.cr.dbname).get('account.fiscalyear') - fy=obj_fy.browse(self.cr,self.uid,fiscal_year.id) - for period in fy.period_ids: - invoices=self.get_invoices(period) - for invoice in invoices: - d={'periodo': period.name} - d['protocollo']=invoice.number - #print 'PARTNER ',invoice.partner_id.name - causale=invoice.partner_id.name - #print 'CAUSALE = ',causale - d['causale']=causale - d['numero']=invoice.reference - d['data_doc']=invoice.date_invoice - for tax in invoice.tax_line: - #print '\tTAX: ',tax - d['aliquota']=tax.tax_code_id.name - d['imponibile']=tax.base - d['imposta']=tax.amount - res.append(d) - d={'periodo':'', 'protocollo':'', 'causale':'', 'numero':'', 'data_doc':'', } - return res - - - -report_sxw.report_sxw('report.l10n_it.report.libroIVA_debito','account.report_libroiva', - 'l10n_it/report/libroIVA_debito.rml', - parser=l10n_chart_it_report_libroIVA_debito,header=False) diff --git a/addons/l10n_it/report/libroIVA_debito.rml b/addons/l10n_it/report/libroIVA_debito.rml deleted file mode 100644 index ced847722af..00000000000 --- a/addons/l10n_it/report/libroIVA_debito.rml +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [[ repeatIn(objects, 'o') ]] - - - - - [[ get_company(o) ]] - - - - - REGISTRO IVA - - - ACQUISTI - - - - - - - - [[ o.name ]] - - - - - - - Periodo - - - Protocollo - - - Fornitore - - - Numero - - - Data fattura - - - Aliquota - - - Imponibile - - - Imposta - - - - - [[ repeatIn(get_lines(o), 'line') ]] - [[ line['periodo'] ]] - - - [[ line['protocollo'] ]] - - - [[ line['causale'] ]] - - - [[ line['numero'] ]] - - - [[ line['data_doc'] ]] - - - [[ line['aliquota'] ]] - - - [[ line['imponibile'] ]] - - - [[ line['imposta'] ]] - - - - - - - - - - - - diff --git a/addons/l10n_it/report/normalized_oo2rml.xsl b/addons/l10n_it/report/normalized_oo2rml.xsl deleted file mode 100644 index 14fcf598e54..00000000000 --- a/addons/l10n_it/report/normalized_oo2rml.xsl +++ /dev/null @@ -1,696 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - ( - - , - - ) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - , - - - - - - - - - - - - - - - - - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - white - - - - - - - - - - - ......... - - - - - - - - - - - - - 15 - 0 - - - - - - - - - - 6 - - - - - - ZapfDingbats - l - - - - - - - - - - - - - - - . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - yes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LEFT - - - CENTER - - - RIGHT - - - JUSTIFY - - - - - - - - - - - - - - - - - - - - - - - - - - - Courier-BoldOblique - - - Courier-Bold - - - Courier-Oblique - - - Courier - - - - - - - Helvetica-BoldOblique - - - Helvetica-Bold - - - Helvetica-Oblique - - - Helvetica - - - - - - - Times-BoldItalic - - - Times-Bold - - - Times-Italic - - - Times-Roman - - - - - - - - Times-Roman - - - - - - - - - - - - - - - - -
- - diff --git a/addons/l10n_it/security/ir.model.access.csv b/addons/l10n_it/security/ir.model.access.csv deleted file mode 100644 index 8a8908511db..00000000000 --- a/addons/l10n_it/security/ir.model.access.csv +++ /dev/null @@ -1,3 +0,0 @@ -"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" -"access_l10n_it_report_manager","l10n_it.report account manager","model_account_report_libroiva","account.group_account_manager",1,1,1,1 -"access_l10n_it_report_user","l10n_it_report account user","model_account_report_libroiva","account.group_account_user",1,1,1,1 From 07881a0c50b00635f5becbb7c0c3b416f34e1263 Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Fri, 2 Sep 2011 17:18:53 +0530 Subject: [PATCH 002/278] [REF]:execute method in audittrail_objects_proxy bzr revid: nch@tinyerp.com-20110902114853-z7f1uofjgh8poq0z --- addons/audittrail/audittrail.py | 39 +++++++++++++-------------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index bfa6bca8f34..ffb44502ba4 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -292,7 +292,7 @@ class audittrail_objects_proxy(object_proxy): def log_fct(self, db, uid, model, method, fct_src, *args): """ - Logging function: This function is performs logging oprations according to method + Logging function: This function is performs logging operations according to method @param db: the current database @param uid: the current user’s ID for security checks, @param object: Object who's values are being changed @@ -482,41 +482,32 @@ class audittrail_objects_proxy(object_proxy): cr = pooler.get_db(db).cursor() cr.autocommit(True) logged_uids = [] + rule = False + ignore_methods = ['default_get','read','fields_view_get','fields_get','search', + 'search_count','name_search','name_get','get','request_get', + 'get_sc', 'unlink', 'write', 'create'] fct_src = super(audittrail_objects_proxy, self).execute - - def my_fct(db, uid, model, method, *args): - rule = False + try: model_ids = model_pool.search(cr, uid, [('model', '=', model)]) model_id = model_ids and model_ids[0] or False - - for model_name in pool.obj_list(): - if model_name == 'audittrail.rule': - rule = True - if not rule: - return fct_src(db, uid_orig, model, method, *args) - if not model_id: - return fct_src(db, uid_orig, model, method, *args) - + if 'audittrail.rule' in pool.obj_list(): + rule = True + if not rule or not model_id: + return fct_src(db, uid_orig, model, method, *args) rule_ids = rule_pool.search(cr, uid, [('object_id', '=', model_id), ('state', '=', 'subscribed')]) if not rule_ids: return fct_src(db, uid_orig, model, method, *args) - for thisrule in rule_pool.browse(cr, uid, rule_ids): - for user in thisrule.user_id: - logged_uids.append(user.id) + for model_rule in rule_pool.browse(cr, uid, rule_ids): + logged_uids += map(lambda x:x.id, model_rule.user_id) if not logged_uids or uid in logged_uids: if method in ('read', 'write', 'create', 'unlink'): - if getattr(thisrule, 'log_' + method): + if getattr(model_rule, 'log_' + method): return self.log_fct(db, uid_orig, model, method, fct_src, *args) - - elif method not in ('default_get','read','fields_view_get','fields_get','search','search_count','name_search','name_get','get','request_get', 'get_sc', 'unlink', 'write', 'create'): - if thisrule.log_action: + elif method not in ignore_methods: + if model_rule.log_action: return self.log_fct(db, uid_orig, model, method, fct_src, *args) - return fct_src(db, uid_orig, model, method, *args) - try: - res = my_fct(db, uid, model, method, *args) - return res finally: cr.close() From 9a4bc3fe0d51d1b45fc83035fee8409642f0fd9b Mon Sep 17 00:00:00 2001 From: eLBati Date: Sat, 3 Sep 2011 13:01:35 +0200 Subject: [PATCH 003/278] [FIX] internal type of tax authority account bzr revid: lorenzo.battistini@agilebg.com-20110903110135-93slbgpt17cf2f5l --- .../l10n_it/data/account.account.template.csv | 466 +++++++++--------- 1 file changed, 233 insertions(+), 233 deletions(-) diff --git a/addons/l10n_it/data/account.account.template.csv b/addons/l10n_it/data/account.account.template.csv index ff91ccba79a..d31d42180d0 100644 --- a/addons/l10n_it/data/account.account.template.csv +++ b/addons/l10n_it/data/account.account.template.csv @@ -1,234 +1,234 @@ "id","code","name","parent_id:id","user_type:id","type","reconcile" -0,0,"Azienda",,"account_type_view","view",FALSE -1,1,"ATTIVO ",0,"account_type_view","view",TRUE -11,11,"IMMOBILIZZAZIONI IMMATERIALI ",1,"account_type_view","view",TRUE -1101,1101,"costi di impianto ",11,"account_type_view","other",TRUE -1106,1106,"software ",11,"account_type_view","other",TRUE -1108,1108,"avviamento ",11,"account_type_view","other",TRUE -1111,1111,"fondo ammortamento costi di impianto ",11,"account_type_view","other",TRUE -1116,1116,"fondo ammortamento software ",11,"account_type_view","other",TRUE -1118,1118,"fondo ammortamento avviamento ",11,"account_type_view","other",TRUE -12,12,"IMMOBILIZZAZIONI MATERIALI ",1,"account_type_view","view",TRUE -1201,1201,"fabbricati ",12,"account_type_view","other",TRUE -1202,1202,"impianti e macchinari ",12,"account_type_view","other",TRUE -1204,1204,"attrezzature commerciali ",12,"account_type_view","other",TRUE -1205,1205,"macchine d'ufficio ",12,"account_type_view","other",TRUE -1206,1206,"arredamento ",12,"account_type_view","other",TRUE -1207,1207,"automezzi ",12,"account_type_view","other",TRUE -1208,1208,"imballaggi durevoli ",12,"account_type_view","other",TRUE -1211,1211,"fondo ammortamento fabbricati ",12,"account_type_view","other",TRUE -1212,1212,"fondo ammortamento impianti e macchinari ",12,"account_type_view","other",TRUE -1214,1214,"fondo ammortamento attrezzature commerciali ",12,"account_type_view","other",TRUE -1215,1215,"fondo ammortamento macchine d'ufficio ",12,"account_type_view","other",TRUE -1216,1216,"fondo ammortamento arredamento ",12,"account_type_view","other",TRUE -1217,1217,"fondo ammortamento automezzi ",12,"account_type_view","other",TRUE -1218,1218,"fondo ammortamento imballaggi durevoli ",12,"account_type_view","other",TRUE -1220,1220,"fornitori immobilizzazioni c/acconti ",12,"account_type_view","other",TRUE -13,13,"IMMOBILIZZAZIONI FINANZIARIE ",1,"account_type_view","view",TRUE -1301,1301,"mutui attivi ",13,"account_type_view","other",TRUE -14,14,"RIMANENZE ",1,"account_type_view","view",TRUE -1401,1401,"materie di consumo ",14,"account_type_view","other",TRUE -1404,1404,"merci ",14,"account_type_view","other",TRUE -1410,1410,"fornitori c/acconti ",14,"account_type_view","other",TRUE -15,15,"CREDITI COMMERCIALI ",1,"account_type_view","view",TRUE -1501,1501,"crediti v/clienti ",15,"account_type_receivable","receivable",TRUE -1502,1502,"crediti commerciali diversi ",15,"account_type_receivable","other",TRUE -1503,1503,"clienti c/spese anticipate ",15,"account_type_receivable","receivable",TRUE -1505,1505,"cambiali attive ",15,"account_type_receivable","other",TRUE -1506,1506,"cambiali allo sconto ",15,"account_type_receivable","other",TRUE -1507,1507,"cambiali all'incasso ",15,"account_type_receivable","other",TRUE -1509,1509,"fatture da emettere ",15,"account_type_receivable","other",TRUE -1510,1510,"crediti insoluti ",15,"account_type_receivable","other",TRUE -1511,1511,"cambiali insolute ",15,"account_type_receivable","other",TRUE -1531,1531,"crediti da liquidare ",15,"account_type_receivable","other",TRUE -1540,1540,"fondo svalutazione crediti ",15,"account_type_receivable","other",TRUE -1541,1541,"fondo rischi su crediti ",15,"account_type_receivable","other",TRUE -16,16,"CREDITI DIVERSI ",1,"account_type_view","view",TRUE -1601,1601,"IVA n/credito ",16,"account_type_receivable","other",TRUE -1602,1602,"IVA c/acconto ",16,"account_type_receivable","other",TRUE -1605,1605,"crediti per IVA ",16,"account_type_receivable","other",TRUE -1607,1607,"imposte c/acconto ",16,"account_type_receivable","other",TRUE -1608,1608,"crediti per imposte ",16,"account_type_receivable","other",TRUE -1609,1609,"crediti per ritenute subite ",16,"account_type_receivable","other",TRUE -1610,1610,"crediti per cauzioni ",16,"account_type_receivable","other",TRUE -1620,1620,"personale c/acconti ",16,"account_type_receivable","other",TRUE -1630,1630,"crediti v/istituti previdenziali ",16,"account_type_receivable","other",TRUE -1640,1640,"debitori diversi ",16,"account_type_receivable","receivable",TRUE -18,18,"DISPONIBILITÀ LIQUIDE ",1,"account_type_view","view",TRUE -1801,1801,"banche c/c ",18,"account_type_bank","liquidity",TRUE -1810,1810,"c/c postali ",18,"account_type_cash","liquidity",TRUE -1820,1820,"denaro in cassa ",18,"account_type_cash","liquidity",TRUE -1821,1821,"assegni ",18,"account_type_cash","liquidity",TRUE -1822,1822,"valori bollati ",18,"account_type_cash","liquidity",TRUE -19,19,"RATEI E RISCONTI ATTIVI ",1,"account_type_view","view",TRUE -1901,1901,"ratei attivi ",19,"account_type_view","other",TRUE -1902,1902,"risconti attivi ",19,"account_type_view","other",TRUE -2,2,"PASSIVO ",0,"account_type_view","view",TRUE -20,20,"PATRIMONIO NETTO ",2,"account_type_view","view",TRUE -2101,2101,"patrimonio netto ",20,"account_type_view","other",TRUE -2102,2102,"utile d'esercizio ",20,"account_type_view","receivable",TRUE -2103,2103,"perdita d'esercizio ",20,"account_type_view","payable",TRUE -2104,2104,"prelevamenti extra gestione ",20,"account_type_view","other",TRUE -2105,2105,"titolare c/ritenute subite ",20,"account_type_view","other",TRUE -22,22,"FONDI PER RISCHI E ONERI ",2,"account_type_view","view",TRUE -2201,2201,"fondo per imposte ",22,"account_type_view","other",TRUE -2204,2204,"fondo responsabilità civile ",22,"account_type_view","other",TRUE -2205,2205,"fondo spese future ",22,"account_type_view","other",TRUE -2211,2211,"fondo manutenzioni programmate ",22,"account_type_view","other",TRUE -23,23,"TRATTAMENTO FINE RAPPORTO DI LAVORO ",2,"account_type_view","view",TRUE -2301,2301,"debiti per TFRL ",23,"account_type_view","other",TRUE -24,24,"DEBITI FINANZIARI ",2,"account_type_view","view",TRUE -2410,2410,"mutui passivi ",24,"account_type_payable","other",TRUE -2411,2411,"banche c/sovvenzioni ",24,"account_type_payable","other",TRUE -2420,2420,"banche c/c passivi ",24,"account_type_payable","other",TRUE -2421,2421,"banche c/RIBA all'incasso ",24,"account_type_payable","other",TRUE -2422,2422,"banche c/cambiali all'incasso ",24,"account_type_payable","other",TRUE -2423,2423,"banche c/anticipi su fatture ",24,"account_type_payable","other",TRUE -2440,2440,"debiti v/altri finanziatori ",24,"account_type_payable","other",TRUE -25,25,"DEBITI COMMERCIALI ",2,"account_type_view","view",TRUE -2501,2501,"debiti v/fornitori ",25,"account_type_payable","payable",TRUE -2503,2503,"cambiali passive ",25,"account_type_payable","other",TRUE -2520,2520,"fatture da ricevere ",25,"account_type_payable","other",TRUE -2521,2521,"debiti da liquidare ",25,"account_type_payable","other",TRUE -2530,2530,"clienti c/acconti ",25,"account_type_payable","payable",TRUE -26,26,"DEBITI DIVERSI ",2,"account_type_view","view",TRUE -2601,2601,"IVA n/debito ",26,"account_type_payable","other",TRUE -2602,2602,"debiti per ritenute da versare ",26,"account_type_payable","other",TRUE -2605,2605,"erario c/IVA ",26,"account_type_payable","other",TRUE -2606,2606,"debiti per imposte ",26,"account_type_payable","other",TRUE -2619,2619,"debiti per cauzioni ",26,"account_type_payable","other",TRUE -2620,2620,"personale c/retribuzioni ",26,"account_type_payable","other",TRUE -2621,2621,"personale c/liquidazioni ",26,"account_type_payable","other",TRUE -2622,2622,"clienti c/cessione ",26,"account_type_payable","other",TRUE -2630,2630,"debiti v/istituti previdenziali ",26,"account_type_payable","other",TRUE -2640,2640,"creditori diversi ",26,"account_type_payable","payable",TRUE -27,27,"RATEI E RISCONTI PASSIVI ",2,"account_type_view","view",TRUE -2701,2701,"ratei passivi ",27,"account_type_view","other",TRUE -2702,2702,"risconti passivi ",27,"account_type_view","other",TRUE -28,28,"CONTI TRANSITORI E DIVERSI ",2,"account_type_view","view",TRUE -2801,2801,"bilancio di apertura ",28,"account_type_view","other",TRUE -2802,2802,"bilancio di chiusura ",28,"account_type_view","other",TRUE -2810,2810,"IVA c/liquidazioni ",28,"account_type_view","other",TRUE -2811,2811,"istituti previdenziali ",28,"account_type_view","other",TRUE -2820,2820,"banca ... c/c ",28,"account_type_view","other",TRUE -2821,2821,"banca ... c/c ",28,"account_type_view","other",TRUE -2822,2822,"banca ... c/c ",28,"account_type_view","other",TRUE -29,29,"CONTI DEI SISTEMI SUPPLEMENTARI ",2,"account_type_view","view",TRUE -2901,2901,"beni di terzi ",29,"account_type_view","other",TRUE -2902,2902,"depositanti beni ",29,"account_type_view","other",TRUE -2911,2911,"merci da ricevere ",29,"account_type_view","other",TRUE -2912,2912,"fornitori c/impegni ",29,"account_type_view","other",TRUE -2913,2913,"impegni per beni in leasing ",29,"account_type_view","other",TRUE -2914,2914,"creditori c/leasing ",29,"account_type_view","other",TRUE -2916,2916,"clienti c/impegni ",29,"account_type_view","other",TRUE -2917,2917,"merci da consegnare ",29,"account_type_view","other",TRUE -2921,2921,"rischi per effetti scontati ",29,"account_type_view","other",TRUE -2922,2922,"banche c/effetti scontati ",29,"account_type_view","other",TRUE -2926,2926,"rischi per fideiussioni ",29,"account_type_view","other",TRUE -2927,2927,"creditori per fideiussioni ",29,"account_type_view","other",TRUE -2931,2931,"rischi per avalli ",29,"account_type_view","other",TRUE -2932,2932,"creditori per avalli ",29,"account_type_view","other",TRUE -3,3,"VALORE DELLA PRODUZIONE ",0,"account_type_view","view",TRUE -31,31,"VENDITE E PRESTAZIONI ",3,"account_type_view","view",TRUE -3101,3101,"merci c/vendite ",31,"account_type_income","other",TRUE -3103,3103,"rimborsi spese di vendita ",31,"account_type_income","other",TRUE -3110,3110,"resi su vendite ",31,"account_type_income","other",TRUE -3111,3111,"ribassi e abbuoni passivi ",31,"account_type_income","other",TRUE -3112,3112,"premi su vendite ",31,"account_type_income","other",TRUE -32,32,"RICAVI E PROVENTI DIVERSI ",3,"account_type_view","view",TRUE -3201,3201,"fitti attivi ",32,"account_type_income","other",TRUE -3202,3202,"proventi vari ",32,"account_type_income","other",TRUE -3210,3210,"arrotondamenti attivi ",32,"account_type_income","other",TRUE -3220,3220,"plusvalenze ordinarie diverse ",32,"account_type_income","other",TRUE -3230,3230,"sopravvenienze attive ordinarie diverse ",32,"account_type_income","other",TRUE -3240,3240,"insussistenze attive ordinarie diverse ",32,"account_type_income","other",TRUE -4,4,"COSTI DELLA PRODUZIONE ",0,"account_type_view","view",TRUE -41,41,"COSTO DEL VENDUTO ",4,"account_type_view","view",TRUE -4101,4101,"merci c/acquisti ",41,"account_type_expense","other",TRUE -4102,4102,"materie di consumo c/acquisti ",41,"account_type_expense","other",TRUE -4105,4105,"merci c/apporti ",41,"account_type_expense","other",TRUE -4110,4110,"resi su acquisti ",41,"account_type_expense","other",TRUE -4111,4111,"ribassi e abbuoni attivi ",41,"account_type_expense","other",TRUE -4112,4112,"premi su acquisti ",41,"account_type_expense","other",TRUE -4121,4121,"merci c/esistenze iniziali ",41,"account_type_expense","other",TRUE -4122,4122,"materie di consumo c/esistenze iniziali ",41,"account_type_expense","other",TRUE -4131,4131,"merci c/rimanenze finali ",41,"account_type_expense","other",TRUE -4132,4132,"materie di consumo c/rimanenze finali ",41,"account_type_expense","other",TRUE -42,42,"COSTI PER SERVIZI ",4,"account_type_view","view",TRUE -4201,4201,"costi di trasporto ",42,"account_type_expense","other",TRUE -4202,4202,"costi per energia ",42,"account_type_expense","other",TRUE -4203,4203,"costi di pubblicità ",42,"account_type_expense","other",TRUE -4204,4204,"costi di consulenze ",42,"account_type_expense","other",TRUE -4205,4205,"costi postali ",42,"account_type_expense","other",TRUE -4206,4206,"costi telefonici ",42,"account_type_expense","other",TRUE -4207,4207,"costi di assicurazione ",42,"account_type_expense","other",TRUE -4208,4208,"costi di vigilanza ",42,"account_type_expense","other",TRUE -4209,4209,"costi per i locali ",42,"account_type_expense","other",TRUE -4210,4210,"costi di esercizio automezzi ",42,"account_type_expense","other",TRUE -4211,4211,"costi di manutenzione e riparazione ",42,"account_type_expense","other",TRUE -4212,4212,"provvigioni passive ",42,"account_type_expense","other",TRUE -4213,4213,"spese di incasso ",42,"account_type_expense","other",TRUE -43,43,"COSTI PER GODIMENTO BENI DI TERZI ",4,"account_type_view","view",TRUE -4301,4301,"fitti passivi ",43,"account_type_expense","other",TRUE -4302,4302,"canoni di leasing ",43,"account_type_expense","other",TRUE -44,44,"COSTI PER IL PERSONALE ",4,"account_type_view","view",TRUE -4401,4401,"salari e stipendi ",44,"account_type_expense","other",TRUE -4402,4402,"oneri sociali ",44,"account_type_expense","other",TRUE -4403,4403,"TFRL ",44,"account_type_expense","other",TRUE -4404,4404,"altri costi per il personale ",44,"account_type_expense","other",TRUE -45,45,"AMMORTAMENTI IMMOBILIZZAZIONI IMMATERIALI ",4,"account_type_view","view",TRUE -4501,4501,"ammortamento costi di impianto ",45,"account_type_view","other",TRUE -4506,4506,"ammortamento software ",45,"account_type_view","other",TRUE -4508,4508,"ammortamento avviamento ",45,"account_type_view","other",TRUE -46,46,"AMMORTAMENTI IMMOBILIZZAZIONI MATERIALI ",4,"account_type_view","view",TRUE -4601,4601,"ammortamento fabbricati ",46,"account_type_view","other",TRUE -4602,4602,"ammortamento impianti e macchinari ",46,"account_type_view","other",TRUE -4604,4604,"ammortamento attrezzature commerciali ",46,"account_type_view","other",TRUE -4605,4605,"ammortamento macchine d'ufficio ",46,"account_type_view","other",TRUE -4606,4606,"ammortamento arredamento ",46,"account_type_view","other",TRUE -4607,4607,"ammortamento automezzi ",46,"account_type_view","other",TRUE -4608,4608,"ammortamento imballaggi durevoli ",46,"account_type_view","other",TRUE -47,47,"SVALUTAZIONI ",4,"account_type_view","view",TRUE -4701,4701,"svalutazioni immobilizzazioni immateriali ",47,"account_type_view","other",TRUE -4702,4702,"svalutazioni immobilizzazioni materiali ",47,"account_type_view","other",TRUE -4706,4706,"svalutazione crediti ",47,"account_type_view","other",TRUE -48,48,"ACCANTONAMENTI ",4,"account_type_view","view",TRUE -481,481,"ACCANTONAMENTI PER RISCHI ",48,"account_type_view","view",TRUE -4814,4814,"accantonamento per responsabilità civile ",481,"account_type_view","other",TRUE -482,482,"ALTRI ACCANTONAMENTI ",48,"account_type_view","view",TRUE -4821,4821,"accantonamento per spese future ",482,"account_type_view","other",TRUE -4823,4823,"accantonamento per manutenzioni programmate ",482,"account_type_view","other",TRUE -49,49,"ONERI DIVERSI ",4,"account_type_view","view",TRUE -4901,4901,"oneri fiscali diversi ",49,"account_type_view","other",TRUE -4903,4903,"oneri vari ",49,"account_type_view","other",TRUE -4905,4905,"perdite su crediti ",49,"account_type_view","other",TRUE -4910,4910,"arrotondamenti passivi ",49,"account_type_view","other",TRUE -4920,4920,"minusvalenze ordinarie diverse ",49,"account_type_view","other",TRUE -4930,4930,"sopravvenienze passive ordinarie diverse ",49,"account_type_view","other",TRUE -4940,4940,"insussistenze passive ordinarie diverse ",49,"account_type_view","other",TRUE -5,5,"PROVENTI E ONERI FINANZIARI ",0,"account_type_view","view",TRUE -51,51,"PROVENTI FINANZIARI ",5,"account_type_view","view",TRUE -5110,5110,"interessi attivi v/clienti ",51,"account_type_view","other",TRUE -5115,5115,"interessi attivi bancari ",51,"account_type_view","other",TRUE -5116,5116,"interessi attivi postali ",51,"account_type_view","other",TRUE -5140,5140,"proventi finanziari diversi ",51,"account_type_view","other",TRUE -52,52,"ONERI FINANZIARI ",5,"account_type_view","view",TRUE -5201,5201,"interessi passivi v/fornitori ",52,"account_type_view","other",TRUE -5202,5202,"interessi passivi bancari ",52,"account_type_view","other",TRUE -5203,5203,"sconti passivi bancari ",52,"account_type_view","other",TRUE -5210,5210,"interessi passivi su mutui ",52,"account_type_view","other",TRUE -5240,5240,"oneri finanziari diversi ",52,"account_type_view","other",TRUE -7,7,"PROVENTI E ONERI STRAORDINARI ",0,"account_type_view","view",TRUE -71,71,"PROVENTI STRAORDINARI ",7,"account_type_view","view",TRUE -7101,7101,"plusvalenze straordinarie ",71,"account_type_view","other",TRUE -7102,7102,"sopravvenienze attive straordinarie ",71,"account_type_view","other",TRUE -7103,7103,"insussistenze attive straordinarie ",71,"account_type_view","other",TRUE -72,72,"ONERI STRAORDINARI ",7,"account_type_view","view",TRUE -7201,7201,"minusvalenze straordinarie ",72,"account_type_view","other",TRUE -7202,7202,"sopravvenienze passive straordinarie ",72,"account_type_view","other",TRUE -7203,7203,"insussistenze passive straordinarie ",72,"account_type_view","other",TRUE -7204,7204,"imposte esercizi precedenti ",72,"account_type_view","other",TRUE -81,81,"IMPOSTE DELL'ESERCIZIO ",7,"account_type_view","view",TRUE -8101,8101,"imposte dell'esercizio ",81,"account_type_view","other",TRUE -91,91,"CONTI DI RISULTATO ",7,"account_type_view","view",TRUE -9101,9101,"conto di risultato economico ",91,"account_type_view","other",TRUE +"0","0","Azienda",,"account_type_view","view","FALSE" +"1","1","ATTIVO ","0","account_type_view","view","TRUE" +"11","11","IMMOBILIZZAZIONI IMMATERIALI ","1","account_type_view","view","TRUE" +"1101","1101","costi di impianto ","11","account_type_view","other","TRUE" +"1106","1106","software ","11","account_type_view","other","TRUE" +"1108","1108","avviamento ","11","account_type_view","other","TRUE" +"1111","1111","fondo ammortamento costi di impianto ","11","account_type_view","other","TRUE" +"1116","1116","fondo ammortamento software ","11","account_type_view","other","TRUE" +"1118","1118","fondo ammortamento avviamento ","11","account_type_view","other","TRUE" +"12","12","IMMOBILIZZAZIONI MATERIALI ","1","account_type_view","view","TRUE" +"1201","1201","fabbricati ","12","account_type_view","other","TRUE" +"1202","1202","impianti e macchinari ","12","account_type_view","other","TRUE" +"1204","1204","attrezzature commerciali ","12","account_type_view","other","TRUE" +"1205","1205","macchine d'ufficio ","12","account_type_view","other","TRUE" +"1206","1206","arredamento ","12","account_type_view","other","TRUE" +"1207","1207","automezzi ","12","account_type_view","other","TRUE" +"1208","1208","imballaggi durevoli ","12","account_type_view","other","TRUE" +"1211","1211","fondo ammortamento fabbricati ","12","account_type_view","other","TRUE" +"1212","1212","fondo ammortamento impianti e macchinari ","12","account_type_view","other","TRUE" +"1214","1214","fondo ammortamento attrezzature commerciali ","12","account_type_view","other","TRUE" +"1215","1215","fondo ammortamento macchine d'ufficio ","12","account_type_view","other","TRUE" +"1216","1216","fondo ammortamento arredamento ","12","account_type_view","other","TRUE" +"1217","1217","fondo ammortamento automezzi ","12","account_type_view","other","TRUE" +"1218","1218","fondo ammortamento imballaggi durevoli ","12","account_type_view","other","TRUE" +"1220","1220","fornitori immobilizzazioni c/acconti ","12","account_type_view","other","TRUE" +"13","13","IMMOBILIZZAZIONI FINANZIARIE ","1","account_type_view","view","TRUE" +"1301","1301","mutui attivi ","13","account_type_view","other","TRUE" +"14","14","RIMANENZE ","1","account_type_view","view","TRUE" +"1401","1401","materie di consumo ","14","account_type_view","other","TRUE" +"1404","1404","merci ","14","account_type_view","other","TRUE" +"1410","1410","fornitori c/acconti ","14","account_type_view","other","TRUE" +"15","15","CREDITI COMMERCIALI ","1","account_type_view","view","TRUE" +"1501","1501","crediti v/clienti ","15","account_type_receivable","receivable","TRUE" +"1502","1502","crediti commerciali diversi ","15","account_type_receivable","other","TRUE" +"1503","1503","clienti c/spese anticipate ","15","account_type_receivable","receivable","TRUE" +"1505","1505","cambiali attive ","15","account_type_receivable","other","TRUE" +"1506","1506","cambiali allo sconto ","15","account_type_receivable","other","TRUE" +"1507","1507","cambiali all'incasso ","15","account_type_receivable","other","TRUE" +"1509","1509","fatture da emettere ","15","account_type_receivable","other","TRUE" +"1510","1510","crediti insoluti ","15","account_type_receivable","other","TRUE" +"1511","1511","cambiali insolute ","15","account_type_receivable","other","TRUE" +"1531","1531","crediti da liquidare ","15","account_type_receivable","other","TRUE" +"1540","1540","fondo svalutazione crediti ","15","account_type_receivable","other","TRUE" +"1541","1541","fondo rischi su crediti ","15","account_type_receivable","other","TRUE" +"16","16","CREDITI DIVERSI ","1","account_type_view","view","TRUE" +"1601","1601","IVA n/credito ","16","account_type_receivable","other","TRUE" +"1602","1602","IVA c/acconto ","16","account_type_receivable","other","TRUE" +"1605","1605","crediti per IVA ","16","account_type_receivable","other","TRUE" +"1607","1607","imposte c/acconto ","16","account_type_receivable","other","TRUE" +"1608","1608","crediti per imposte ","16","account_type_receivable","other","TRUE" +"1609","1609","crediti per ritenute subite ","16","account_type_receivable","other","TRUE" +"1610","1610","crediti per cauzioni ","16","account_type_receivable","other","TRUE" +"1620","1620","personale c/acconti ","16","account_type_receivable","other","TRUE" +"1630","1630","crediti v/istituti previdenziali ","16","account_type_receivable","other","TRUE" +"1640","1640","debitori diversi ","16","account_type_receivable","receivable","TRUE" +"18","18","DISPONIBILITÀ LIQUIDE ","1","account_type_view","view","TRUE" +"1801","1801","banche c/c ","18","account_type_bank","liquidity","TRUE" +"1810","1810","c/c postali ","18","account_type_cash","liquidity","TRUE" +"1820","1820","denaro in cassa ","18","account_type_cash","liquidity","TRUE" +"1821","1821","assegni ","18","account_type_cash","liquidity","TRUE" +"1822","1822","valori bollati ","18","account_type_cash","liquidity","TRUE" +"19","19","RATEI E RISCONTI ATTIVI ","1","account_type_view","view","TRUE" +"1901","1901","ratei attivi ","19","account_type_view","other","TRUE" +"1902","1902","risconti attivi ","19","account_type_view","other","TRUE" +"2","2","PASSIVO ","0","account_type_view","view","TRUE" +"20","20","PATRIMONIO NETTO ","2","account_type_view","view","TRUE" +"2101","2101","patrimonio netto ","20","account_type_view","other","TRUE" +"2102","2102","utile d'esercizio ","20","account_type_view","receivable","TRUE" +"2103","2103","perdita d'esercizio ","20","account_type_view","payable","TRUE" +"2104","2104","prelevamenti extra gestione ","20","account_type_view","other","TRUE" +"2105","2105","titolare c/ritenute subite ","20","account_type_view","other","TRUE" +"22","22","FONDI PER RISCHI E ONERI ","2","account_type_view","view","TRUE" +"2201","2201","fondo per imposte ","22","account_type_view","other","TRUE" +"2204","2204","fondo responsabilità civile ","22","account_type_view","other","TRUE" +"2205","2205","fondo spese future ","22","account_type_view","other","TRUE" +"2211","2211","fondo manutenzioni programmate ","22","account_type_view","other","TRUE" +"23","23","TRATTAMENTO FINE RAPPORTO DI LAVORO ","2","account_type_view","view","TRUE" +"2301","2301","debiti per TFRL ","23","account_type_view","other","TRUE" +"24","24","DEBITI FINANZIARI ","2","account_type_view","view","TRUE" +"2410","2410","mutui passivi ","24","account_type_payable","other","TRUE" +"2411","2411","banche c/sovvenzioni ","24","account_type_payable","other","TRUE" +"2420","2420","banche c/c passivi ","24","account_type_payable","other","TRUE" +"2421","2421","banche c/RIBA all'incasso ","24","account_type_payable","other","TRUE" +"2422","2422","banche c/cambiali all'incasso ","24","account_type_payable","other","TRUE" +"2423","2423","banche c/anticipi su fatture ","24","account_type_payable","other","TRUE" +"2440","2440","debiti v/altri finanziatori ","24","account_type_payable","other","TRUE" +"25","25","DEBITI COMMERCIALI ","2","account_type_view","view","TRUE" +"2501","2501","debiti v/fornitori ","25","account_type_payable","payable","TRUE" +"2503","2503","cambiali passive ","25","account_type_payable","other","TRUE" +"2520","2520","fatture da ricevere ","25","account_type_payable","other","TRUE" +"2521","2521","debiti da liquidare ","25","account_type_payable","other","TRUE" +"2530","2530","clienti c/acconti ","25","account_type_payable","payable","TRUE" +"26","26","DEBITI DIVERSI ","2","account_type_view","view","TRUE" +"2601","2601","IVA n/debito ","26","account_type_payable","other","TRUE" +"2602","2602","debiti per ritenute da versare ","26","account_type_payable","other","TRUE" +"2605","2605","erario c/IVA ","26","account_type_payable","payable","TRUE" +"2606","2606","debiti per imposte ","26","account_type_payable","other","TRUE" +"2619","2619","debiti per cauzioni ","26","account_type_payable","other","TRUE" +"2620","2620","personale c/retribuzioni ","26","account_type_payable","other","TRUE" +"2621","2621","personale c/liquidazioni ","26","account_type_payable","other","TRUE" +"2622","2622","clienti c/cessione ","26","account_type_payable","other","TRUE" +"2630","2630","debiti v/istituti previdenziali ","26","account_type_payable","other","TRUE" +"2640","2640","creditori diversi ","26","account_type_payable","payable","TRUE" +"27","27","RATEI E RISCONTI PASSIVI ","2","account_type_view","view","TRUE" +"2701","2701","ratei passivi ","27","account_type_view","other","TRUE" +"2702","2702","risconti passivi ","27","account_type_view","other","TRUE" +"28","28","CONTI TRANSITORI E DIVERSI ","2","account_type_view","view","TRUE" +"2801","2801","bilancio di apertura ","28","account_type_view","other","TRUE" +"2802","2802","bilancio di chiusura ","28","account_type_view","other","TRUE" +"2810","2810","IVA c/liquidazioni ","28","account_type_view","other","TRUE" +"2811","2811","istituti previdenziali ","28","account_type_view","other","TRUE" +"2820","2820","banca ... c/c ","28","account_type_view","other","TRUE" +"2821","2821","banca ... c/c ","28","account_type_view","other","TRUE" +"2822","2822","banca ... c/c ","28","account_type_view","other","TRUE" +"29","29","CONTI DEI SISTEMI SUPPLEMENTARI ","2","account_type_view","view","TRUE" +"2901","2901","beni di terzi ","29","account_type_view","other","TRUE" +"2902","2902","depositanti beni ","29","account_type_view","other","TRUE" +"2911","2911","merci da ricevere ","29","account_type_view","other","TRUE" +"2912","2912","fornitori c/impegni ","29","account_type_view","other","TRUE" +"2913","2913","impegni per beni in leasing ","29","account_type_view","other","TRUE" +"2914","2914","creditori c/leasing ","29","account_type_view","other","TRUE" +"2916","2916","clienti c/impegni ","29","account_type_view","other","TRUE" +"2917","2917","merci da consegnare ","29","account_type_view","other","TRUE" +"2921","2921","rischi per effetti scontati ","29","account_type_view","other","TRUE" +"2922","2922","banche c/effetti scontati ","29","account_type_view","other","TRUE" +"2926","2926","rischi per fideiussioni ","29","account_type_view","other","TRUE" +"2927","2927","creditori per fideiussioni ","29","account_type_view","other","TRUE" +"2931","2931","rischi per avalli ","29","account_type_view","other","TRUE" +"2932","2932","creditori per avalli ","29","account_type_view","other","TRUE" +"3","3","VALORE DELLA PRODUZIONE ","0","account_type_view","view","TRUE" +"31","31","VENDITE E PRESTAZIONI ","3","account_type_view","view","TRUE" +"3101","3101","merci c/vendite ","31","account_type_income","other","TRUE" +"3103","3103","rimborsi spese di vendita ","31","account_type_income","other","TRUE" +"3110","3110","resi su vendite ","31","account_type_income","other","TRUE" +"3111","3111","ribassi e abbuoni passivi ","31","account_type_income","other","TRUE" +"3112","3112","premi su vendite ","31","account_type_income","other","TRUE" +"32","32","RICAVI E PROVENTI DIVERSI ","3","account_type_view","view","TRUE" +"3201","3201","fitti attivi ","32","account_type_income","other","TRUE" +"3202","3202","proventi vari ","32","account_type_income","other","TRUE" +"3210","3210","arrotondamenti attivi ","32","account_type_income","other","TRUE" +"3220","3220","plusvalenze ordinarie diverse ","32","account_type_income","other","TRUE" +"3230","3230","sopravvenienze attive ordinarie diverse ","32","account_type_income","other","TRUE" +"3240","3240","insussistenze attive ordinarie diverse ","32","account_type_income","other","TRUE" +"4","4","COSTI DELLA PRODUZIONE ","0","account_type_view","view","TRUE" +"41","41","COSTO DEL VENDUTO ","4","account_type_view","view","TRUE" +"4101","4101","merci c/acquisti ","41","account_type_expense","other","TRUE" +"4102","4102","materie di consumo c/acquisti ","41","account_type_expense","other","TRUE" +"4105","4105","merci c/apporti ","41","account_type_expense","other","TRUE" +"4110","4110","resi su acquisti ","41","account_type_expense","other","TRUE" +"4111","4111","ribassi e abbuoni attivi ","41","account_type_expense","other","TRUE" +"4112","4112","premi su acquisti ","41","account_type_expense","other","TRUE" +"4121","4121","merci c/esistenze iniziali ","41","account_type_expense","other","TRUE" +"4122","4122","materie di consumo c/esistenze iniziali ","41","account_type_expense","other","TRUE" +"4131","4131","merci c/rimanenze finali ","41","account_type_expense","other","TRUE" +"4132","4132","materie di consumo c/rimanenze finali ","41","account_type_expense","other","TRUE" +"42","42","COSTI PER SERVIZI ","4","account_type_view","view","TRUE" +"4201","4201","costi di trasporto ","42","account_type_expense","other","TRUE" +"4202","4202","costi per energia ","42","account_type_expense","other","TRUE" +"4203","4203","costi di pubblicità ","42","account_type_expense","other","TRUE" +"4204","4204","costi di consulenze ","42","account_type_expense","other","TRUE" +"4205","4205","costi postali ","42","account_type_expense","other","TRUE" +"4206","4206","costi telefonici ","42","account_type_expense","other","TRUE" +"4207","4207","costi di assicurazione ","42","account_type_expense","other","TRUE" +"4208","4208","costi di vigilanza ","42","account_type_expense","other","TRUE" +"4209","4209","costi per i locali ","42","account_type_expense","other","TRUE" +"4210","4210","costi di esercizio automezzi ","42","account_type_expense","other","TRUE" +"4211","4211","costi di manutenzione e riparazione ","42","account_type_expense","other","TRUE" +"4212","4212","provvigioni passive ","42","account_type_expense","other","TRUE" +"4213","4213","spese di incasso ","42","account_type_expense","other","TRUE" +"43","43","COSTI PER GODIMENTO BENI DI TERZI ","4","account_type_view","view","TRUE" +"4301","4301","fitti passivi ","43","account_type_expense","other","TRUE" +"4302","4302","canoni di leasing ","43","account_type_expense","other","TRUE" +"44","44","COSTI PER IL PERSONALE ","4","account_type_view","view","TRUE" +"4401","4401","salari e stipendi ","44","account_type_expense","other","TRUE" +"4402","4402","oneri sociali ","44","account_type_expense","other","TRUE" +"4403","4403","TFRL ","44","account_type_expense","other","TRUE" +"4404","4404","altri costi per il personale ","44","account_type_expense","other","TRUE" +"45","45","AMMORTAMENTI IMMOBILIZZAZIONI IMMATERIALI ","4","account_type_view","view","TRUE" +"4501","4501","ammortamento costi di impianto ","45","account_type_view","other","TRUE" +"4506","4506","ammortamento software ","45","account_type_view","other","TRUE" +"4508","4508","ammortamento avviamento ","45","account_type_view","other","TRUE" +"46","46","AMMORTAMENTI IMMOBILIZZAZIONI MATERIALI ","4","account_type_view","view","TRUE" +"4601","4601","ammortamento fabbricati ","46","account_type_view","other","TRUE" +"4602","4602","ammortamento impianti e macchinari ","46","account_type_view","other","TRUE" +"4604","4604","ammortamento attrezzature commerciali ","46","account_type_view","other","TRUE" +"4605","4605","ammortamento macchine d'ufficio ","46","account_type_view","other","TRUE" +"4606","4606","ammortamento arredamento ","46","account_type_view","other","TRUE" +"4607","4607","ammortamento automezzi ","46","account_type_view","other","TRUE" +"4608","4608","ammortamento imballaggi durevoli ","46","account_type_view","other","TRUE" +"47","47","SVALUTAZIONI ","4","account_type_view","view","TRUE" +"4701","4701","svalutazioni immobilizzazioni immateriali ","47","account_type_view","other","TRUE" +"4702","4702","svalutazioni immobilizzazioni materiali ","47","account_type_view","other","TRUE" +"4706","4706","svalutazione crediti ","47","account_type_view","other","TRUE" +"48","48","ACCANTONAMENTI ","4","account_type_view","view","TRUE" +"481","481","ACCANTONAMENTI PER RISCHI ","48","account_type_view","view","TRUE" +"4814","4814","accantonamento per responsabilità civile ","481","account_type_view","other","TRUE" +"482","482","ALTRI ACCANTONAMENTI ","48","account_type_view","view","TRUE" +"4821","4821","accantonamento per spese future ","482","account_type_view","other","TRUE" +"4823","4823","accantonamento per manutenzioni programmate ","482","account_type_view","other","TRUE" +"49","49","ONERI DIVERSI ","4","account_type_view","view","TRUE" +"4901","4901","oneri fiscali diversi ","49","account_type_view","other","TRUE" +"4903","4903","oneri vari ","49","account_type_view","other","TRUE" +"4905","4905","perdite su crediti ","49","account_type_view","other","TRUE" +"4910","4910","arrotondamenti passivi ","49","account_type_view","other","TRUE" +"4920","4920","minusvalenze ordinarie diverse ","49","account_type_view","other","TRUE" +"4930","4930","sopravvenienze passive ordinarie diverse ","49","account_type_view","other","TRUE" +"4940","4940","insussistenze passive ordinarie diverse ","49","account_type_view","other","TRUE" +"5","5","PROVENTI E ONERI FINANZIARI ","0","account_type_view","view","TRUE" +"51","51","PROVENTI FINANZIARI ","5","account_type_view","view","TRUE" +"5110","5110","interessi attivi v/clienti ","51","account_type_view","other","TRUE" +"5115","5115","interessi attivi bancari ","51","account_type_view","other","TRUE" +"5116","5116","interessi attivi postali ","51","account_type_view","other","TRUE" +"5140","5140","proventi finanziari diversi ","51","account_type_view","other","TRUE" +"52","52","ONERI FINANZIARI ","5","account_type_view","view","TRUE" +"5201","5201","interessi passivi v/fornitori ","52","account_type_view","other","TRUE" +"5202","5202","interessi passivi bancari ","52","account_type_view","other","TRUE" +"5203","5203","sconti passivi bancari ","52","account_type_view","other","TRUE" +"5210","5210","interessi passivi su mutui ","52","account_type_view","other","TRUE" +"5240","5240","oneri finanziari diversi ","52","account_type_view","other","TRUE" +"7","7","PROVENTI E ONERI STRAORDINARI ","0","account_type_view","view","TRUE" +"71","71","PROVENTI STRAORDINARI ","7","account_type_view","view","TRUE" +"7101","7101","plusvalenze straordinarie ","71","account_type_view","other","TRUE" +"7102","7102","sopravvenienze attive straordinarie ","71","account_type_view","other","TRUE" +"7103","7103","insussistenze attive straordinarie ","71","account_type_view","other","TRUE" +"72","72","ONERI STRAORDINARI ","7","account_type_view","view","TRUE" +"7201","7201","minusvalenze straordinarie ","72","account_type_view","other","TRUE" +"7202","7202","sopravvenienze passive straordinarie ","72","account_type_view","other","TRUE" +"7203","7203","insussistenze passive straordinarie ","72","account_type_view","other","TRUE" +"7204","7204","imposte esercizi precedenti ","72","account_type_view","other","TRUE" +"81","81","IMPOSTE DELL'ESERCIZIO ","7","account_type_view","view","TRUE" +"8101","8101","imposte dell'esercizio ","81","account_type_view","other","TRUE" +"91","91","CONTI DI RISULTATO ","7","account_type_view","view","TRUE" +"9101","9101","conto di risultato economico ","91","account_type_view","other","TRUE" From 2fef7cd890150c20b4cb9835d601263de1ba5632 Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Mon, 5 Sep 2011 14:39:26 +0530 Subject: [PATCH 004/278] [IMP]:refactored with speed improvement:get_value_text method bzr revid: nch@tinyerp.com-20110905090926-jjklwr3p12sbjzl2 --- addons/audittrail/audittrail.py | 50 +++++++++++---------------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index ffb44502ba4..0780679f49c 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -203,37 +203,22 @@ class audittrail_objects_proxy(object_proxy): if field_name in('__last_update','id'): return values pool = pooler.get_pool(cr.dbname) - field_pool = pool.get('ir.model.fields') - model_pool = pool.get('ir.model') obj_pool = pool.get(model.model) - if obj_pool._inherits: - inherits_ids = model_pool.search(cr, uid, [('model', '=', obj_pool._inherits.keys()[0])]) - field_ids = field_pool.search(cr, uid, [('name', '=', field_name), ('model_id', 'in', (model.id, inherits_ids[0]))]) - else: - field_ids = field_pool.search(cr, uid, [('name', '=', field_name), ('model_id', '=', model.id)]) - field_id = field_ids and field_ids[0] or False - assert field_id, _("'%s' field does not exist in '%s' model" %(field_name, model.model)) - - field = field_pool.read(cr, uid, field_id) - relation_model = field['relation'] - relation_model_pool = relation_model and pool.get(relation_model) or False - - if field['ttype'] == 'many2one': - res = False - relation_id = False - if values and type(values) == tuple: - relation_id = values[0] - if relation_id and relation_model_pool: - relation_model_object = relation_model_pool.read(cr, uid, relation_id, [relation_model_pool._rec_name]) - res = relation_model_object[relation_model_pool._rec_name] - return res - - elif field['ttype'] in ('many2many','one2many'): - res = [] - for relation_model_object in relation_model_pool.read(cr, uid, values, [relation_model_pool._rec_name]): - res.append(relation_model_object[relation_model_pool._rec_name]) - return res - + field_obj = obj_pool._all_columns.get(field_name, False) + assert field_obj, _("'%s' field does not exist in '%s' model" %(field_name, model.model)) + field_obj = field_obj.column + if field_obj._obj: + relation_model_pool = pool.get(field_obj._obj) + relational_rec_name = relation_model_pool._rec_name + if field_obj._type == 'many2one': + if values and isinstance(values, tuple): + if values[0]: + relation_model_object = relation_model_pool.read(cr, uid, values[0], [relational_rec_name]) + return relation_model_object.get(relational_rec_name) + return False + elif field_obj._type in ('many2many','one2many'): + data = relation_model_pool.read(cr, uid, values, [relational_rec_name]) + return map(lambda x:x.get(relational_rec_name, False), data) return values def create_log_line(self, cr, uid, log_id, model, lines=[]): @@ -482,7 +467,6 @@ class audittrail_objects_proxy(object_proxy): cr = pooler.get_db(db).cursor() cr.autocommit(True) logged_uids = [] - rule = False ignore_methods = ['default_get','read','fields_view_get','fields_get','search', 'search_count','name_search','name_get','get','request_get', 'get_sc', 'unlink', 'write', 'create'] @@ -490,9 +474,7 @@ class audittrail_objects_proxy(object_proxy): try: model_ids = model_pool.search(cr, uid, [('model', '=', model)]) model_id = model_ids and model_ids[0] or False - if 'audittrail.rule' in pool.obj_list(): - rule = True - if not rule or not model_id: + if not ('audittrail.rule' in pool.obj_list()) or not model_id: return fct_src(db, uid_orig, model, method, *args) rule_ids = rule_pool.search(cr, uid, [('object_id', '=', model_id), ('state', '=', 'subscribed')]) if not rule_ids: From 9ebdf040f574d1da0697435fdc4acae864085aec Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Mon, 5 Sep 2011 15:08:41 +0530 Subject: [PATCH 005/278] [IMP]:refactored create_log_line method bzr revid: nch@tinyerp.com-20110905093841-uk7nke7e36gsf4ig --- addons/audittrail/audittrail.py | 39 ++++++++++++++------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index 0780679f49c..99382797d72 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -235,43 +235,36 @@ class audittrail_objects_proxy(object_proxy): model_pool = pool.get('ir.model') field_pool = pool.get('ir.model.fields') log_line_pool = pool.get('audittrail.log.line') - #start Loop for line in lines: - if line['name'] in('__last_update','id'): + if line['name'] in ('__last_update','id'): continue + field_obj = obj_pool._all_columns.get(line['name'], False) + assert field_obj, _("'%s' field does not exist in '%s' model" %(line['name'], model.model)) + field_obj = field_obj.column + old_value = line.get('old_value', '') + new_value = line.get('new_value', '') + old_value_text = line.get('old_value_text', '') + new_value_text = line.get('new_value_text', '') + search_models = [ model.id ] if obj_pool._inherits: - inherits_ids = model_pool.search(cr, uid, [('model', '=', obj_pool._inherits.keys()[0])]) - field_ids = field_pool.search(cr, uid, [('name', '=', line['name']), ('model_id', 'in', (model.id, inherits_ids[0]))]) - else: - field_ids = field_pool.search(cr, uid, [('name', '=', line['name']), ('model_id', '=', model.id)]) - field_id = field_ids and field_ids[0] or False - assert field_id, _("'%s' field does not exist in '%s' model" %(line['name'], model.model)) - - field = field_pool.read(cr, uid, field_id) - old_value = 'old_value' in line and line['old_value'] or '' - new_value = 'new_value' in line and line['new_value'] or '' - old_value_text = 'old_value_text' in line and line['old_value_text'] or '' - new_value_text = 'new_value_text' in line and line['new_value_text'] or '' - + search_models += model_pool.search(cr, uid, [('model', 'in', obj_pool._inherits.keys())]) + field_id = field_pool.search(cr, uid, [('name', '=', line['name']), ('model_id', 'in', search_models)]) if old_value_text == new_value_text: continue - if field['ttype'] == 'many2one': - if type(old_value) == tuple: - old_value = old_value[0] - if type(new_value) == tuple: - new_value = new_value[0] + if field_obj._type == 'many2one': + old_value = isinstance(old_value, tuple) and old_value[0] or old_value + new_value = isinstance(new_value, tuple) and new_value[0] or new_value vals = { "log_id": log_id, - "field_id": field_id, + "field_id": field_id and field_id[0] or False, "old_value": old_value, "new_value": new_value, "old_value_text": old_value_text, "new_value_text": new_value_text, - "field_description": field['field_description'] + "field_description": field_obj.string } line_id = log_line_pool.create(cr, uid, vals) cr.commit() - #End Loop return True From 2a828b8f5e86ce16bce6a114a34a8f893bed7c6e Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Mon, 5 Sep 2011 17:38:46 +0530 Subject: [PATCH 006/278] [IMP]:refactored log_fct to include create for o2m, m2m method bzr revid: nch@tinyerp.com-20110905120846-sletd1fvcfloqdxy --- addons/audittrail/audittrail.py | 55 +++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index 99382797d72..841eda00d29 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -292,31 +292,38 @@ class audittrail_objects_proxy(object_proxy): model_id = model_ids and model_ids[0] or False assert model_id, _("'%s' Model does not exist..." %(model)) model = model_pool.browse(cr, uid, model_id) - + relational_table_log = args and args[-1] == 'child_relation_log' or False if method in ('create'): - res_id = fct_src(db, uid_orig, model.model, method, *args) - cr.commit() - resource = resource_pool.read(cr, uid, res_id, args[0].keys()) - vals = { - "method": method, - "object_id": model.id, - "user_id": uid_orig, - "res_id": resource['id'], - } - if 'id' in resource: - del resource['id'] - log_id = log_pool.create(cr, uid, vals) - lines = [] - for field in resource: - line = { - 'name': field, - 'new_value': resource[field], - 'new_value_text': self.get_value_text(cr, uid, field, resource[field], model) - } - lines.append(line) - self.create_log_line(cr, uid, log_id, model, lines) - - cr.commit() + fields_to_read = [] + if relational_table_log: + res_id = args[0] + else: + res_id = fct_src(db, uid_orig, model.model, method, *args) + cr.commit() + fields_to_read = args[0].keys() + resource = resource_pool.read(cr, uid, res_id, fields_to_read) + if not isinstance(resource, list): + resource = [resource] + vals = { 'method': method, 'object_id': model.id,'user_id': uid_orig} + for resource_data in resource: + vals.update({'res_id': resource_data['id']}) + if 'id' in resource_data: + del resource_data['id'] + log_id = log_pool.create(cr, uid, vals) + lines = [] + for field in resource_data: + field_obj = resource_pool._all_columns.get(field, False) + field_obj = field_obj.column + if field_obj._type in ('one2many','many2many'): + self.log_fct(db, uid, field_obj._obj, method, None, resource_data[field], 'child_relation_log') + line = { + 'name': field, + 'new_value': resource_data[field], + 'new_value_text': self.get_value_text(cr, uid, field, resource_data[field], model) + } + lines.append(line) + self.create_log_line(cr, uid, log_id, model, lines) + cr.commit() cr.close() return res_id From 43ff15c84d7f6f674e0201a2674b2a5a4e3c7082 Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Tue, 6 Sep 2011 11:01:24 +0530 Subject: [PATCH 007/278] [IMP]:get_value_text to use name_get for x2m and simply return [1] arg for m2o tuple bzr revid: nch@tinyerp.com-20110906053124-a3kw3j2g3weln60q --- addons/audittrail/audittrail.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index 841eda00d29..1d42000488d 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -204,21 +204,19 @@ class audittrail_objects_proxy(object_proxy): return values pool = pooler.get_pool(cr.dbname) obj_pool = pool.get(model.model) - field_obj = obj_pool._all_columns.get(field_name, False) + field_obj = obj_pool._all_columns.get(field_name) assert field_obj, _("'%s' field does not exist in '%s' model" %(field_name, model.model)) field_obj = field_obj.column if field_obj._obj: relation_model_pool = pool.get(field_obj._obj) relational_rec_name = relation_model_pool._rec_name if field_obj._type == 'many2one': - if values and isinstance(values, tuple): - if values[0]: - relation_model_object = relation_model_pool.read(cr, uid, values[0], [relational_rec_name]) - return relation_model_object.get(relational_rec_name) - return False + if values: + return values[1] + return values elif field_obj._type in ('many2many','one2many'): - data = relation_model_pool.read(cr, uid, values, [relational_rec_name]) - return map(lambda x:x.get(relational_rec_name, False), data) + data = relation_model_pool.name_get(cr, uid, values) + return map(lambda x:x[1], data) return values def create_log_line(self, cr, uid, log_id, model, lines=[]): @@ -312,7 +310,7 @@ class audittrail_objects_proxy(object_proxy): log_id = log_pool.create(cr, uid, vals) lines = [] for field in resource_data: - field_obj = resource_pool._all_columns.get(field, False) + field_obj = resource_pool._all_columns.get(field) field_obj = field_obj.column if field_obj._type in ('one2many','many2many'): self.log_fct(db, uid, field_obj._obj, method, None, resource_data[field], 'child_relation_log') From 1947eed2df667bfd59b7c42306e19ab390170e96 Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Tue, 6 Sep 2011 11:24:31 +0530 Subject: [PATCH 008/278] [IMP]:support for x2m log unlink bzr revid: nch@tinyerp.com-20110906055431-a87bvbm0o7p1hts5 --- addons/audittrail/audittrail.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index 1d42000488d..3f4417a15bb 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -359,33 +359,31 @@ class audittrail_objects_proxy(object_proxy): elif method in ('unlink'): res_ids = args[0] + res = False old_values = {} for res_id in res_ids: old_values[res_id] = resource_pool.read(cr, uid, res_id) - + vals = {'method': method,'object_id': model.id,'user_id': uid_orig} for res_id in res_ids: - vals = { - "method": method, - "object_id": model.id, - "user_id": uid_orig, - "res_id": res_id, - - } + vals.update({'res_id': res_id}) log_id = log_pool.create(cr, uid, vals) lines = [] for field in old_values[res_id]: - if field in ('id'): - continue + if field == 'id': continue + field_obj = resource_pool._all_columns.get(field) + field_obj = field_obj.column + if field_obj._type in ('one2many','many2many'): + self.log_fct(db, uid, field_obj._obj, method, None, old_values[res_id][field], 'child_relation_log') line = { 'name': field, 'old_value': old_values[res_id][field], 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model) } lines.append(line) - self.create_log_line(cr, uid, log_id, model, lines) - res = fct_src(db, uid_orig, model.model, method, *args) - cr.commit() + if not relational_table_log: + res = fct_src(db, uid_orig, model.model, method, *args) + cr.commit() cr.close() return res else: From d213821ea0dc2b000f95df025be8f45cefa63330 Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Tue, 6 Sep 2011 11:52:41 +0530 Subject: [PATCH 009/278] [IMP]:x2m logging when there is any action execute like on_change,copy etc bzr revid: nch@tinyerp.com-20110906062241-373t8wqelc9jsyk9 --- addons/audittrail/audittrail.py | 46 +++++++++++++++------------------ 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index 3f4417a15bb..ed4fc5a551d 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -236,7 +236,7 @@ class audittrail_objects_proxy(object_proxy): for line in lines: if line['name'] in ('__last_update','id'): continue - field_obj = obj_pool._all_columns.get(line['name'], False) + field_obj = obj_pool._all_columns.get(line['name']) assert field_obj, _("'%s' field does not exist in '%s' model" %(line['name'], model.model)) field_obj = field_obj.column old_value = line.get('old_value', '') @@ -250,8 +250,8 @@ class audittrail_objects_proxy(object_proxy): if old_value_text == new_value_text: continue if field_obj._type == 'many2one': - old_value = isinstance(old_value, tuple) and old_value[0] or old_value - new_value = isinstance(new_value, tuple) and new_value[0] or new_value + old_value = old_value[0] + new_value = new_value[0] vals = { "log_id": log_id, "field_id": field_id and field_id[0] or False, @@ -305,8 +305,7 @@ class audittrail_objects_proxy(object_proxy): vals = { 'method': method, 'object_id': model.id,'user_id': uid_orig} for resource_data in resource: vals.update({'res_id': resource_data['id']}) - if 'id' in resource_data: - del resource_data['id'] + del resource_data['id'] log_id = log_pool.create(cr, uid, vals) lines = [] for field in resource_data: @@ -393,38 +392,36 @@ class audittrail_objects_proxy(object_proxy): res_ids = args[0] old_values = {} fields = [] - if len(args)>1 and type(args[1]) == dict: + if len(args) > 1 and isinstance(args[1], dict): fields = args[1].keys() - if type(res_ids) in (long, int): + if isinstance(res_ids, (long, int)): res_ids = [res_ids] if res_ids: - for resource in resource_pool.read(cr, uid, res_ids): + resource_data = resource_pool.read(cr, uid, res_ids) + for resource in resource_data: resource_id = resource['id'] - if 'id' in resource: - del resource['id'] + del resource['id'] old_values_text = {} old_value = {} for field in resource.keys(): + field_obj = resource_pool._all_columns.get(field) + field_obj = field_obj.column + if field_obj._type in ('one2many','many2many'): + self.log_fct(db, uid, field_obj._obj, method, None, resource[field], 'child_relation_log') old_value[field] = resource[field] old_values_text[field] = self.get_value_text(cr, uid, field, resource[field], model) old_values[resource_id] = {'text':old_values_text, 'value': old_value} - - res = fct_src(db, uid_orig, model.model, method, *args) - cr.commit() + if not relational_table_log: + res = fct_src(db, uid_orig, model.model, method, *args) + cr.commit() if res_ids: - for resource in resource_pool.read(cr, uid, res_ids): + resource_data = resource_pool.read(cr, uid, res_ids) + vals = {'method': method,'object_id': model.id,'user_id': uid_orig } + for resource in resource_data: resource_id = resource['id'] - if 'id' in resource: - del resource['id'] - vals = { - "method": method, - "object_id": model.id, - "user_id": uid_orig, - "res_id": resource_id, - } - - + del resource['id'] + vals.update({'res_id': resource_id}) log_id = log_pool.create(cr, uid, vals) lines = [] for field in resource.keys(): @@ -436,7 +433,6 @@ class audittrail_objects_proxy(object_proxy): 'old_value_text': old_values[resource_id]['text'][field] } lines.append(line) - self.create_log_line(cr, uid, log_id, model, lines) cr.commit() cr.close() From c70d21b6227dac93a0765e80f80a80a3718c532e Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Tue, 6 Sep 2011 12:24:16 +0530 Subject: [PATCH 010/278] [IMP]:refactored: removed code duplication bzr revid: nch@tinyerp.com-20110906065416-33abo0zg1e6n55v5 --- addons/audittrail/audittrail.py | 85 +++++++++++---------------------- 1 file changed, 28 insertions(+), 57 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index ed4fc5a551d..4fd99d7bba3 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -250,8 +250,8 @@ class audittrail_objects_proxy(object_proxy): if old_value_text == new_value_text: continue if field_obj._type == 'many2one': - old_value = old_value[0] - new_value = new_value[0] + old_value = old_value and old_value[0] or old_value + new_value = new_value and new_value[0] or new_value vals = { "log_id": log_id, "field_id": field_id and field_id[0] or False, @@ -439,90 +439,61 @@ class audittrail_objects_proxy(object_proxy): return res return True - - - def execute(self, db, uid, model, method, *args, **kw): + def audit_log_call(self, db, uid, model, method, action_type, *args, **argv): """ Overrides Object Proxy execute method @param db: the current database @param uid: the current user's ID for security checks, @param object: Object who's values are being changed @param method: get any method and create log - + @param action_type: either 'execute' or 'workflow' @return: Returns result as per method of Object proxy """ uid_orig = uid uid = 1 pool = pooler.get_pool(db) + logged_uids = [] model_pool = pool.get('ir.model') rule_pool = pool.get('audittrail.rule') cr = pooler.get_db(db).cursor() cr.autocommit(True) - logged_uids = [] - ignore_methods = ['default_get','read','fields_view_get','fields_get','search', - 'search_count','name_search','name_get','get','request_get', - 'get_sc', 'unlink', 'write', 'create'] - fct_src = super(audittrail_objects_proxy, self).execute + if action_type == 'execute': + ignore_methods = ['default_get','read','fields_view_get','fields_get','search', + 'search_count','name_search','name_get','get','request_get', + 'get_sc', 'unlink', 'write', 'create'] + fct_src = super(audittrail_objects_proxy, self).execute + else: + fct_src = super(audittrail_objects_proxy, self).exec_workflow try: model_ids = model_pool.search(cr, uid, [('model', '=', model)]) model_id = model_ids and model_ids[0] or False if not ('audittrail.rule' in pool.obj_list()) or not model_id: - return fct_src(db, uid_orig, model, method, *args) + return fct_src(db, uid_orig, model, method, *args, **argv) rule_ids = rule_pool.search(cr, uid, [('object_id', '=', model_id), ('state', '=', 'subscribed')]) if not rule_ids: - return fct_src(db, uid_orig, model, method, *args) - + return fct_src(db, uid_orig, model, method, *args, **argv) for model_rule in rule_pool.browse(cr, uid, rule_ids): logged_uids += map(lambda x:x.id, model_rule.user_id) if not logged_uids or uid in logged_uids: - if method in ('read', 'write', 'create', 'unlink'): - if getattr(model_rule, 'log_' + method): + if action_type == 'execute': + if method in ('read', 'write', 'create', 'unlink'): + if getattr(model_rule, 'log_' + method): + return self.log_fct(db, uid_orig, model, method, fct_src, *args) + elif method not in ignore_methods: + if model_rule.log_action: + return self.log_fct(db, uid_orig, model, method, fct_src, *args) + else: + if model_rule.log_workflow: return self.log_fct(db, uid_orig, model, method, fct_src, *args) - elif method not in ignore_methods: - if model_rule.log_action: - return self.log_fct(db, uid_orig, model, method, fct_src, *args) - return fct_src(db, uid_orig, model, method, *args) + return fct_src(db, uid_orig, model, method, *args, **argv) finally: cr.close() + def execute(self, db, uid, model, method, *args, **argv): + return self.audit_log_call(db, uid, model, method, 'execute', *args, **argv) + def exec_workflow(self, db, uid, model, method, *args, **argv): - uid_orig = uid - uid = 1 - - pool = pooler.get_pool(db) - logged_uids = [] - fct_src = super(audittrail_objects_proxy, self).exec_workflow - field = method - rule = False - model_pool = pool.get('ir.model') - rule_pool = pool.get('audittrail.rule') - cr = pooler.get_db(db).cursor() - cr.autocommit(True) - try: - model_ids = model_pool.search(cr, uid, [('model', '=', model)]) - for obj_name in pool.obj_list(): - if obj_name == 'audittrail.rule': - rule = True - if not rule: - return super(audittrail_objects_proxy, self).exec_workflow(db, uid_orig, model, method, *args, **argv) - if not model_ids: - return super(audittrail_objects_proxy, self).exec_workflow(db, uid_orig, model, method, *args, **argv) - - rule_ids = rule_pool.search(cr, uid, [('object_id', 'in', model_ids), ('state', '=', 'subscribed')]) - if not rule_ids: - return super(audittrail_objects_proxy, self).exec_workflow(db, uid_orig, model, method, *args, **argv) - - for thisrule in rule_pool.browse(cr, uid, rule_ids): - for user in thisrule.user_id: - logged_uids.append(user.id) - if not logged_uids or uid in logged_uids: - if thisrule.log_workflow: - return self.log_fct(db, uid_orig, model, method, fct_src, *args) - return super(audittrail_objects_proxy, self).exec_workflow(db, uid_orig, model, method, *args, **argv) - - return True - finally: - cr.close() + return self.audit_log_call(db, uid, model, method, 'workflow', *args, **argv) audittrail_objects_proxy() From b8596288a8c793c7e1b176d570f291668ab22a1a Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Tue, 6 Sep 2011 15:04:53 +0530 Subject: [PATCH 011/278] [IMP]:removedget_value_text to refactore the code..more improvements coming bzr revid: nch@tinyerp.com-20110906093453-c6z7wj8178w6o75g --- addons/audittrail/audittrail.py | 112 +++++++++++++++----------------- 1 file changed, 53 insertions(+), 59 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index 4fd99d7bba3..41205982101 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -187,38 +187,6 @@ audittrail_log_line() class audittrail_objects_proxy(object_proxy): """ Uses Object proxy for auditing changes on object of subscribed Rules""" - def get_value_text(self, cr, uid, field_name, values, model, context=None): - """ - Gets textual values for the fields - e.g.: For field of type many2one it gives its name value instead of id - - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param field_name: List of fields for text values - @param values: Values for field to be converted into textual values - @return: values: List of textual values for given fields - """ - if not context: - context = {} - if field_name in('__last_update','id'): - return values - pool = pooler.get_pool(cr.dbname) - obj_pool = pool.get(model.model) - field_obj = obj_pool._all_columns.get(field_name) - assert field_obj, _("'%s' field does not exist in '%s' model" %(field_name, model.model)) - field_obj = field_obj.column - if field_obj._obj: - relation_model_pool = pool.get(field_obj._obj) - relational_rec_name = relation_model_pool._rec_name - if field_obj._type == 'many2one': - if values: - return values[1] - return values - elif field_obj._type in ('many2many','one2many'): - data = relation_model_pool.name_get(cr, uid, values) - return map(lambda x:x[1], data) - return values - def create_log_line(self, cr, uid, log_id, model, lines=[]): """ Creates lines for changed fields with its old and new values @@ -234,8 +202,6 @@ class audittrail_objects_proxy(object_proxy): field_pool = pool.get('ir.model.fields') log_line_pool = pool.get('audittrail.log.line') for line in lines: - if line['name'] in ('__last_update','id'): - continue field_obj = obj_pool._all_columns.get(line['name']) assert field_obj, _("'%s' field does not exist in '%s' model" %(line['name'], model.model)) field_obj = field_obj.column @@ -279,7 +245,6 @@ class audittrail_objects_proxy(object_proxy): """ uid_orig = uid uid = 1 - res2 = args pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() resource_pool = pool.get(model) @@ -303,6 +268,7 @@ class audittrail_objects_proxy(object_proxy): if not isinstance(resource, list): resource = [resource] vals = { 'method': method, 'object_id': model.id,'user_id': uid_orig} + new_value_text = '' for resource_data in resource: vals.update({'res_id': resource_data['id']}) del resource_data['id'] @@ -311,12 +277,18 @@ class audittrail_objects_proxy(object_proxy): for field in resource_data: field_obj = resource_pool._all_columns.get(field) field_obj = field_obj.column + new_value_text = resource_data[field] + if field in ('__last_update', 'id'):continue if field_obj._type in ('one2many','many2many'): self.log_fct(db, uid, field_obj._obj, method, None, resource_data[field], 'child_relation_log') + data = pool.get(field_obj._obj).name_get(cr, uid, resource_data[field]) + new_value_text = map(lambda x:x[1], data) + elif field_obj._type == 'many2one': + new_value_text = resource_data[field] and resource_data[field][1] or resource_data[field] line = { 'name': field, 'new_value': resource_data[field], - 'new_value_text': self.get_value_text(cr, uid, field, resource_data[field], model) + 'new_value_text': new_value_text } lines.append(line) self.create_log_line(cr, uid, log_id, model, lines) @@ -328,29 +300,29 @@ class audittrail_objects_proxy(object_proxy): res_ids = args[0] old_values = {} res = fct_src(db, uid_orig, model.model, method, *args) - if type(res) == list: - for v in res: - old_values[v['id']] = v - else: - old_values[res['id']] = res + map(lambda x:old_values.setdefault(x['id'], x), res) + vals = {'method': method,'object_id': model.id,'user_id': uid_orig} + old_value_text = '' for res_id in old_values: - vals = { - "method": method, - "object_id": model.id, - "user_id": uid_orig, - "res_id": res_id, - - } + vals.update({'res_id': res_id}) log_id = log_pool.create(cr, uid, vals) lines = [] for field in old_values[res_id]: + if field in ('__last_update', 'id'):continue + field_obj = resource_pool._all_columns.get(field) + field_obj = field_obj.column + old_value_text = old_values[res_id][field] + if field_obj._type in ('one2many','many2many'): + data = pool.get(field_obj._obj).name_get(cr, uid, old_values[res_id][field]) + old_value_text = map(lambda x:x[1], data) + elif field_obj._type == 'many2one': + old_value_text = old_values[res_id][field] and old_values[res_id][field][1] or old_values[res_id][field] line = { - 'name': field, - 'old_value': old_values[res_id][field], - 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model) - } + 'name': field, + 'old_value': old_values[res_id][field], + 'old_value_text': old_value_text + } lines.append(line) - self.create_log_line(cr, uid, log_id, model, lines) cr.commit() cr.close() @@ -363,20 +335,26 @@ class audittrail_objects_proxy(object_proxy): for res_id in res_ids: old_values[res_id] = resource_pool.read(cr, uid, res_id) vals = {'method': method,'object_id': model.id,'user_id': uid_orig} + old_value_text = '' for res_id in res_ids: vals.update({'res_id': res_id}) log_id = log_pool.create(cr, uid, vals) lines = [] for field in old_values[res_id]: - if field == 'id': continue + if field in ('__last_update', 'id'):continue field_obj = resource_pool._all_columns.get(field) field_obj = field_obj.column + old_value_text = old_values[res_id][field] if field_obj._type in ('one2many','many2many'): self.log_fct(db, uid, field_obj._obj, method, None, old_values[res_id][field], 'child_relation_log') + data = pool.get(field_obj._obj).name_get(cr, uid, old_values[res_id][field]) + old_value_text = map(lambda x:x[1], data) + elif field_obj._type == 'many2one': + old_value_text = old_values[res_id][field] and old_values[res_id][field][1] or old_values[res_id][field] line = { 'name': field, 'old_value': old_values[res_id][field], - 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model) + 'old_value_text': old_value_text } lines.append(line) self.create_log_line(cr, uid, log_id, model, lines) @@ -398,26 +376,33 @@ class audittrail_objects_proxy(object_proxy): res_ids = [res_ids] if res_ids: resource_data = resource_pool.read(cr, uid, res_ids) + old_text = '' for resource in resource_data: resource_id = resource['id'] del resource['id'] old_values_text = {} old_value = {} for field in resource.keys(): + if field in ('__last_update', 'id'):continue field_obj = resource_pool._all_columns.get(field) field_obj = field_obj.column + old_text = resource[field] if field_obj._type in ('one2many','many2many'): - self.log_fct(db, uid, field_obj._obj, method, None, resource[field], 'child_relation_log') + self.log_fct(db, uid, field_obj._obj, method, None, resource[field], 'child_relation_log') + data = pool.get(field_obj._obj).name_get(cr, uid, resource[field]) + old_text = map(lambda x:x[1], data) + elif field_obj._type == 'many2one': + old_text = resource[field] and resource[field][1] or resource[field] old_value[field] = resource[field] - old_values_text[field] = self.get_value_text(cr, uid, field, resource[field], model) + old_values_text[field] = old_text old_values[resource_id] = {'text':old_values_text, 'value': old_value} if not relational_table_log: res = fct_src(db, uid_orig, model.model, method, *args) cr.commit() - if res_ids: resource_data = resource_pool.read(cr, uid, res_ids) vals = {'method': method,'object_id': model.id,'user_id': uid_orig } + old_value_text = '' for resource in resource_data: resource_id = resource['id'] del resource['id'] @@ -425,11 +410,20 @@ class audittrail_objects_proxy(object_proxy): log_id = log_pool.create(cr, uid, vals) lines = [] for field in resource.keys(): + if field in ('__last_update', 'id'):continue + field_obj = resource_pool._all_columns.get(field) + field_obj = field_obj.column + old_value_text = resource[field] + if field_obj._type in ('one2many','many2many'): + data = pool.get(field_obj._obj).name_get(cr, uid, resource[field]) + old_value_text = map(lambda x:x[1], data) + elif field_obj._type == 'many2one': + old_value_text = resource[field] and resource[field][1] or resource[field] line = { 'name': field, 'new_value': resource[field], 'old_value': old_values[resource_id]['value'][field], - 'new_value_text': self.get_value_text(cr, uid, field, resource[field], model), + 'new_value_text': old_value_text, 'old_value_text': old_values[resource_id]['text'][field] } lines.append(line) From dbd40832d51837844fbf0a94e842c41defbc56dc Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Tue, 6 Sep 2011 16:19:49 +0530 Subject: [PATCH 012/278] [REF]:more refactoring bzr revid: nch@tinyerp.com-20110906104949-i6uxzcdden0pq71a --- addons/audittrail/audittrail.py | 75 +++++++++------------------------ 1 file changed, 21 insertions(+), 54 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index 41205982101..625d4d46072 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -231,7 +231,17 @@ class audittrail_objects_proxy(object_proxy): cr.commit() return True - + def get_x2m_m2o_values(self, cr, db, uid, pool, resource_pool, method, field, value, recursive=True): + field_obj = (resource_pool._all_columns.get(field)).column + if field_obj._type in ('one2many','many2many'): + if recursive: + self.log_fct(db, uid, field_obj._obj, method, None, value, 'child_relation_log') + data = pool.get(field_obj._obj).name_get(cr, uid, value) + return map(lambda x:x[1], data) + elif field_obj._type == 'many2one': + return value and value[1] or value + return False + def log_fct(self, db, uid, model, method, fct_src, *args): """ Logging function: This function is performs logging operations according to method @@ -268,27 +278,18 @@ class audittrail_objects_proxy(object_proxy): if not isinstance(resource, list): resource = [resource] vals = { 'method': method, 'object_id': model.id,'user_id': uid_orig} - new_value_text = '' for resource_data in resource: vals.update({'res_id': resource_data['id']}) del resource_data['id'] log_id = log_pool.create(cr, uid, vals) lines = [] for field in resource_data: - field_obj = resource_pool._all_columns.get(field) - field_obj = field_obj.column - new_value_text = resource_data[field] if field in ('__last_update', 'id'):continue - if field_obj._type in ('one2many','many2many'): - self.log_fct(db, uid, field_obj._obj, method, None, resource_data[field], 'child_relation_log') - data = pool.get(field_obj._obj).name_get(cr, uid, resource_data[field]) - new_value_text = map(lambda x:x[1], data) - elif field_obj._type == 'many2one': - new_value_text = resource_data[field] and resource_data[field][1] or resource_data[field] + ret_val = self.get_x2m_m2o_values(cr, db, uid, pool, resource_pool, method, field, resource_data[field]) line = { 'name': field, 'new_value': resource_data[field], - 'new_value_text': new_value_text + 'new_value_text': ret_val and ret_val or resource_data[field] } lines.append(line) self.create_log_line(cr, uid, log_id, model, lines) @@ -302,25 +303,17 @@ class audittrail_objects_proxy(object_proxy): res = fct_src(db, uid_orig, model.model, method, *args) map(lambda x:old_values.setdefault(x['id'], x), res) vals = {'method': method,'object_id': model.id,'user_id': uid_orig} - old_value_text = '' for res_id in old_values: vals.update({'res_id': res_id}) log_id = log_pool.create(cr, uid, vals) lines = [] for field in old_values[res_id]: if field in ('__last_update', 'id'):continue - field_obj = resource_pool._all_columns.get(field) - field_obj = field_obj.column - old_value_text = old_values[res_id][field] - if field_obj._type in ('one2many','many2many'): - data = pool.get(field_obj._obj).name_get(cr, uid, old_values[res_id][field]) - old_value_text = map(lambda x:x[1], data) - elif field_obj._type == 'many2one': - old_value_text = old_values[res_id][field] and old_values[res_id][field][1] or old_values[res_id][field] + ret_val = self.get_x2m_m2o_values(cr, db, uid, pool, resource_pool, method, field, old_values[res_id][field], False) line = { 'name': field, 'old_value': old_values[res_id][field], - 'old_value_text': old_value_text + 'old_value_text': ret_val and ret_val or old_values[res_id][field] } lines.append(line) self.create_log_line(cr, uid, log_id, model, lines) @@ -335,26 +328,17 @@ class audittrail_objects_proxy(object_proxy): for res_id in res_ids: old_values[res_id] = resource_pool.read(cr, uid, res_id) vals = {'method': method,'object_id': model.id,'user_id': uid_orig} - old_value_text = '' for res_id in res_ids: vals.update({'res_id': res_id}) log_id = log_pool.create(cr, uid, vals) lines = [] for field in old_values[res_id]: if field in ('__last_update', 'id'):continue - field_obj = resource_pool._all_columns.get(field) - field_obj = field_obj.column - old_value_text = old_values[res_id][field] - if field_obj._type in ('one2many','many2many'): - self.log_fct(db, uid, field_obj._obj, method, None, old_values[res_id][field], 'child_relation_log') - data = pool.get(field_obj._obj).name_get(cr, uid, old_values[res_id][field]) - old_value_text = map(lambda x:x[1], data) - elif field_obj._type == 'many2one': - old_value_text = old_values[res_id][field] and old_values[res_id][field][1] or old_values[res_id][field] + ret_val = self.get_x2m_m2o_values(cr, db, uid, pool, resource_pool, method, field, old_values[res_id][field]) line = { 'name': field, 'old_value': old_values[res_id][field], - 'old_value_text': old_value_text + 'old_value_text': ret_val and ret_val or old_values[res_id][field] } lines.append(line) self.create_log_line(cr, uid, log_id, model, lines) @@ -376,7 +360,6 @@ class audittrail_objects_proxy(object_proxy): res_ids = [res_ids] if res_ids: resource_data = resource_pool.read(cr, uid, res_ids) - old_text = '' for resource in resource_data: resource_id = resource['id'] del resource['id'] @@ -384,17 +367,9 @@ class audittrail_objects_proxy(object_proxy): old_value = {} for field in resource.keys(): if field in ('__last_update', 'id'):continue - field_obj = resource_pool._all_columns.get(field) - field_obj = field_obj.column - old_text = resource[field] - if field_obj._type in ('one2many','many2many'): - self.log_fct(db, uid, field_obj._obj, method, None, resource[field], 'child_relation_log') - data = pool.get(field_obj._obj).name_get(cr, uid, resource[field]) - old_text = map(lambda x:x[1], data) - elif field_obj._type == 'many2one': - old_text = resource[field] and resource[field][1] or resource[field] + ret_val = self.get_x2m_m2o_values(cr, db, uid, pool, resource_pool, method, field, resource[field]) old_value[field] = resource[field] - old_values_text[field] = old_text + old_values_text[field] = ret_val and ret_val or resource[field] old_values[resource_id] = {'text':old_values_text, 'value': old_value} if not relational_table_log: res = fct_src(db, uid_orig, model.model, method, *args) @@ -402,7 +377,6 @@ class audittrail_objects_proxy(object_proxy): if res_ids: resource_data = resource_pool.read(cr, uid, res_ids) vals = {'method': method,'object_id': model.id,'user_id': uid_orig } - old_value_text = '' for resource in resource_data: resource_id = resource['id'] del resource['id'] @@ -411,19 +385,12 @@ class audittrail_objects_proxy(object_proxy): lines = [] for field in resource.keys(): if field in ('__last_update', 'id'):continue - field_obj = resource_pool._all_columns.get(field) - field_obj = field_obj.column - old_value_text = resource[field] - if field_obj._type in ('one2many','many2many'): - data = pool.get(field_obj._obj).name_get(cr, uid, resource[field]) - old_value_text = map(lambda x:x[1], data) - elif field_obj._type == 'many2one': - old_value_text = resource[field] and resource[field][1] or resource[field] + ret_val = self.get_x2m_m2o_values(cr, db, uid, pool, resource_pool, method, field, resource[field], False) line = { 'name': field, 'new_value': resource[field], 'old_value': old_values[resource_id]['value'][field], - 'new_value_text': old_value_text, + 'new_value_text': ret_val and ret_val or resource[field], 'old_value_text': old_values[resource_id]['text'][field] } lines.append(line) From 1dce682a32d0d20092553933921056df42a8d145 Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Tue, 6 Sep 2011 17:57:35 +0530 Subject: [PATCH 013/278] [REF] bzr revid: nch@tinyerp.com-20110906122735-4ikr703mpzbiav5b --- addons/audittrail/audittrail.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index 625d4d46072..244f26fba3f 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -266,7 +266,7 @@ class audittrail_objects_proxy(object_proxy): assert model_id, _("'%s' Model does not exist..." %(model)) model = model_pool.browse(cr, uid, model_id) relational_table_log = args and args[-1] == 'child_relation_log' or False - if method in ('create'): + if method == 'create': fields_to_read = [] if relational_table_log: res_id = args[0] @@ -297,7 +297,7 @@ class audittrail_objects_proxy(object_proxy): cr.close() return res_id - elif method in ('read'): + elif method == 'read': res_ids = args[0] old_values = {} res = fct_src(db, uid_orig, model.model, method, *args) @@ -321,7 +321,7 @@ class audittrail_objects_proxy(object_proxy): cr.close() return res - elif method in ('unlink'): + elif method == 'unlink': res_ids = args[0] res = False old_values = {} From 044e4f4c1a6c3be56d8efc581bb4520f6fedf251 Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Wed, 7 Sep 2011 18:08:13 +0530 Subject: [PATCH 014/278] [IMP/REF]:allowed entires to be logged when doing different actions/workflow/on_change/write etc...and removed and refactored the code bzr revid: nch@tinyerp.com-20110907123813-4thzx4y3e9vic7uq --- addons/audittrail/audittrail.py | 231 ++++++++++++++++---------------- 1 file changed, 114 insertions(+), 117 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index 244f26fba3f..579ba005ba3 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -231,7 +231,7 @@ class audittrail_objects_proxy(object_proxy): cr.commit() return True - def get_x2m_m2o_values(self, cr, db, uid, pool, resource_pool, method, field, value, recursive=True): + def get_value_text(self, cr, db, uid, pool, resource_pool, method, field, value, recursive=True): field_obj = (resource_pool._all_columns.get(field)).column if field_obj._type in ('one2many','many2many'): if recursive: @@ -242,6 +242,27 @@ class audittrail_objects_proxy(object_proxy): return value and value[1] or value return False + def start_log_process(self, cr, db, user_id, model, method, resource_data, pool, resource_pool): + key1 = '%s_value'%(method == 'create' and 'new' or 'old') + key2 = '%s_value_text'%(method == 'create' and 'new' or 'old') + uid = 1 + vals = { 'method': method, 'object_id': model.id,'user_id': user_id} + for resource, fields in resource_data.iteritems(): + vals.update({'res_id': resource}) + log_id = pool.get('audittrail.log').create(cr, uid, vals) + lines = [] + for field_key, value in fields.iteritems(): + if field_key in ('__last_update', 'id'):continue + ret_val = self.get_value_text(cr, db, uid, pool, resource_pool, method, field_key, value, method != 'read') + line = { + 'name': field_key, + key1: value, + key2: ret_val and ret_val or value + } + lines.append(line) + self.create_log_line(cr, uid, log_id, model, lines) + return True + def log_fct(self, db, uid, model, method, fct_src, *args): """ Logging function: This function is performs logging operations according to method @@ -259,14 +280,12 @@ class audittrail_objects_proxy(object_proxy): cr = pooler.get_db(db).cursor() resource_pool = pool.get(model) log_pool = pool.get('audittrail.log') - model_pool = pool.get('ir.model') - - model_ids = model_pool.search(cr, uid, [('model', '=', model)]) - model_id = model_ids and model_ids[0] or False - assert model_id, _("'%s' Model does not exist..." %(model)) - model = model_pool.browse(cr, uid, model_id) + model = self.check_rule_subscription(cr, uid, pool, model, False) + assert model, _("'%s' Model does not exist..." %(model)) + relational_table_log = args and args[-1] == 'child_relation_log' or False if method == 'create': + resource_data = {} fields_to_read = [] if relational_table_log: res_id = args[0] @@ -274,77 +293,29 @@ class audittrail_objects_proxy(object_proxy): res_id = fct_src(db, uid_orig, model.model, method, *args) cr.commit() fields_to_read = args[0].keys() - resource = resource_pool.read(cr, uid, res_id, fields_to_read) - if not isinstance(resource, list): - resource = [resource] - vals = { 'method': method, 'object_id': model.id,'user_id': uid_orig} - for resource_data in resource: - vals.update({'res_id': resource_data['id']}) - del resource_data['id'] - log_id = log_pool.create(cr, uid, vals) - lines = [] - for field in resource_data: - if field in ('__last_update', 'id'):continue - ret_val = self.get_x2m_m2o_values(cr, db, uid, pool, resource_pool, method, field, resource_data[field]) - line = { - 'name': field, - 'new_value': resource_data[field], - 'new_value_text': ret_val and ret_val or resource_data[field] - } - lines.append(line) - self.create_log_line(cr, uid, log_id, model, lines) - cr.commit() + if res_id: + resource = resource_pool.read(cr, uid, res_id, fields_to_read) + if not isinstance(resource,list): + resource = [resource] + map(lambda x: resource_data.setdefault(x['id'], x), resource) + self.start_log_process(cr, db, uid_orig, model, method, resource_data, pool, resource_pool) + cr.commit() cr.close() return res_id - elif method == 'read': + elif method in('read', 'unlink'): res_ids = args[0] old_values = {} - res = fct_src(db, uid_orig, model.model, method, *args) - map(lambda x:old_values.setdefault(x['id'], x), res) - vals = {'method': method,'object_id': model.id,'user_id': uid_orig} - for res_id in old_values: - vals.update({'res_id': res_id}) - log_id = log_pool.create(cr, uid, vals) - lines = [] - for field in old_values[res_id]: - if field in ('__last_update', 'id'):continue - ret_val = self.get_x2m_m2o_values(cr, db, uid, pool, resource_pool, method, field, old_values[res_id][field], False) - line = { - 'name': field, - 'old_value': old_values[res_id][field], - 'old_value_text': ret_val and ret_val or old_values[res_id][field] - } - lines.append(line) - self.create_log_line(cr, uid, log_id, model, lines) - cr.commit() - cr.close() - return res - - elif method == 'unlink': - res_ids = args[0] - res = False - old_values = {} - for res_id in res_ids: - old_values[res_id] = resource_pool.read(cr, uid, res_id) - vals = {'method': method,'object_id': model.id,'user_id': uid_orig} - for res_id in res_ids: - vals.update({'res_id': res_id}) - log_id = log_pool.create(cr, uid, vals) - lines = [] - for field in old_values[res_id]: - if field in ('__last_update', 'id'):continue - ret_val = self.get_x2m_m2o_values(cr, db, uid, pool, resource_pool, method, field, old_values[res_id][field]) - line = { - 'name': field, - 'old_value': old_values[res_id][field], - 'old_value_text': ret_val and ret_val or old_values[res_id][field] - } - lines.append(line) - self.create_log_line(cr, uid, log_id, model, lines) - if not relational_table_log: + if method == 'read': res = fct_src(db, uid_orig, model.model, method, *args) - cr.commit() + map(lambda x: old_values.setdefault(x['id'], x), res) + else: + res = resource_pool.read(cr, uid, res_ids) + map(lambda x:old_values.setdefault(x['id'], x), res) + self.start_log_process(cr, db, uid_orig, model, method, old_values, pool, resource_pool) + if not relational_table_log and method == 'unlink': + res = fct_src(db, uid_orig, model.model, method, *args) + cr.commit() cr.close() return res else: @@ -359,47 +330,79 @@ class audittrail_objects_proxy(object_proxy): if isinstance(res_ids, (long, int)): res_ids = [res_ids] if res_ids: - resource_data = resource_pool.read(cr, uid, res_ids) - for resource in resource_data: - resource_id = resource['id'] - del resource['id'] - old_values_text = {} - old_value = {} - for field in resource.keys(): - if field in ('__last_update', 'id'):continue - ret_val = self.get_x2m_m2o_values(cr, db, uid, pool, resource_pool, method, field, resource[field]) - old_value[field] = resource[field] - old_values_text[field] = ret_val and ret_val or resource[field] - old_values[resource_id] = {'text':old_values_text, 'value': old_value} - if not relational_table_log: - res = fct_src(db, uid_orig, model.model, method, *args) - cr.commit() + x2m_old_values = {} + old_values = {} + def inline_process_old_data(res_ids, model, model_id=False): + resource_pool = pool.get(model) + resource_data = resource_pool.read(cr, uid, res_ids) + _old_values = {} + for resource in resource_data: + _old_values_text = {} + _old_value = {} + resource_id = resource['id'] + for field in resource.keys(): + if field in ('__last_update', 'id'):continue + field_obj = (resource_pool._all_columns.get(field)).column + if field_obj._type in ('one2many','many2many'): + x2m_rule_ids, x2m_model = self.check_rule_subscription(cr, uid, pool, field_obj._obj) + if x2m_rule_ids: + x2m_old_values.update(inline_process_old_data(resource[field], field_obj._obj, x2m_model)) + ret_val = self.get_value_text(cr, db, uid, pool, resource_pool, method, field, resource[field], False) + _old_value[field] = resource[field] + _old_values_text[field] = ret_val and ret_val or resource[field] + _old_values[resource_id] = {'text':_old_values_text, 'value': _old_value} + if model_id: + _old_values[resource_id].update({'model_id':model_id}) + return _old_values + old_values.update(inline_process_old_data(res_ids, model.model)) + res = fct_src(db, uid_orig, model.model, method, *args) + cr.commit() if res_ids: - resource_data = resource_pool.read(cr, uid, res_ids) - vals = {'method': method,'object_id': model.id,'user_id': uid_orig } - for resource in resource_data: - resource_id = resource['id'] - del resource['id'] - vals.update({'res_id': resource_id}) - log_id = log_pool.create(cr, uid, vals) - lines = [] - for field in resource.keys(): - if field in ('__last_update', 'id'):continue - ret_val = self.get_x2m_m2o_values(cr, db, uid, pool, resource_pool, method, field, resource[field], False) - line = { - 'name': field, - 'new_value': resource[field], - 'old_value': old_values[resource_id]['value'][field], - 'new_value_text': ret_val and ret_val or resource[field], - 'old_value_text': old_values[resource_id]['text'][field] - } - lines.append(line) - self.create_log_line(cr, uid, log_id, model, lines) + def inline_process_new_data(res_ids, model, dict_to_use={}): + resource_pool = pool.get(model.model) + resource_data = resource_pool.read(cr, uid, res_ids) + vals = {'method': method,'object_id': model.id,'user_id': uid_orig } + for resource in resource_data: + resource_id = resource['id'] + vals.update({'res_id': resource_id}) + log_id = log_pool.create(cr, uid, vals) + lines = [] + for field in resource.keys(): + if field in ('__last_update', 'id'):continue + field_obj = (resource_pool._all_columns.get(field)).column + if field_obj._type in ('one2many','many2many'): + x2m_rule_ids, x2m_model = self.check_rule_subscription(cr, uid, pool, field_obj._obj) + if x2m_rule_ids: + inline_process_new_data(resource[field], x2m_model, x2m_old_values) + ret_val = self.get_value_text(cr, db, uid, pool, resource_pool, method, field, resource[field], False) + line = { + 'name': field, + 'new_value': resource[field], + 'old_value': resource_id in dict_to_use and dict_to_use[resource_id]['value'].get(field), + 'new_value_text': ret_val and ret_val or resource[field], + 'old_value_text': resource_id in dict_to_use and dict_to_use[resource_id]['text'].get(field) + } + lines.append(line) + self.create_log_line(cr, uid, log_id, model, lines) + return True + inline_process_new_data(res_ids, model, old_values) cr.commit() cr.close() return res return True - + + def check_rule_subscription(self, cr, uid, pool, model, rule_check=True): + ''' + Test if the model has been subscribed to the audit rule + if yes then return the rule_ids also return the model browse_record object. + ''' + model_ids = pool.get('ir.model').search(cr, uid, [('model', '=', model)]) + model_obj = model_ids and model_ids[0] and pool.get('ir.model').browse(cr, uid, model_ids[0]) or False + if rule_check: + rule_ids = pool.get('audittrail.rule').search(cr, uid, [('object_id', '=', model_obj.id), ('state', '=', 'subscribed')]) + return rule_ids, model_obj + return model_obj + def audit_log_call(self, db, uid, model, method, action_type, *args, **argv): """ Overrides Object Proxy execute method @@ -414,8 +417,6 @@ class audittrail_objects_proxy(object_proxy): uid = 1 pool = pooler.get_pool(db) logged_uids = [] - model_pool = pool.get('ir.model') - rule_pool = pool.get('audittrail.rule') cr = pooler.get_db(db).cursor() cr.autocommit(True) if action_type == 'execute': @@ -426,14 +427,10 @@ class audittrail_objects_proxy(object_proxy): else: fct_src = super(audittrail_objects_proxy, self).exec_workflow try: - model_ids = model_pool.search(cr, uid, [('model', '=', model)]) - model_id = model_ids and model_ids[0] or False - if not ('audittrail.rule' in pool.obj_list()) or not model_id: + rule_ids, model_obj = self.check_rule_subscription(cr, uid, pool, model) + if not ('audittrail.rule' in pool.obj_list() and model_obj and rule_ids): return fct_src(db, uid_orig, model, method, *args, **argv) - rule_ids = rule_pool.search(cr, uid, [('object_id', '=', model_id), ('state', '=', 'subscribed')]) - if not rule_ids: - return fct_src(db, uid_orig, model, method, *args, **argv) - for model_rule in rule_pool.browse(cr, uid, rule_ids): + for model_rule in pool.get('audittrail.rule').browse(cr, uid, rule_ids): logged_uids += map(lambda x:x.id, model_rule.user_id) if not logged_uids or uid in logged_uids: if action_type == 'execute': From baf3c74fc43a3ff47ff68684ce36969a1eb0bce5 Mon Sep 17 00:00:00 2001 From: eLBati Date: Sat, 17 Sep 2011 09:29:30 +0200 Subject: [PATCH 015/278] [FIX] new ordinary VAT 21% http://www.ilsole24ore.com/art/norme-e-tributi/2011-09-15/domani-aumenta-224724.shtml bzr revid: lorenzo.battistini@agilebg.com-20110917072930-i6rnvkjgw4lffgla --- .../data/account.tax.code.template.csv | 4 + addons/l10n_it/data/account.tax.template.csv | 74 ++++++++++--------- 2 files changed, 42 insertions(+), 36 deletions(-) diff --git a/addons/l10n_it/data/account.tax.code.template.csv b/addons/l10n_it/data/account.tax.code.template.csv index 288f169f4ab..01699380f81 100644 --- a/addons/l10n_it/data/account.tax.code.template.csv +++ b/addons/l10n_it/data/account.tax.code.template.csv @@ -26,6 +26,8 @@ "IVC4Idet50","template_impcode_pagata_4det50","IVA a credito 4% detraibile 50% (imponibile)","template_impcode_pagata" "IVC20","template_ivacode_pagata_20","IVA a credito 20%","template_ivacode_pagata" "IVC20I","template_impcode_pagata_20","IVA a credito 20% (imponibile)","template_impcode_pagata" +"IVC21","template_ivacode_pagata_21","IVA a credito 21%","template_ivacode_pagata" +"IVC21I","template_impcode_pagata_21","IVA a credito 21% (imponibile)","template_impcode_pagata" "IVC4","template_ivacode_pagata_4","IVA a credito 4%","template_ivacode_pagata" "IVC4I","template_impcode_pagata_4","IVA a credito 4% (imponibile)","template_impcode_pagata" "IVC12","template_ivacode_pagata_12","IVA a credito 12%","template_ivacode_pagata" @@ -40,6 +42,8 @@ "IVD10I","template_impcode_riscossa_10","IVA a debito 10% (imponibile)","template_impcode_riscossa" "IVD20","template_ivacode_riscossa_20","IVA a debito 20%","template_ivacode_riscossa" "IVD20I","template_impcode_riscossa_20","IVA a debito 20% (imponibile)","template_impcode_riscossa" +"IVD21","template_ivacode_riscossa_21","IVA a debito 21%","template_ivacode_riscossa" +"IVD21I","template_impcode_riscossa_21","IVA a debito 21% (imponibile)","template_impcode_riscossa" "IVD4","template_ivacode_riscossa_4","IVA a debito 4%","template_ivacode_riscossa" "IVD4I","template_impcode_riscossa_4","IVA a debito 4% (imponibile)","template_impcode_riscossa" "IVD12","template_ivacode_riscossa_12","IVA a debito 12%","template_ivacode_riscossa" diff --git a/addons/l10n_it/data/account.tax.template.csv b/addons/l10n_it/data/account.tax.template.csv index 5be051ed009..08a4d770b31 100644 --- a/addons/l10n_it/data/account.tax.template.csv +++ b/addons/l10n_it/data/account.tax.template.csv @@ -1,46 +1,48 @@ "id","description","chart_template_id:id","name","sequence","amount","parent_id:id","child_depend","type","account_collected_id:id","account_paid_id:id","type_tax_use","base_code_id:id","tax_code_id:id","ref_base_code_id:id","ref_tax_code_id:id","ref_base_sign","ref_tax_sign","price_include" -"20a","20a","l10n_it_chart_template_generic","Iva al 20% (debito)",,"0.2",,"False","percent","2601","2601","sale","template_impcode_riscossa_20","template_ivacode_riscossa_20","template_impcode_riscossa_20","template_ivacode_riscossa_20",-1,-1,"False" -"20b","20b","l10n_it_chart_template_generic","Iva al 20% (credito)",,"0.2",,"False","percent","1601","1601","purchase","template_impcode_pagata_20","template_ivacode_pagata_20","template_impcode_pagata_20","template_ivacode_pagata_20",-1,-1,"False" -"10a","10a","l10n_it_chart_template_generic","Iva al 10% (debito)",,"0.1",,"False","percent","2601","2601","sale","template_impcode_riscossa_10","template_ivacode_riscossa_10","template_impcode_riscossa_10","template_ivacode_riscossa_10",-1,-1,"False" -"10b","10b","l10n_it_chart_template_generic","Iva al 10% (credito)",,"0.1",,"False","percent","1601","1601","purchase","template_impcode_pagata_10","template_ivacode_pagata_10","template_impcode_pagata_10","template_ivacode_pagata_10",-1,-1,"False" -"10AO","10AO","l10n_it_chart_template_generic","Iva al 10% indetraibile",,"0.1",,"True","percent",,,"purchase","template_impcode_pagata_10ind",,"template_impcode_pagata_10ind",,-1,,"False" -"10AOa","10AOa","l10n_it_chart_template_generic","Iva al 10% indetraibile (D)","2","0","10AO","False","balance","1601","1601","purchase",,"template_ivacode_pagata_10ind",,"template_ivacode_pagata_10ind",,-1,"False" +"21a","21a","l10n_it_chart_template_generic","Iva al 21% (debito)",,"0.21",,"False","percent","2601","2601","sale","template_impcode_riscossa_21","template_ivacode_riscossa_21","template_impcode_riscossa_21","template_ivacode_riscossa_21","-1","-1","False" +"21b","21b","l10n_it_chart_template_generic","Iva al 21% (credito)",,"0.21",,"False","percent","1601","1601","purchase","template_impcode_pagata_21","template_ivacode_pagata_21","template_impcode_pagata_21","template_ivacode_pagata_21","-1","-1","False" +"20a","20a","l10n_it_chart_template_generic","Iva al 20% (debito)",,"0.2",,"False","percent","2601","2601","sale","template_impcode_riscossa_20","template_ivacode_riscossa_20","template_impcode_riscossa_20","template_ivacode_riscossa_20","-1","-1","False" +"20b","20b","l10n_it_chart_template_generic","Iva al 20% (credito)",,"0.2",,"False","percent","1601","1601","purchase","template_impcode_pagata_20","template_ivacode_pagata_20","template_impcode_pagata_20","template_ivacode_pagata_20","-1","-1","False" +"10a","10a","l10n_it_chart_template_generic","Iva al 10% (debito)",,"0.1",,"False","percent","2601","2601","sale","template_impcode_riscossa_10","template_ivacode_riscossa_10","template_impcode_riscossa_10","template_ivacode_riscossa_10","-1","-1","False" +"10b","10b","l10n_it_chart_template_generic","Iva al 10% (credito)",,"0.1",,"False","percent","1601","1601","purchase","template_impcode_pagata_10","template_ivacode_pagata_10","template_impcode_pagata_10","template_ivacode_pagata_10","-1","-1","False" +"10AO","10AO","l10n_it_chart_template_generic","Iva al 10% indetraibile",,"0.1",,"True","percent",,,"purchase","template_impcode_pagata_10ind",,"template_impcode_pagata_10ind",,"-1",,"False" +"10AOa","10AOa","l10n_it_chart_template_generic","Iva al 10% indetraibile (D)","2","0","10AO","False","balance","1601","1601","purchase",,"template_ivacode_pagata_10ind",,"template_ivacode_pagata_10ind",,"-1","False" "10AOb","10AOb","l10n_it_chart_template_generic","Iva al 10% indetraibile (I)","1","1","10AO","False","percent",,,"purchase",,,,,,,"False" -"12a","12a","l10n_it_chart_template_generic","Iva 12% (debito)",,"0.12",,"False","percent","2601","2601","sale","template_impcode_riscossa_12","template_ivacode_riscossa_12","template_impcode_riscossa_12","template_ivacode_riscossa_12",-1,-1,"False" -"12b","12b","l10n_it_chart_template_generic","Iva 12% (credito)",,"0.12",,"False","percent","1601","1601","purchase","template_impcode_pagata_12","template_ivacode_pagata_12","template_impcode_pagata_12","template_ivacode_pagata_12",-1,-1,"False" -"2010","2010","l10n_it_chart_template_generic","Iva al 20% detraibile 10%",,"0.2",,"True","percent",,,"purchase","template_impcode_pagata_20det10",,"template_impcode_pagata_20det10",,-1,,"False" -"2010a","2010a","l10n_it_chart_template_generic","Iva al 20% detraibile 10% (D)","2","0","2010","False","balance","1601","1601","purchase",,"template_ivacode_pagata_20det10",,"template_ivacode_pagata_20det10",,-1,"False" +"12a","12a","l10n_it_chart_template_generic","Iva 12% (debito)",,"0.12",,"False","percent","2601","2601","sale","template_impcode_riscossa_12","template_ivacode_riscossa_12","template_impcode_riscossa_12","template_ivacode_riscossa_12","-1","-1","False" +"12b","12b","l10n_it_chart_template_generic","Iva 12% (credito)",,"0.12",,"False","percent","1601","1601","purchase","template_impcode_pagata_12","template_ivacode_pagata_12","template_impcode_pagata_12","template_ivacode_pagata_12","-1","-1","False" +"2010","2010","l10n_it_chart_template_generic","Iva al 20% detraibile 10%",,"0.2",,"True","percent",,,"purchase","template_impcode_pagata_20det10",,"template_impcode_pagata_20det10",,"-1",,"False" +"2010a","2010a","l10n_it_chart_template_generic","Iva al 20% detraibile 10% (D)","2","0","2010","False","balance","1601","1601","purchase",,"template_ivacode_pagata_20det10",,"template_ivacode_pagata_20det10",,"-1","False" "2010b","2010b","l10n_it_chart_template_generic","Iva al 20% detraibile 10% (I)","1","0.9","2010","False","percent",,,"purchase",,,,,,,"False" -"2015","2015","l10n_it_chart_template_generic","Iva al 20% detraibile 15%",,"0.2",,"True","percent",,,"purchase","template_impcode_pagata_20det15",,"template_impcode_pagata_20det15",,-1,,"False" -"2015a","2015a","l10n_it_chart_template_generic","Iva al 20% detraibile 15% (D)","2","0","2015","False","balance","1601","1601","purchase",,"template_ivacode_pagata_20det15",,"template_ivacode_pagata_20det15",,-1,"False" +"2015","2015","l10n_it_chart_template_generic","Iva al 20% detraibile 15%",,"0.2",,"True","percent",,,"purchase","template_impcode_pagata_20det15",,"template_impcode_pagata_20det15",,"-1",,"False" +"2015a","2015a","l10n_it_chart_template_generic","Iva al 20% detraibile 15% (D)","2","0","2015","False","balance","1601","1601","purchase",,"template_ivacode_pagata_20det15",,"template_ivacode_pagata_20det15",,"-1","False" "2015b","2015b","l10n_it_chart_template_generic","Iva al 20% detraibile 15% (I)","1","0.85","2015","False","percent",,,"purchase",,,,,,,"False" -"2040","2040","l10n_it_chart_template_generic","Iva al 20% detraibile 40%",,"0.2",,"True","percent",,,"purchase","template_impcode_pagata_20det40",,"template_impcode_pagata_20det40",,-1,,"False" -"2040a","2040a","l10n_it_chart_template_generic","Iva al 20% detraibile 40% (D)","2","0","2040","False","balance","1601","1601","purchase",,"template_ivacode_pagata_20det40",,"template_ivacode_pagata_20det40",,-1,"False" +"2040","2040","l10n_it_chart_template_generic","Iva al 20% detraibile 40%",,"0.2",,"True","percent",,,"purchase","template_impcode_pagata_20det40",,"template_impcode_pagata_20det40",,"-1",,"False" +"2040a","2040a","l10n_it_chart_template_generic","Iva al 20% detraibile 40% (D)","2","0","2040","False","balance","1601","1601","purchase",,"template_ivacode_pagata_20det40",,"template_ivacode_pagata_20det40",,"-1","False" "2040b","2040b","l10n_it_chart_template_generic","Iva al 20% detraibile 40% (I)","1","0.6","2040","False","percent",,,"purchase",,,,,,,"False" -"20AO","20AO","l10n_it_chart_template_generic","Iva al 20% indetraibile",,"0.2",,"True","percent",,,"purchase","template_impcode_pagata_20ind",,"template_impcode_pagata_20ind",,-1,,"False" -"20AOa","20AOa","l10n_it_chart_template_generic","Iva al 20% indetraibile (D)","2","0","20AO","False","balance","1601","1601","purchase",,"template_ivacode_pagata_20ind",,"template_ivacode_pagata_20ind",,-1,"False" +"20AO","20AO","l10n_it_chart_template_generic","Iva al 20% indetraibile",,"0.2",,"True","percent",,,"purchase","template_impcode_pagata_20ind",,"template_impcode_pagata_20ind",,"-1",,"False" +"20AOa","20AOa","l10n_it_chart_template_generic","Iva al 20% indetraibile (D)","2","0","20AO","False","balance","1601","1601","purchase",,"template_ivacode_pagata_20ind",,"template_ivacode_pagata_20ind",,"-1","False" "20AOb","20AOb","l10n_it_chart_template_generic","Iva al 20% indetraibile (I)","1","1","20AO","False","percent",,,"purchase",,,,,,,"False" -"20I5","20I5","l10n_it_chart_template_generic","IVA al 20% detraibile al 50%",,"0.2",,"True","percent",,,"purchase","template_impcode_pagata_20det50",,"template_impcode_pagata_20det50",,-1,,"False" +"20I5","20I5","l10n_it_chart_template_generic","IVA al 20% detraibile al 50%",,"0.2",,"True","percent",,,"purchase","template_impcode_pagata_20det50",,"template_impcode_pagata_20det50",,"-1",,"False" "20I5b","20I5b","l10n_it_chart_template_generic","IVA al 20% detraibile al 50% (I)","1","0.5","20I5","False","percent",,,"purchase",,,,,,,"False" -"20I5a","20I5a","l10n_it_chart_template_generic","IVA al 20% detraibile al 50% (D)","2","0","20I5","False","balance","1601","1601","purchase",,"template_ivacode_pagata_20det50",,"template_ivacode_pagata_20det50",,-1,"False" -"22a","22a","l10n_it_chart_template_generic","Iva 2% (debito)",,"0.02",,"False","percent","2601","2601","sale","template_impcode_riscossa_2","template_ivacode_riscossa_2","template_impcode_riscossa_2","template_ivacode_riscossa_2",-1,-1,"False" -"22b","22b","l10n_it_chart_template_generic","Iva 2% (credito)",,"0.02",,"False","percent","1601","1601","purchase","template_impcode_pagata_2","template_ivacode_pagata_2","template_impcode_pagata_2","template_ivacode_pagata_2",-1,-1,"False" -"4a","4a","l10n_it_chart_template_generic","Iva 4% (debito)",,"0.04",,"False","percent","2601","2601","sale","template_impcode_riscossa_4","template_ivacode_riscossa_4","template_impcode_riscossa_4","template_ivacode_riscossa_4",-1,-1,"False" -"4b","4b","l10n_it_chart_template_generic","Iva 4% (credito)",,"0.04",,"False","percent","1601","1601","purchase","template_impcode_pagata_4","template_ivacode_pagata_4","template_impcode_pagata_4","template_ivacode_pagata_4",-1,-1,"False" -"4AO","4AO","l10n_it_chart_template_generic","Iva al 4% indetraibile",,"0.04",,"True","percent",,,"purchase","template_impcode_pagata_4ind",,"template_impcode_pagata_4ind",,-1,,"False" -"4AOa","4AOa","l10n_it_chart_template_generic","Iva al 4% indetraibile (D)","2","0","4AO","False","balance","1601","1601","purchase",,"template_ivacode_pagata_4ind",,"template_ivacode_pagata_4ind",,-1,"False" +"20I5a","20I5a","l10n_it_chart_template_generic","IVA al 20% detraibile al 50% (D)","2","0","20I5","False","balance","1601","1601","purchase",,"template_ivacode_pagata_20det50",,"template_ivacode_pagata_20det50",,"-1","False" +"22a","22a","l10n_it_chart_template_generic","Iva 2% (debito)",,"0.02",,"False","percent","2601","2601","sale","template_impcode_riscossa_2","template_ivacode_riscossa_2","template_impcode_riscossa_2","template_ivacode_riscossa_2","-1","-1","False" +"22b","22b","l10n_it_chart_template_generic","Iva 2% (credito)",,"0.02",,"False","percent","1601","1601","purchase","template_impcode_pagata_2","template_ivacode_pagata_2","template_impcode_pagata_2","template_ivacode_pagata_2","-1","-1","False" +"4a","4a","l10n_it_chart_template_generic","Iva 4% (debito)",,"0.04",,"False","percent","2601","2601","sale","template_impcode_riscossa_4","template_ivacode_riscossa_4","template_impcode_riscossa_4","template_ivacode_riscossa_4","-1","-1","False" +"4b","4b","l10n_it_chart_template_generic","Iva 4% (credito)",,"0.04",,"False","percent","1601","1601","purchase","template_impcode_pagata_4","template_ivacode_pagata_4","template_impcode_pagata_4","template_ivacode_pagata_4","-1","-1","False" +"4AO","4AO","l10n_it_chart_template_generic","Iva al 4% indetraibile",,"0.04",,"True","percent",,,"purchase","template_impcode_pagata_4ind",,"template_impcode_pagata_4ind",,"-1",,"False" +"4AOa","4AOa","l10n_it_chart_template_generic","Iva al 4% indetraibile (D)","2","0","4AO","False","balance","1601","1601","purchase",,"template_ivacode_pagata_4ind",,"template_ivacode_pagata_4ind",,"-1","False" "4AOb","4AOb","l10n_it_chart_template_generic","Iva al 4% indetraibile (I)","1","1","4AO","False","percent",,,"purchase",,,,,,,"False" -"10I5","10I5","l10n_it_chart_template_generic","IVA al 10% detraibile al 50%",,"0.1",,"True","percent",,,"purchase","template_impcode_pagata_10det50",,"template_impcode_pagata_10det50",,-1,,"False" -"10I5a","10I5a","l10n_it_chart_template_generic","IVA al 10% detraibile al 50% (D)","2","0","10I5","False","balance","1601","1601","purchase",,"template_ivacode_pagata_10det50",,"template_ivacode_pagata_10det50",,-1,"False" +"10I5","10I5","l10n_it_chart_template_generic","IVA al 10% detraibile al 50%",,"0.1",,"True","percent",,,"purchase","template_impcode_pagata_10det50",,"template_impcode_pagata_10det50",,"-1",,"False" +"10I5a","10I5a","l10n_it_chart_template_generic","IVA al 10% detraibile al 50% (D)","2","0","10I5","False","balance","1601","1601","purchase",,"template_ivacode_pagata_10det50",,"template_ivacode_pagata_10det50",,"-1","False" "10I5b","10I5b","l10n_it_chart_template_generic","IVA al 10% detraibile al 50% (I)","1","0.5","10I5","False","percent",,,"purchase",,,,,,,"False" -"4I5","4I5","l10n_it_chart_template_generic","IVA al 4% detraibile al 50%",,"0.04",,"True","percent",,,"purchase","template_impcode_pagata_4det50",,"template_impcode_pagata_4det50",,-1,,"False" -"4I5a","4I5a","l10n_it_chart_template_generic","IVA al 4% detraibile al 50% (D)","2","0","4I5","False","balance","1601","1601","purchase",,"template_ivacode_pagata_4det50",,"template_ivacode_pagata_4det50",,-1,"False" +"4I5","4I5","l10n_it_chart_template_generic","IVA al 4% detraibile al 50%",,"0.04",,"True","percent",,,"purchase","template_impcode_pagata_4det50",,"template_impcode_pagata_4det50",,"-1",,"False" +"4I5a","4I5a","l10n_it_chart_template_generic","IVA al 4% detraibile al 50% (D)","2","0","4I5","False","balance","1601","1601","purchase",,"template_ivacode_pagata_4det50",,"template_ivacode_pagata_4det50",,"-1","False" "4I5b","4I5b","l10n_it_chart_template_generic","IVA al 4% detraibile al 50% (I)","1","0.5","4I5","False","percent",,,"purchase",,,,,,,"False" -"00a","00a","l10n_it_chart_template_generic","Esente IVA (debito)",,"0",,"False","percent","2601","2601","sale","template_impcode_riscossa_0","template_ivacode_riscossa_0","template_impcode_riscossa_0","template_ivacode_riscossa_0",-1,-1,"False" -"00b","00b","l10n_it_chart_template_generic","Esente IVA (credito)",,"0",,"False","percent","1601","1601","purchase","template_impcode_pagata_0","template_ivacode_pagata_0","template_impcode_pagata_0","template_ivacode_pagata_0",-1,-1,"False" -"20a INC","20a INC","l10n_it_chart_template_generic","Iva al 20% (debito) INC",,"0.2",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_20","l10n_it.template_ivacode_riscossa_20","l10n_it.template_impcode_riscossa_20","l10n_it.template_ivacode_riscossa_20",-1,-1,"True" -"10a INC","10a INC","l10n_it_chart_template_generic","Iva al 10% (debito) INC",,"0.1",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_10","l10n_it.template_ivacode_riscossa_10","l10n_it.template_impcode_riscossa_10","l10n_it.template_ivacode_riscossa_10",-1,-1,"True" -"12a INC","12a INC","l10n_it_chart_template_generic","Iva 12% (debito) INC",,"0.12",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_12","l10n_it.template_ivacode_riscossa_12","l10n_it.template_impcode_riscossa_12","l10n_it.template_ivacode_riscossa_12",-1,-1,"True" -"22a INC","22a INC","l10n_it_chart_template_generic","Iva 2% (debito) INC",,"0.02",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_2","l10n_it.template_ivacode_riscossa_2","l10n_it.template_impcode_riscossa_2","l10n_it.template_ivacode_riscossa_2",-1,-1,"True" -"4a INC","4a INC","l10n_it_chart_template_generic","Iva 4% (debito) INC",,"0.04",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_4","l10n_it.template_ivacode_riscossa_4","l10n_it.template_impcode_riscossa_4","l10n_it.template_ivacode_riscossa_4",-1,-1,"True" -"00a INC","00a INC","l10n_it_chart_template_generic","Esente IVA (debito) INC",,"0",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_0","l10n_it.template_ivacode_riscossa_0","l10n_it.template_impcode_riscossa_0","l10n_it.template_ivacode_riscossa_0",-1,-1,"True" +"00a","00a","l10n_it_chart_template_generic","Esente IVA (debito)",,"0",,"False","percent","2601","2601","sale","template_impcode_riscossa_0","template_ivacode_riscossa_0","template_impcode_riscossa_0","template_ivacode_riscossa_0","-1","-1","False" +"00b","00b","l10n_it_chart_template_generic","Esente IVA (credito)",,"0",,"False","percent","1601","1601","purchase","template_impcode_pagata_0","template_ivacode_pagata_0","template_impcode_pagata_0","template_ivacode_pagata_0","-1","-1","False" +"20a INC","20a INC","l10n_it_chart_template_generic","Iva al 20% (debito) INC",,"0.2",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_20","l10n_it.template_ivacode_riscossa_20","l10n_it.template_impcode_riscossa_20","l10n_it.template_ivacode_riscossa_20","-1","-1","True" +"10a INC","10a INC","l10n_it_chart_template_generic","Iva al 10% (debito) INC",,"0.1",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_10","l10n_it.template_ivacode_riscossa_10","l10n_it.template_impcode_riscossa_10","l10n_it.template_ivacode_riscossa_10","-1","-1","True" +"12a INC","12a INC","l10n_it_chart_template_generic","Iva 12% (debito) INC",,"0.12",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_12","l10n_it.template_ivacode_riscossa_12","l10n_it.template_impcode_riscossa_12","l10n_it.template_ivacode_riscossa_12","-1","-1","True" +"22a INC","22a INC","l10n_it_chart_template_generic","Iva 2% (debito) INC",,"0.02",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_2","l10n_it.template_ivacode_riscossa_2","l10n_it.template_impcode_riscossa_2","l10n_it.template_ivacode_riscossa_2","-1","-1","True" +"4a INC","4a INC","l10n_it_chart_template_generic","Iva 4% (debito) INC",,"0.04",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_4","l10n_it.template_ivacode_riscossa_4","l10n_it.template_impcode_riscossa_4","l10n_it.template_ivacode_riscossa_4","-1","-1","True" +"00a INC","00a INC","l10n_it_chart_template_generic","Esente IVA (debito) INC",,"0",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_0","l10n_it.template_ivacode_riscossa_0","l10n_it.template_impcode_riscossa_0","l10n_it.template_ivacode_riscossa_0","-1","-1","True" From 7f44b2a49930e3594232f39f9f9b7e03a8b5fff6 Mon Sep 17 00:00:00 2001 From: eLBati Date: Sun, 18 Sep 2011 17:19:26 +0200 Subject: [PATCH 016/278] [ADD] VAT 21% included bzr revid: lorenzo.battistini@agilebg.com-20110918151926-ux171fc0zixkbz1k --- addons/l10n_it/data/account.tax.template.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/l10n_it/data/account.tax.template.csv b/addons/l10n_it/data/account.tax.template.csv index 08a4d770b31..c0ce348693c 100644 --- a/addons/l10n_it/data/account.tax.template.csv +++ b/addons/l10n_it/data/account.tax.template.csv @@ -40,6 +40,7 @@ "4I5b","4I5b","l10n_it_chart_template_generic","IVA al 4% detraibile al 50% (I)","1","0.5","4I5","False","percent",,,"purchase",,,,,,,"False" "00a","00a","l10n_it_chart_template_generic","Esente IVA (debito)",,"0",,"False","percent","2601","2601","sale","template_impcode_riscossa_0","template_ivacode_riscossa_0","template_impcode_riscossa_0","template_ivacode_riscossa_0","-1","-1","False" "00b","00b","l10n_it_chart_template_generic","Esente IVA (credito)",,"0",,"False","percent","1601","1601","purchase","template_impcode_pagata_0","template_ivacode_pagata_0","template_impcode_pagata_0","template_ivacode_pagata_0","-1","-1","False" +"21a INC","21a INC","l10n_it_chart_template_generic","Iva al 21% (debito) INC",,"0.21",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_21","l10n_it.template_ivacode_riscossa_21","l10n_it.template_impcode_riscossa_21","l10n_it.template_ivacode_riscossa_21","-1","-1","True" "20a INC","20a INC","l10n_it_chart_template_generic","Iva al 20% (debito) INC",,"0.2",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_20","l10n_it.template_ivacode_riscossa_20","l10n_it.template_impcode_riscossa_20","l10n_it.template_ivacode_riscossa_20","-1","-1","True" "10a INC","10a INC","l10n_it_chart_template_generic","Iva al 10% (debito) INC",,"0.1",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_10","l10n_it.template_ivacode_riscossa_10","l10n_it.template_impcode_riscossa_10","l10n_it.template_ivacode_riscossa_10","-1","-1","True" "12a INC","12a INC","l10n_it_chart_template_generic","Iva 12% (debito) INC",,"0.12",,"False","percent","l10n_it.2601","l10n_it.2601","sale","l10n_it.template_impcode_riscossa_12","l10n_it.template_ivacode_riscossa_12","l10n_it.template_impcode_riscossa_12","l10n_it.template_ivacode_riscossa_12","-1","-1","True" From 966ed38ba4651be633d525475c4cb0d0da389953 Mon Sep 17 00:00:00 2001 From: eLBati Date: Fri, 23 Sep 2011 18:32:09 +0200 Subject: [PATCH 017/278] [FIX] various account types bzr revid: lorenzo.battistini@agilebg.com-20110923163209-73xwtba0n62d8o15 --- .../l10n_it/data/account.account.template.csv | 176 +++++++++--------- addons/l10n_it/data/account.account.type.csv | 9 +- 2 files changed, 92 insertions(+), 93 deletions(-) diff --git a/addons/l10n_it/data/account.account.template.csv b/addons/l10n_it/data/account.account.template.csv index d31d42180d0..a838a76e892 100644 --- a/addons/l10n_it/data/account.account.template.csv +++ b/addons/l10n_it/data/account.account.template.csv @@ -2,34 +2,34 @@ "0","0","Azienda",,"account_type_view","view","FALSE" "1","1","ATTIVO ","0","account_type_view","view","TRUE" "11","11","IMMOBILIZZAZIONI IMMATERIALI ","1","account_type_view","view","TRUE" -"1101","1101","costi di impianto ","11","account_type_view","other","TRUE" -"1106","1106","software ","11","account_type_view","other","TRUE" -"1108","1108","avviamento ","11","account_type_view","other","TRUE" -"1111","1111","fondo ammortamento costi di impianto ","11","account_type_view","other","TRUE" -"1116","1116","fondo ammortamento software ","11","account_type_view","other","TRUE" -"1118","1118","fondo ammortamento avviamento ","11","account_type_view","other","TRUE" +"1101","1101","costi di impianto ","11","account_type_asset","other","TRUE" +"1106","1106","software ","11","account_type_asset","other","TRUE" +"1108","1108","avviamento ","11","account_type_asset","other","TRUE" +"1111","1111","fondo ammortamento costi di impianto ","11","account_type_asset","other","TRUE" +"1116","1116","fondo ammortamento software ","11","account_type_asset","other","TRUE" +"1118","1118","fondo ammortamento avviamento ","11","account_type_asset","other","TRUE" "12","12","IMMOBILIZZAZIONI MATERIALI ","1","account_type_view","view","TRUE" -"1201","1201","fabbricati ","12","account_type_view","other","TRUE" -"1202","1202","impianti e macchinari ","12","account_type_view","other","TRUE" -"1204","1204","attrezzature commerciali ","12","account_type_view","other","TRUE" -"1205","1205","macchine d'ufficio ","12","account_type_view","other","TRUE" -"1206","1206","arredamento ","12","account_type_view","other","TRUE" -"1207","1207","automezzi ","12","account_type_view","other","TRUE" -"1208","1208","imballaggi durevoli ","12","account_type_view","other","TRUE" -"1211","1211","fondo ammortamento fabbricati ","12","account_type_view","other","TRUE" -"1212","1212","fondo ammortamento impianti e macchinari ","12","account_type_view","other","TRUE" -"1214","1214","fondo ammortamento attrezzature commerciali ","12","account_type_view","other","TRUE" -"1215","1215","fondo ammortamento macchine d'ufficio ","12","account_type_view","other","TRUE" -"1216","1216","fondo ammortamento arredamento ","12","account_type_view","other","TRUE" -"1217","1217","fondo ammortamento automezzi ","12","account_type_view","other","TRUE" -"1218","1218","fondo ammortamento imballaggi durevoli ","12","account_type_view","other","TRUE" -"1220","1220","fornitori immobilizzazioni c/acconti ","12","account_type_view","other","TRUE" +"1201","1201","fabbricati ","12","account_type_asset","other","TRUE" +"1202","1202","impianti e macchinari ","12","account_type_asset","other","TRUE" +"1204","1204","attrezzature commerciali ","12","account_type_asset","other","TRUE" +"1205","1205","macchine d'ufficio ","12","account_type_asset","other","TRUE" +"1206","1206","arredamento ","12","account_type_asset","other","TRUE" +"1207","1207","automezzi ","12","account_type_asset","other","TRUE" +"1208","1208","imballaggi durevoli ","12","account_type_asset","other","TRUE" +"1211","1211","fondo ammortamento fabbricati ","12","account_type_asset","other","TRUE" +"1212","1212","fondo ammortamento impianti e macchinari ","12","account_type_asset","other","TRUE" +"1214","1214","fondo ammortamento attrezzature commerciali ","12","account_type_asset","other","TRUE" +"1215","1215","fondo ammortamento macchine d'ufficio ","12","account_type_asset","other","TRUE" +"1216","1216","fondo ammortamento arredamento ","12","account_type_asset","other","TRUE" +"1217","1217","fondo ammortamento automezzi ","12","account_type_asset","other","TRUE" +"1218","1218","fondo ammortamento imballaggi durevoli ","12","account_type_asset","other","TRUE" +"1220","1220","fornitori immobilizzazioni c/acconti ","12","account_type_asset","other","TRUE" "13","13","IMMOBILIZZAZIONI FINANZIARIE ","1","account_type_view","view","TRUE" -"1301","1301","mutui attivi ","13","account_type_view","other","TRUE" +"1301","1301","mutui attivi ","13","account_type_asset","other","TRUE" "14","14","RIMANENZE ","1","account_type_view","view","TRUE" -"1401","1401","materie di consumo ","14","account_type_view","other","TRUE" -"1404","1404","merci ","14","account_type_view","other","TRUE" -"1410","1410","fornitori c/acconti ","14","account_type_view","other","TRUE" +"1401","1401","materie di consumo ","14","account_type_asset","other","TRUE" +"1404","1404","merci ","14","account_type_asset","other","TRUE" +"1410","1410","fornitori c/acconti ","14","account_type_asset","other","TRUE" "15","15","CREDITI COMMERCIALI ","1","account_type_view","view","TRUE" "1501","1501","crediti v/clienti ","15","account_type_receivable","receivable","TRUE" "1502","1502","crediti commerciali diversi ","15","account_type_receivable","other","TRUE" @@ -44,15 +44,15 @@ "1540","1540","fondo svalutazione crediti ","15","account_type_receivable","other","TRUE" "1541","1541","fondo rischi su crediti ","15","account_type_receivable","other","TRUE" "16","16","CREDITI DIVERSI ","1","account_type_view","view","TRUE" -"1601","1601","IVA n/credito ","16","account_type_receivable","other","TRUE" -"1602","1602","IVA c/acconto ","16","account_type_receivable","other","TRUE" -"1605","1605","crediti per IVA ","16","account_type_receivable","other","TRUE" -"1607","1607","imposte c/acconto ","16","account_type_receivable","other","TRUE" -"1608","1608","crediti per imposte ","16","account_type_receivable","other","TRUE" -"1609","1609","crediti per ritenute subite ","16","account_type_receivable","other","TRUE" -"1610","1610","crediti per cauzioni ","16","account_type_receivable","other","TRUE" -"1620","1620","personale c/acconti ","16","account_type_receivable","other","TRUE" -"1630","1630","crediti v/istituti previdenziali ","16","account_type_receivable","other","TRUE" +"1601","1601","IVA n/credito ","16","account_type_tax","other","TRUE" +"1602","1602","IVA c/acconto ","16","account_type_tax","other","TRUE" +"1605","1605","crediti per IVA ","16","account_type_tax","other","TRUE" +"1607","1607","imposte c/acconto ","16","account_type_tax","other","TRUE" +"1608","1608","crediti per imposte ","16","account_type_tax","other","TRUE" +"1609","1609","crediti per ritenute subite ","16","account_type_asset","other","TRUE" +"1610","1610","crediti per cauzioni ","16","account_type_asset","other","TRUE" +"1620","1620","personale c/acconti ","16","account_type_asset","other","TRUE" +"1630","1630","crediti v/istituti previdenziali ","16","account_type_asset","other","TRUE" "1640","1640","debitori diversi ","16","account_type_receivable","receivable","TRUE" "18","18","DISPONIBILITÀ LIQUIDE ","1","account_type_view","view","TRUE" "1801","1801","banche c/c ","18","account_type_bank","liquidity","TRUE" @@ -61,73 +61,73 @@ "1821","1821","assegni ","18","account_type_cash","liquidity","TRUE" "1822","1822","valori bollati ","18","account_type_cash","liquidity","TRUE" "19","19","RATEI E RISCONTI ATTIVI ","1","account_type_view","view","TRUE" -"1901","1901","ratei attivi ","19","account_type_view","other","TRUE" -"1902","1902","risconti attivi ","19","account_type_view","other","TRUE" +"1901","1901","ratei attivi ","19","account_type_asset","other","TRUE" +"1902","1902","risconti attivi ","19","account_type_asset","other","TRUE" "2","2","PASSIVO ","0","account_type_view","view","TRUE" "20","20","PATRIMONIO NETTO ","2","account_type_view","view","TRUE" -"2101","2101","patrimonio netto ","20","account_type_view","other","TRUE" -"2102","2102","utile d'esercizio ","20","account_type_view","receivable","TRUE" -"2103","2103","perdita d'esercizio ","20","account_type_view","payable","TRUE" -"2104","2104","prelevamenti extra gestione ","20","account_type_view","other","TRUE" -"2105","2105","titolare c/ritenute subite ","20","account_type_view","other","TRUE" +"2101","2101","patrimonio netto ","20","account_type_asset","other","TRUE" +"2102","2102","utile d'esercizio ","20","account_type_asset","other","TRUE" +"2103","2103","perdita d'esercizio ","20","account_type_asset","other","TRUE" +"2104","2104","prelevamenti extra gestione ","20","account_type_asset","other","TRUE" +"2105","2105","titolare c/ritenute subite ","20","account_type_asset","other","TRUE" "22","22","FONDI PER RISCHI E ONERI ","2","account_type_view","view","TRUE" -"2201","2201","fondo per imposte ","22","account_type_view","other","TRUE" -"2204","2204","fondo responsabilità civile ","22","account_type_view","other","TRUE" -"2205","2205","fondo spese future ","22","account_type_view","other","TRUE" -"2211","2211","fondo manutenzioni programmate ","22","account_type_view","other","TRUE" +"2201","2201","fondo per imposte ","22","account_type_asset","other","TRUE" +"2204","2204","fondo responsabilità civile ","22","account_type_asset","other","TRUE" +"2205","2205","fondo spese future ","22","account_type_asset","other","TRUE" +"2211","2211","fondo manutenzioni programmate ","22","account_type_asset","other","TRUE" "23","23","TRATTAMENTO FINE RAPPORTO DI LAVORO ","2","account_type_view","view","TRUE" -"2301","2301","debiti per TFRL ","23","account_type_view","other","TRUE" +"2301","2301","debiti per TFRL ","23","account_type_asset","other","TRUE" "24","24","DEBITI FINANZIARI ","2","account_type_view","view","TRUE" -"2410","2410","mutui passivi ","24","account_type_payable","other","TRUE" -"2411","2411","banche c/sovvenzioni ","24","account_type_payable","other","TRUE" -"2420","2420","banche c/c passivi ","24","account_type_payable","other","TRUE" -"2421","2421","banche c/RIBA all'incasso ","24","account_type_payable","other","TRUE" -"2422","2422","banche c/cambiali all'incasso ","24","account_type_payable","other","TRUE" -"2423","2423","banche c/anticipi su fatture ","24","account_type_payable","other","TRUE" -"2440","2440","debiti v/altri finanziatori ","24","account_type_payable","other","TRUE" +"2410","2410","mutui passivi ","24","account_type_asset","other","TRUE" +"2411","2411","banche c/sovvenzioni ","24","account_type_asset","other","TRUE" +"2420","2420","banche c/c passivi ","24","account_type_asset","other","TRUE" +"2421","2421","banche c/RIBA all'incasso ","24","account_type_asset","other","TRUE" +"2422","2422","banche c/cambiali all'incasso ","24","account_type_asset","other","TRUE" +"2423","2423","banche c/anticipi su fatture ","24","account_type_asset","other","TRUE" +"2440","2440","debiti v/altri finanziatori ","24","account_type_asset","other","TRUE" "25","25","DEBITI COMMERCIALI ","2","account_type_view","view","TRUE" "2501","2501","debiti v/fornitori ","25","account_type_payable","payable","TRUE" -"2503","2503","cambiali passive ","25","account_type_payable","other","TRUE" -"2520","2520","fatture da ricevere ","25","account_type_payable","other","TRUE" -"2521","2521","debiti da liquidare ","25","account_type_payable","other","TRUE" +"2503","2503","cambiali passive ","25","account_type_asset","other","TRUE" +"2520","2520","fatture da ricevere ","25","account_type_asset","other","TRUE" +"2521","2521","debiti da liquidare ","25","account_type_asset","other","TRUE" "2530","2530","clienti c/acconti ","25","account_type_payable","payable","TRUE" "26","26","DEBITI DIVERSI ","2","account_type_view","view","TRUE" -"2601","2601","IVA n/debito ","26","account_type_payable","other","TRUE" -"2602","2602","debiti per ritenute da versare ","26","account_type_payable","other","TRUE" -"2605","2605","erario c/IVA ","26","account_type_payable","payable","TRUE" -"2606","2606","debiti per imposte ","26","account_type_payable","other","TRUE" -"2619","2619","debiti per cauzioni ","26","account_type_payable","other","TRUE" -"2620","2620","personale c/retribuzioni ","26","account_type_payable","other","TRUE" -"2621","2621","personale c/liquidazioni ","26","account_type_payable","other","TRUE" -"2622","2622","clienti c/cessione ","26","account_type_payable","other","TRUE" -"2630","2630","debiti v/istituti previdenziali ","26","account_type_payable","other","TRUE" +"2601","2601","IVA n/debito ","26","account_type_tax","other","TRUE" +"2602","2602","debiti per ritenute da versare ","26","account_type_tax","other","TRUE" +"2605","2605","erario c/IVA ","26","account_type_tax","payable","TRUE" +"2606","2606","debiti per imposte ","26","account_type_tax","other","TRUE" +"2619","2619","debiti per cauzioni ","26","account_type_asset","other","TRUE" +"2620","2620","personale c/retribuzioni ","26","account_type_asset","other","TRUE" +"2621","2621","personale c/liquidazioni ","26","account_type_asset","other","TRUE" +"2622","2622","clienti c/cessione ","26","account_type_asset","other","TRUE" +"2630","2630","debiti v/istituti previdenziali ","26","account_type_asset","other","TRUE" "2640","2640","creditori diversi ","26","account_type_payable","payable","TRUE" "27","27","RATEI E RISCONTI PASSIVI ","2","account_type_view","view","TRUE" -"2701","2701","ratei passivi ","27","account_type_view","other","TRUE" -"2702","2702","risconti passivi ","27","account_type_view","other","TRUE" +"2701","2701","ratei passivi ","27","account_type_asset","other","TRUE" +"2702","2702","risconti passivi ","27","account_type_asset","other","TRUE" "28","28","CONTI TRANSITORI E DIVERSI ","2","account_type_view","view","TRUE" -"2801","2801","bilancio di apertura ","28","account_type_view","other","TRUE" -"2802","2802","bilancio di chiusura ","28","account_type_view","other","TRUE" -"2810","2810","IVA c/liquidazioni ","28","account_type_view","other","TRUE" -"2811","2811","istituti previdenziali ","28","account_type_view","other","TRUE" -"2820","2820","banca ... c/c ","28","account_type_view","other","TRUE" -"2821","2821","banca ... c/c ","28","account_type_view","other","TRUE" -"2822","2822","banca ... c/c ","28","account_type_view","other","TRUE" +"2801","2801","bilancio di apertura ","28","account_type_asset","other","TRUE" +"2802","2802","bilancio di chiusura ","28","account_type_asset","other","TRUE" +"2810","2810","IVA c/liquidazioni ","28","account_type_asset","other","TRUE" +"2811","2811","istituti previdenziali ","28","account_type_asset","other","TRUE" +"2820","2820","banca ... c/c ","28","account_type_asset","other","TRUE" +"2821","2821","banca ... c/c ","28","account_type_asset","other","TRUE" +"2822","2822","banca ... c/c ","28","account_type_asset","other","TRUE" "29","29","CONTI DEI SISTEMI SUPPLEMENTARI ","2","account_type_view","view","TRUE" -"2901","2901","beni di terzi ","29","account_type_view","other","TRUE" -"2902","2902","depositanti beni ","29","account_type_view","other","TRUE" -"2911","2911","merci da ricevere ","29","account_type_view","other","TRUE" -"2912","2912","fornitori c/impegni ","29","account_type_view","other","TRUE" -"2913","2913","impegni per beni in leasing ","29","account_type_view","other","TRUE" -"2914","2914","creditori c/leasing ","29","account_type_view","other","TRUE" -"2916","2916","clienti c/impegni ","29","account_type_view","other","TRUE" -"2917","2917","merci da consegnare ","29","account_type_view","other","TRUE" -"2921","2921","rischi per effetti scontati ","29","account_type_view","other","TRUE" -"2922","2922","banche c/effetti scontati ","29","account_type_view","other","TRUE" -"2926","2926","rischi per fideiussioni ","29","account_type_view","other","TRUE" -"2927","2927","creditori per fideiussioni ","29","account_type_view","other","TRUE" -"2931","2931","rischi per avalli ","29","account_type_view","other","TRUE" -"2932","2932","creditori per avalli ","29","account_type_view","other","TRUE" +"2901","2901","beni di terzi ","29","account_type_asset","other","TRUE" +"2902","2902","depositanti beni ","29","account_type_asset","other","TRUE" +"2911","2911","merci da ricevere ","29","account_type_asset","other","TRUE" +"2912","2912","fornitori c/impegni ","29","account_type_asset","other","TRUE" +"2913","2913","impegni per beni in leasing ","29","account_type_asset","other","TRUE" +"2914","2914","creditori c/leasing ","29","account_type_asset","other","TRUE" +"2916","2916","clienti c/impegni ","29","account_type_asset","other","TRUE" +"2917","2917","merci da consegnare ","29","account_type_asset","other","TRUE" +"2921","2921","rischi per effetti scontati ","29","account_type_asset","other","TRUE" +"2922","2922","banche c/effetti scontati ","29","account_type_asset","other","TRUE" +"2926","2926","rischi per fideiussioni ","29","account_type_asset","other","TRUE" +"2927","2927","creditori per fideiussioni ","29","account_type_asset","other","TRUE" +"2931","2931","rischi per avalli ","29","account_type_asset","other","TRUE" +"2932","2932","creditori per avalli ","29","account_type_asset","other","TRUE" "3","3","VALORE DELLA PRODUZIONE ","0","account_type_view","view","TRUE" "31","31","VENDITE E PRESTAZIONI ","3","account_type_view","view","TRUE" "3101","3101","merci c/vendite ","31","account_type_income","other","TRUE" diff --git a/addons/l10n_it/data/account.account.type.csv b/addons/l10n_it/data/account.account.type.csv index 273ff71eb05..d6827ca151c 100644 --- a/addons/l10n_it/data/account.account.type.csv +++ b/addons/l10n_it/data/account.account.type.csv @@ -1,11 +1,10 @@ "id","code","name","close_method","report_type" -"account_type_receivable","receivable","Debiti","unreconciled","liability" -"account_type_payable","payable","Crediti","unreconciled","asset" +"account_type_receivable","receivable","Crediti","unreconciled","asset" +"account_type_payable","payable","Debiti","unreconciled","liability" "account_type_view","view","Gerarchia","none", "account_type_income","income","Entrate","none","income" "account_type_expense","expense","Uscite","none","expense" -"account_type_tax","tax","Tasse","none", +"account_type_tax","tax","Tasse","balance", "account_type_cash","cash","Liquidità","balance","asset" -"account_type_asset","asset","Beni","none","asset" +"account_type_asset","asset","Beni","balance","asset" "account_type_bank","bank","Banca","balance","asset" -"account_type_equity","equity","Capitale","none","asset" From a490d148a47c8a3a2a4e7d123b57a7d6fddf85bf Mon Sep 17 00:00:00 2001 From: eLBati Date: Sun, 25 Sep 2011 11:15:08 +0200 Subject: [PATCH 018/278] [FIX] P & L accounts bzr revid: lorenzo.battistini@agilebg.com-20110925091508-tyg6fak0oiik5y2r --- .../l10n_it/data/account.account.template.csv | 82 +++++++++---------- addons/l10n_it/data/account.account.type.csv | 1 + 2 files changed, 42 insertions(+), 41 deletions(-) diff --git a/addons/l10n_it/data/account.account.template.csv b/addons/l10n_it/data/account.account.template.csv index a838a76e892..4fe01b77561 100644 --- a/addons/l10n_it/data/account.account.template.csv +++ b/addons/l10n_it/data/account.account.template.csv @@ -177,58 +177,58 @@ "4403","4403","TFRL ","44","account_type_expense","other","TRUE" "4404","4404","altri costi per il personale ","44","account_type_expense","other","TRUE" "45","45","AMMORTAMENTI IMMOBILIZZAZIONI IMMATERIALI ","4","account_type_view","view","TRUE" -"4501","4501","ammortamento costi di impianto ","45","account_type_view","other","TRUE" -"4506","4506","ammortamento software ","45","account_type_view","other","TRUE" -"4508","4508","ammortamento avviamento ","45","account_type_view","other","TRUE" +"4501","4501","ammortamento costi di impianto ","45","account_type_p_l","other","TRUE" +"4506","4506","ammortamento software ","45","account_type_p_l","other","TRUE" +"4508","4508","ammortamento avviamento ","45","account_type_p_l","other","TRUE" "46","46","AMMORTAMENTI IMMOBILIZZAZIONI MATERIALI ","4","account_type_view","view","TRUE" -"4601","4601","ammortamento fabbricati ","46","account_type_view","other","TRUE" -"4602","4602","ammortamento impianti e macchinari ","46","account_type_view","other","TRUE" -"4604","4604","ammortamento attrezzature commerciali ","46","account_type_view","other","TRUE" -"4605","4605","ammortamento macchine d'ufficio ","46","account_type_view","other","TRUE" -"4606","4606","ammortamento arredamento ","46","account_type_view","other","TRUE" -"4607","4607","ammortamento automezzi ","46","account_type_view","other","TRUE" -"4608","4608","ammortamento imballaggi durevoli ","46","account_type_view","other","TRUE" +"4601","4601","ammortamento fabbricati ","46","account_type_p_l","other","TRUE" +"4602","4602","ammortamento impianti e macchinari ","46","account_type_p_l","other","TRUE" +"4604","4604","ammortamento attrezzature commerciali ","46","account_type_p_l","other","TRUE" +"4605","4605","ammortamento macchine d'ufficio ","46","account_type_p_l","other","TRUE" +"4606","4606","ammortamento arredamento ","46","account_type_p_l","other","TRUE" +"4607","4607","ammortamento automezzi ","46","account_type_p_l","other","TRUE" +"4608","4608","ammortamento imballaggi durevoli ","46","account_type_p_l","other","TRUE" "47","47","SVALUTAZIONI ","4","account_type_view","view","TRUE" -"4701","4701","svalutazioni immobilizzazioni immateriali ","47","account_type_view","other","TRUE" -"4702","4702","svalutazioni immobilizzazioni materiali ","47","account_type_view","other","TRUE" -"4706","4706","svalutazione crediti ","47","account_type_view","other","TRUE" +"4701","4701","svalutazioni immobilizzazioni immateriali ","47","account_type_p_l","other","TRUE" +"4702","4702","svalutazioni immobilizzazioni materiali ","47","account_type_p_l","other","TRUE" +"4706","4706","svalutazione crediti ","47","account_type_p_l","other","TRUE" "48","48","ACCANTONAMENTI ","4","account_type_view","view","TRUE" "481","481","ACCANTONAMENTI PER RISCHI ","48","account_type_view","view","TRUE" -"4814","4814","accantonamento per responsabilità civile ","481","account_type_view","other","TRUE" +"4814","4814","accantonamento per responsabilità civile ","481","account_type_p_l","other","TRUE" "482","482","ALTRI ACCANTONAMENTI ","48","account_type_view","view","TRUE" -"4821","4821","accantonamento per spese future ","482","account_type_view","other","TRUE" -"4823","4823","accantonamento per manutenzioni programmate ","482","account_type_view","other","TRUE" +"4821","4821","accantonamento per spese future ","482","account_type_p_l","other","TRUE" +"4823","4823","accantonamento per manutenzioni programmate ","482","account_type_p_l","other","TRUE" "49","49","ONERI DIVERSI ","4","account_type_view","view","TRUE" -"4901","4901","oneri fiscali diversi ","49","account_type_view","other","TRUE" -"4903","4903","oneri vari ","49","account_type_view","other","TRUE" -"4905","4905","perdite su crediti ","49","account_type_view","other","TRUE" -"4910","4910","arrotondamenti passivi ","49","account_type_view","other","TRUE" -"4920","4920","minusvalenze ordinarie diverse ","49","account_type_view","other","TRUE" -"4930","4930","sopravvenienze passive ordinarie diverse ","49","account_type_view","other","TRUE" -"4940","4940","insussistenze passive ordinarie diverse ","49","account_type_view","other","TRUE" +"4901","4901","oneri fiscali diversi ","49","account_type_p_l","other","TRUE" +"4903","4903","oneri vari ","49","account_type_p_l","other","TRUE" +"4905","4905","perdite su crediti ","49","account_type_p_l","other","TRUE" +"4910","4910","arrotondamenti passivi ","49","account_type_p_l","other","TRUE" +"4920","4920","minusvalenze ordinarie diverse ","49","account_type_p_l","other","TRUE" +"4930","4930","sopravvenienze passive ordinarie diverse ","49","account_type_p_l","other","TRUE" +"4940","4940","insussistenze passive ordinarie diverse ","49","account_type_p_l","other","TRUE" "5","5","PROVENTI E ONERI FINANZIARI ","0","account_type_view","view","TRUE" "51","51","PROVENTI FINANZIARI ","5","account_type_view","view","TRUE" -"5110","5110","interessi attivi v/clienti ","51","account_type_view","other","TRUE" -"5115","5115","interessi attivi bancari ","51","account_type_view","other","TRUE" -"5116","5116","interessi attivi postali ","51","account_type_view","other","TRUE" -"5140","5140","proventi finanziari diversi ","51","account_type_view","other","TRUE" +"5110","5110","interessi attivi v/clienti ","51","account_type_p_l","other","TRUE" +"5115","5115","interessi attivi bancari ","51","account_type_p_l","other","TRUE" +"5116","5116","interessi attivi postali ","51","account_type_p_l","other","TRUE" +"5140","5140","proventi finanziari diversi ","51","account_type_p_l","other","TRUE" "52","52","ONERI FINANZIARI ","5","account_type_view","view","TRUE" -"5201","5201","interessi passivi v/fornitori ","52","account_type_view","other","TRUE" -"5202","5202","interessi passivi bancari ","52","account_type_view","other","TRUE" -"5203","5203","sconti passivi bancari ","52","account_type_view","other","TRUE" -"5210","5210","interessi passivi su mutui ","52","account_type_view","other","TRUE" -"5240","5240","oneri finanziari diversi ","52","account_type_view","other","TRUE" +"5201","5201","interessi passivi v/fornitori ","52","account_type_p_l","other","TRUE" +"5202","5202","interessi passivi bancari ","52","account_type_p_l","other","TRUE" +"5203","5203","sconti passivi bancari ","52","account_type_p_l","other","TRUE" +"5210","5210","interessi passivi su mutui ","52","account_type_p_l","other","TRUE" +"5240","5240","oneri finanziari diversi ","52","account_type_p_l","other","TRUE" "7","7","PROVENTI E ONERI STRAORDINARI ","0","account_type_view","view","TRUE" "71","71","PROVENTI STRAORDINARI ","7","account_type_view","view","TRUE" -"7101","7101","plusvalenze straordinarie ","71","account_type_view","other","TRUE" -"7102","7102","sopravvenienze attive straordinarie ","71","account_type_view","other","TRUE" -"7103","7103","insussistenze attive straordinarie ","71","account_type_view","other","TRUE" +"7101","7101","plusvalenze straordinarie ","71","account_type_p_l","other","TRUE" +"7102","7102","sopravvenienze attive straordinarie ","71","account_type_p_l","other","TRUE" +"7103","7103","insussistenze attive straordinarie ","71","account_type_p_l","other","TRUE" "72","72","ONERI STRAORDINARI ","7","account_type_view","view","TRUE" -"7201","7201","minusvalenze straordinarie ","72","account_type_view","other","TRUE" -"7202","7202","sopravvenienze passive straordinarie ","72","account_type_view","other","TRUE" -"7203","7203","insussistenze passive straordinarie ","72","account_type_view","other","TRUE" -"7204","7204","imposte esercizi precedenti ","72","account_type_view","other","TRUE" +"7201","7201","minusvalenze straordinarie ","72","account_type_p_l","other","TRUE" +"7202","7202","sopravvenienze passive straordinarie ","72","account_type_p_l","other","TRUE" +"7203","7203","insussistenze passive straordinarie ","72","account_type_p_l","other","TRUE" +"7204","7204","imposte esercizi precedenti ","72","account_type_p_l","other","TRUE" "81","81","IMPOSTE DELL'ESERCIZIO ","7","account_type_view","view","TRUE" -"8101","8101","imposte dell'esercizio ","81","account_type_view","other","TRUE" +"8101","8101","imposte dell'esercizio ","81","account_type_p_l","other","TRUE" "91","91","CONTI DI RISULTATO ","7","account_type_view","view","TRUE" -"9101","9101","conto di risultato economico ","91","account_type_view","other","TRUE" +"9101","9101","conto di risultato economico ","91","account_type_p_l","other","TRUE" diff --git a/addons/l10n_it/data/account.account.type.csv b/addons/l10n_it/data/account.account.type.csv index d6827ca151c..36eeebbbe89 100644 --- a/addons/l10n_it/data/account.account.type.csv +++ b/addons/l10n_it/data/account.account.type.csv @@ -8,3 +8,4 @@ "account_type_cash","cash","Liquidità","balance","asset" "account_type_asset","asset","Beni","balance","asset" "account_type_bank","bank","Banca","balance","asset" +"account_type_p_l","p_l","Conto Economico","none", From ad61a880bf166d953d38774c437ec8b69bde7b3e Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Wed, 28 Sep 2011 17:43:31 +0530 Subject: [PATCH 019/278] [FIX] hr-expense : incmplete handling of canceld and reopened invoices lp bug: https://launchpad.net/bugs/808704 fixed bzr revid: ara@tinyerp.com-20110928121331-p3x76mmel6ity9fs --- addons/hr_expense/hr_expense.py | 5 +++++ addons/hr_expense/hr_expense_view.xml | 1 + addons/hr_expense/hr_expense_workflow.xml | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index 2dc6ad090ac..b671705d769 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -82,6 +82,7 @@ class hr_expense_expense(osv.osv): ('accepted', 'Approved'), ('invoiced', 'Invoiced'), ('paid', 'Reimbursed'), + ('invoice_except', 'Invoice Exception'), ('cancelled', 'Refused')], 'State', readonly=True, help='When the expense request is created the state is \'Draft\'.\n It is confirmed by the user and request is sent to admin, the state is \'Waiting Confirmation\'.\ \nIf the admin accepts it, the state is \'Accepted\'.\n If an invoice is made for the expense request, the state is \'Invoiced\'.\n If the expense is paid to user, the state is \'Reimbursed\'.'), @@ -224,6 +225,10 @@ class hr_expense_expense(osv.osv): res = inv_id return res + def action_invoice_cancel(self, cr, uid, ids, context=None): + self.write(cr, uid, ids, {'state': 'invoice_except'}, context=context) + return True + hr_expense_expense() class product_product(osv.osv): diff --git a/addons/hr_expense/hr_expense_view.xml b/addons/hr_expense/hr_expense_view.xml index 786dc6beee2..a832191bb90 100644 --- a/addons/hr_expense/hr_expense_view.xml +++ b/addons/hr_expense/hr_expense_view.xml @@ -106,6 +106,7 @@ '); self.add_node_dialog.$element.find("select[id=node_type] option[value=field]").attr("selected",1); self.add_node_dialog.$element.find('#new_field').click(function() { - var action = { - context: self.session.user_context, - res_model: "ir.model.fields", - views: [[false, 'form']], - type: 'ir.actions.act_window', - target: "new", - flags: { - sidebar: false, - views_switcher: false, - action_buttons: false, - search_view: false, - pager: false, - }, - }; - var action_manager = new openerp.web.ActionManager(self); - action_manager.do_action(action); - + model_data = new openerp.web.DataSetSearch(self,'ir.model', null, null); + model_data.read_slice([], {domain: [['model','=', self.model]]}, function(result) { + self.render_new_field(result[0].id); + }); }); + }, + render_new_field :function(id){ + var action = { + context: {'default_model_id':id, 'manual':true},//self.session.user_context, + res_model: "ir.model.fields", + views: [[false, 'form']], + type: 'ir.actions.act_window', + target: "new", + flags: { + action_buttons: true, + }, + }; + var action_manager = new openerp.web.ActionManager(self); + action_manager.do_action(action); + }); + } }); openerp.web.ViewEditor.Field = openerp.web.Class.extend({ From eeede305423e8dd623ca76b3c047c58735d9d471 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 14 Nov 2011 16:37:12 +0530 Subject: [PATCH 105/278] [IMP] vieweditor :- improve code and add warning message. bzr revid: ysa@tinyerp.com-20111114110712-761wddi4f9low200 --- addons/web/static/src/js/view_editor.js | 36 ++++++++++++++----------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index f4d322542c8..487d5b55dc0 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -75,7 +75,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }, on_create_view: function() { var self = this; - this.create_view_dialog = new openerp.web.Dialog(this,{ + this.create_view_dialog = new openerp.web.Dialog(this, { modal: true, title: _.sprintf("Create a view (%s)", self.model), width: 500, @@ -86,7 +86,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var warn = false; _.each(self.create_view_widget, function(widget) { if (widget.invalid) { - warn = true + warn = true; return false; }; if (widget.dirty && !widget.invalid) { @@ -179,10 +179,12 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }, do_delete_view: function() { + var self = this; if (confirm(_t("Do you really want to remove this view?"))) { - var controller = this.action_manager.inner_viewmanager.views[this.action_manager.inner_viewmanager.active_view].controller; - this.dataset.unlink([this.main_view_id]).then(function() { + var controller = this.action_manager.inner_viewmanager.views[this.action_manager.inner_viewmanager.active_view].controller; + self.dataset.unlink([this.main_view_id]).then(function() { controller.reload_content(); + self.main_view_id = self.parent.fields_view.view_id; }); } }, @@ -245,18 +247,22 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var self = this; var view_arch_list = []; this.dataset.read_ids([parseInt(self.main_view_id)], ['arch', 'type'], function(arch) { - var arch_object = self.parse_xml(arch[0].arch, self.main_view_id); - self.main_view_type = arch[0].type - view_arch_list.push({"view_id": self.main_view_id, "arch": arch[0].arch}); - self.dataset.read_slice([], {domain: [['inherit_id','=', parseInt(self.main_view_id)]]}, function(result) { - _.each(result, function(res) { - view_arch_list.push({"view_id": res.id, "arch": res.arch}); - self.inherit_view(arch_object, res); + if (arch.length) { + var arch_object = self.parse_xml(arch[0].arch, self.main_view_id); + self.main_view_type = arch[0].type + view_arch_list.push({"view_id": self.main_view_id, "arch": arch[0].arch}); + self.dataset.read_slice([], {domain: [['inherit_id','=', parseInt(self.main_view_id)]]}, function(result) { + _.each(result, function(res) { + view_arch_list.push({"view_id": res.id, "arch": res.arch}); + self.inherit_view(arch_object, res); + }); + return self.edit_view({"main_object": arch_object, + "parent_child_id": self.parent_child_list(arch_object, []), + "arch": view_arch_list}); }); - return self.edit_view({"main_object": arch_object, - "parent_child_id": self.parent_child_list(arch_object, []), - "arch": view_arch_list}); - }); + } else { + self.do_warn("Please select view in list :"); + } }); }, parent_child_list : function(one_object, parent_list) { From 479ab434292f84fbf9396f3860b8ae8f72427d4c Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 14 Nov 2011 16:57:34 +0530 Subject: [PATCH 106/278] [IMP] vieweditor:- simple value pass on set_value method instead of array.. bzr revid: ysa@tinyerp.com-20111114112734-l3d7v634sy1g9qsp --- addons/web/static/src/js/view_editor.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 487d5b55dc0..17b05cbf540 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -666,6 +666,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var value = _.detect(arch_val[0]['att_list'],function(res) { return _.include(res, id); }); + value = value instanceof Array ? value[1] : value; if (id == 'groups') type_widget.selection = self.groups; self.edit_node_dialog.$element.find('table[id=rec_table]').append(''+id+':'+type_widget.render()+''); type_widget.start(); @@ -749,7 +750,7 @@ openerp.web.ViewEditor.FieldBoolean = openerp.web.ViewEditor.Field.extend({ }, set_value: function(value) { if (value) { - this.$element.find("input[id=" + this.name+ "]").attr('checked', value[1]); + this.$element.find("input[id=" + this.name+ "]").attr('checked', true); } }, get_value: function() { @@ -767,7 +768,7 @@ openerp.web.ViewEditor.FieldChar = openerp.web.ViewEditor.Field.extend({ this._super(); }, set_value: function(value) { - value ? this.$element.find("input[id=" + this.name + "]").val(value[1]): this.$element.find("tr[id=" + this.name + "] input").val(); + value ? this.$element.find("input[id=" + this.name + "]").val(value): this.$element.find("tr[id=" + this.name + "] input").val(); }, get_value: function() { var value= this.$element.find("input[id=" + this.name + "]").val(); @@ -789,7 +790,6 @@ openerp.web.ViewEditor.FieldSelect = openerp.web.ViewEditor.Field.extend({ }, set_value: function(value) { value = value === null ? false : value; - value = value instanceof Array ? value[1] : value; var index = 0; for (var i = 0, ii = this.selection.length; i < ii; i++) { if ((this.selection[i] instanceof Array && this.selection[i][1] === value) || this.selection[i] === value) index = i; @@ -814,7 +814,7 @@ openerp.web.ViewEditor.WidgetProperty = openerp.web.ViewEditor.FieldSelect.exten openerp.web.ViewEditor.IconProperty = openerp.web.ViewEditor.FieldSelect.extend({ init: function(view, id) { this._super(view, id); - this.selection = icons; + this.selection = _ICONS; }, }); openerp.web.ViewEditor.ButtonTargetProperty = openerp.web.ViewEditor.FieldSelect.extend({ @@ -848,12 +848,7 @@ openerp.web.ViewEditor.PositionProperty = openerp.web.ViewEditor.FieldSelect.ext }, }); openerp.web.ViewEditor.GroupsProperty = openerp.web.ViewEditor.FieldSelect.extend({ - init: function(view, id) { - this._super(view, id); - this.multiple = true; - }, start: function () { - this._super(); this.$element.find("select[id=" + this.name + "]").css('height', '100px').attr("multiple",true); this._super(); }, @@ -862,7 +857,7 @@ openerp.web.ViewEditor.GroupsProperty = openerp.web.ViewEditor.FieldSelect.exten self.$element.find("#groups option").attr("selected",false); if (!value) return false; _.each(this.selection, function(item) { - if (_.include(value[1].split(','), item[0])) { + if (_.include(value.split(','), item[0])) { self.$element.find("select[id="+self.name+"] option[value='" + item[0] +"']").attr("selected",1) } }); @@ -887,7 +882,7 @@ var _PROPERTIES = { 'graph' : ['string', 'type'], 'calendar' : ['string', 'date_start', 'date_stop', 'date_delay', 'day_length', 'color', 'mode'], }; -var icons = ['','STOCK_ABOUT', 'STOCK_ADD', 'STOCK_APPLY', 'STOCK_BOLD', +var _ICONS = ['','STOCK_ABOUT', 'STOCK_ADD', 'STOCK_APPLY', 'STOCK_BOLD', 'STOCK_CANCEL', 'STOCK_CDROM', 'STOCK_CLEAR', 'STOCK_CLOSE', 'STOCK_COLOR_PICKER', 'STOCK_CONNECT', 'STOCK_CONVERT', 'STOCK_COPY', 'STOCK_CUT', 'STOCK_DELETE', 'STOCK_DIALOG_AUTHENTICATION', 'STOCK_DIALOG_ERROR', 'STOCK_DIALOG_INFO', From a58a66282bc6ba590fd4d0ae1ee9a3cb29445530 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 14 Nov 2011 17:10:55 +0530 Subject: [PATCH 107/278] [IMP] vieweditor :- change variable name id to property. bzr revid: ysa@tinyerp.com-20111114114055-d8tdfcvofsivhws6 --- addons/web/static/src/js/view_editor.js | 61 ++++++++++++------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 17b05cbf540..61af4d194e3 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -385,8 +385,6 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ sidebar: false, views_switcher: false, action_buttons: false, - search_view: false, - pager: false, }, }; var action_manager = new openerp.web.ActionManager(self); @@ -654,21 +652,20 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var arch_val = self.get_object_by_id(clicked_tr_id,obj['main_object'], []); this.edit_node_dialog.$element.append('
'); this.edit_widget = []; - _.each(properties, function(record) { - var id = record, - type_widget; - self.ready = $.when(self.on_groups(id)).then(function () { - if (_.include(widget,id)){ - type_widget = new (self.property.get_any(['undefined' , id, arch_val[0]['att_list'][0]])) (self.edit_node_dialog, id); + _.each(properties, function(property) { + type_widget = false; + self.ready = $.when(self.on_groups(property)).then(function () { + if (_.include(widget, property)){ + type_widget = new (self.property.get_any([property])) (self.edit_node_dialog, property); } else { - type_widget = new openerp.web.ViewEditor.FieldChar (self.edit_node_dialog, id); + type_widget = new openerp.web.ViewEditor.FieldChar (self.edit_node_dialog, property); } var value = _.detect(arch_val[0]['att_list'],function(res) { - return _.include(res, id); + return _.include(res, property); }); value = value instanceof Array ? value[1] : value; - if (id == 'groups') type_widget.selection = self.groups; - self.edit_node_dialog.$element.find('table[id=rec_table]').append(''+id+':'+type_widget.render()+''); + if (property == 'groups') type_widget.selection = self.groups; + self.edit_node_dialog.$element.find('table[id=rec_table]').append('' + property + ':' + type_widget.render() + ''); type_widget.start(); type_widget.set_value(value) self.edit_widget.push(type_widget); @@ -676,10 +673,10 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); }, //for getting groups - on_groups: function(id){ + on_groups: function(property){ var self = this, def = $.Deferred(); - if (id != 'groups') { + if (property != 'groups') { self.groups = false; return false; } @@ -710,10 +707,10 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }); openerp.web.ViewEditor.Field = openerp.web.Class.extend({ - init: function(view, id) { + init: function(view, name) { this.$element = view.$element; this.dirty = false; - this.name = id; + this.name = name; this.required = false; this.invalid = false; }, @@ -777,8 +774,8 @@ openerp.web.ViewEditor.FieldChar = openerp.web.ViewEditor.Field.extend({ }); openerp.web.ViewEditor.FieldSelect = openerp.web.ViewEditor.Field.extend({ template : "vieweditor_selection", - init: function(view, id) { - this._super(view, id); + init: function(view, name) { + this._super(view, name); this.selection = false; }, start: function () { @@ -802,8 +799,8 @@ openerp.web.ViewEditor.FieldSelect = openerp.web.ViewEditor.Field.extend({ } }); openerp.web.ViewEditor.WidgetProperty = openerp.web.ViewEditor.FieldSelect.extend({ - init: function(view, id) { - this._super(view, id); + init: function(view, name) { + this._super(view, name); this.registry = openerp.web.form.widgets; var values = _.keys(this.registry.map); values.push(''); @@ -812,38 +809,38 @@ openerp.web.ViewEditor.WidgetProperty = openerp.web.ViewEditor.FieldSelect.exten }, }); openerp.web.ViewEditor.IconProperty = openerp.web.ViewEditor.FieldSelect.extend({ - init: function(view, id) { - this._super(view, id); + init: function(view, name) { + this._super(view, name); this.selection = _ICONS; }, }); openerp.web.ViewEditor.ButtonTargetProperty = openerp.web.ViewEditor.FieldSelect.extend({ - init: function(view, id) { - this._super(view, id); + init: function(view, name) { + this._super(view, name); this.selection = [['', ''], ['new', 'New Window']]; }, }); openerp.web.ViewEditor.ButtonTypeProperty = openerp.web.ViewEditor.FieldSelect.extend({ - init: function(view, id) { - this._super(view, id); + init: function(view, name) { + this._super(view, name); this.selection = [['', ''], ['action', 'Action'], ['object', 'Object'], ['workflow', 'Workflow'], ['server_action', 'Server Action']]; }, }); openerp.web.ViewEditor.AlignProperty = openerp.web.ViewEditor.FieldSelect.extend({ - init: function(view, id) { - this._super(view, id); + init: function(view, name) { + this._super(view, name); this.selection = [['', ''], ['0.0', 'Left'], ['0.5', 'Center'], ['1.0', 'Right']]; }, }); openerp.web.ViewEditor.ButtonSpecialProperty = openerp.web.ViewEditor.FieldSelect.extend({ - init: function(view, id) { - this._super(view, id); + init: function(view, name) { + this._super(view, name); this.selection = [['',''],['save', 'Save Button'], ['cancel', 'Cancel Button'], ['open', 'Open Button']]; }, }); openerp.web.ViewEditor.PositionProperty = openerp.web.ViewEditor.FieldSelect.extend({ - init: function(view, id) { - this._super(view, id); + init: function(view, name) { + this._super(view, name); this.selection = [['',''],['after', 'After'],['before', 'Before'],['inside', 'Inside'],['replace', 'Replace']]; }, }); From 311b55260196db7b137b0d33382dab8deedf8e30 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 14 Nov 2011 17:49:33 +0530 Subject: [PATCH 108/278] [IMP] Improve code in vieweditor. bzr revid: ysa@tinyerp.com-20111114121933-zmxgk4oy9e20p08u --- addons/web/static/src/js/view_editor.js | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 61af4d194e3..3988cfd84c4 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -94,14 +94,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }); if (warn) { - var msg = "
    "; - _.each(self.create_view_widget, function(widget) { - if (widget.invalid) { - msg += "
  • " + widget.name + "
  • "; - } - }); - msg += "
"; - self.do_warn("The following fields are invalid :", msg); + self.on_valid_create_view(); } else { $.when(self.do_save_view(view_values)).then(function() { self.create_view_dialog.close(); @@ -130,7 +123,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ self.create_view_dialog.$element.find('table[id=create_view]').append('' + widget.string + ':' + type_widget.render()+''); var value = null; if (widget.value) { - value = [widget.name, widget.value]; + value = widget.value; type_widget.dirty = true; } type_widget.start(); @@ -163,6 +156,16 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); return def.promise(); }, + on_valid_create_view: function() { + var msg = "
    "; + _.each(self.create_view_widget, function(widget) { + if (widget.invalid) { + msg += "
  • " + widget.name + "
  • "; + } + }); + msg += "
"; + self.do_warn("The following fields are invalid :", msg); + }, add_node_name : function(node) { if(node.tagName.toLowerCase() == "button" || node.tagName.toLowerCase() == "field"){ return (node.getAttribute('name'))? @@ -751,8 +754,7 @@ openerp.web.ViewEditor.FieldBoolean = openerp.web.ViewEditor.Field.extend({ } }, get_value: function() { - var value = this.$element.find("input[id=" + this.name + "]").is(':checked'); - return value ? value: null; + return this.$element.find("input[id=" + this.name + "]").is(':checked') || null; } }); openerp.web.ViewEditor.FieldChar = openerp.web.ViewEditor.Field.extend({ @@ -768,8 +770,7 @@ openerp.web.ViewEditor.FieldChar = openerp.web.ViewEditor.Field.extend({ value ? this.$element.find("input[id=" + this.name + "]").val(value): this.$element.find("tr[id=" + this.name + "] input").val(); }, get_value: function() { - var value= this.$element.find("input[id=" + this.name + "]").val(); - return value ? value: ""; + return this.$element.find("input[id=" + this.name + "]").val(); } }); openerp.web.ViewEditor.FieldSelect = openerp.web.ViewEditor.Field.extend({ @@ -794,8 +795,7 @@ openerp.web.ViewEditor.FieldSelect = openerp.web.ViewEditor.Field.extend({ this.$element.find("select[id=" + this.name + "]")[0].selectedIndex = index; }, get_value: function() { - var value = this.$element.find("select[id=" + this.name + "]").val(); - return value ? value: ""; + return this.$element.find("select[id=" + this.name + "]").val(); } }); openerp.web.ViewEditor.WidgetProperty = openerp.web.ViewEditor.FieldSelect.extend({ From 4b250ebee88b70d0ded96174ec6d19cf3aa68592 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 15 Nov 2011 10:20:27 +0530 Subject: [PATCH 109/278] [IMP] vieweditor:- improve code and set element in start method. bzr revid: ysa@tinyerp.com-20111115045027-b7j0qpw31d2zoqii --- addons/web/static/src/js/view_editor.js | 40 +++++++++++++------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 3988cfd84c4..8e630089e3f 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -120,7 +120,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ type_widget.selection = widget.selection; } type_widget.required = widget.required; - self.create_view_dialog.$element.find('table[id=create_view]').append('' + widget.string + ':' + type_widget.render()+''); + self.create_view_dialog.$element.find('table[id=create_view]').append('' + widget.string + ':' + type_widget.render()+''); var value = null; if (widget.value) { value = widget.value; @@ -668,7 +668,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); value = value instanceof Array ? value[1] : value; if (property == 'groups') type_widget.selection = self.groups; - self.edit_node_dialog.$element.find('table[id=rec_table]').append('' + property + ':' + type_widget.render() + ''); + self.edit_node_dialog.$element.find('table[id=rec_table]').append('' + property + ':' + type_widget.render() + ''); type_widget.start(); type_widget.set_value(value) self.edit_widget.push(type_widget); @@ -718,11 +718,12 @@ openerp.web.ViewEditor.Field = openerp.web.Class.extend({ this.invalid = false; }, start: function () { + this.$element = this.$element.find("td[id="+ this.name+"]"); this.update_dom(); }, update_dom: function() { - this.$element.find("td[id="+ this.name+"]").toggleClass('invalid', this.invalid); - this.$element.find("td[id="+ this.name+"]").toggleClass('required', this.required); + this.$element.toggleClass('invalid', this.invalid); + this.$element.toggleClass('required', this.required); }, on_ui_change: function() { var value = this.get_value(); @@ -736,41 +737,42 @@ openerp.web.ViewEditor.Field = openerp.web.Class.extend({ this.update_dom(); }, render: function() { - return QWeb.render(this.template, {widget: this}); + return _.sprintf("%s", this.name, QWeb.render(this.template, {widget: this})) }, }); openerp.web.ViewEditor.FieldBoolean = openerp.web.ViewEditor.Field.extend({ template : "vieweditor_boolean", start: function() { var self = this; - this.$element.find("input[id="+ self.name+"]").change(function() { + this._super(); + this.$element.find("input").change(function() { self.on_ui_change(); }); - this._super(); + }, set_value: function(value) { if (value) { - this.$element.find("input[id=" + this.name+ "]").attr('checked', true); + this.$element.find("input").attr('checked', true); } }, get_value: function() { - return this.$element.find("input[id=" + this.name + "]").is(':checked') || null; + return this.$element.find("input").is(':checked') || null; } }); openerp.web.ViewEditor.FieldChar = openerp.web.ViewEditor.Field.extend({ template : "vieweditor_char", start: function () { var self = this; - this.$element.find("input[id="+ this.name+"]").css('width','100%').change(function() { + this._super(); + this.$element.find("input").css('width','100%').change(function() { self.on_ui_change(); }); - this._super(); }, set_value: function(value) { - value ? this.$element.find("input[id=" + this.name + "]").val(value): this.$element.find("tr[id=" + this.name + "] input").val(); + this.$element.find("input").val(value); }, get_value: function() { - return this.$element.find("input[id=" + this.name + "]").val(); + return this.$element.find("input").val(); } }); openerp.web.ViewEditor.FieldSelect = openerp.web.ViewEditor.Field.extend({ @@ -781,10 +783,10 @@ openerp.web.ViewEditor.FieldSelect = openerp.web.ViewEditor.Field.extend({ }, start: function () { var self = this; - this.$element.find("select[id=" + this.name + "]").css('width', '100%').change(function() { + this._super(); + this.$element.find("select").css('width', '100%').change(function() { self.on_ui_change(); }); - this._super(); }, set_value: function(value) { value = value === null ? false : value; @@ -792,10 +794,10 @@ openerp.web.ViewEditor.FieldSelect = openerp.web.ViewEditor.Field.extend({ for (var i = 0, ii = this.selection.length; i < ii; i++) { if ((this.selection[i] instanceof Array && this.selection[i][1] === value) || this.selection[i] === value) index = i; } - this.$element.find("select[id=" + this.name + "]")[0].selectedIndex = index; + this.$element.find("select")[0].selectedIndex = index; }, get_value: function() { - return this.$element.find("select[id=" + this.name + "]").val(); + return this.$element.find("select").val(); } }); openerp.web.ViewEditor.WidgetProperty = openerp.web.ViewEditor.FieldSelect.extend({ @@ -846,8 +848,8 @@ openerp.web.ViewEditor.PositionProperty = openerp.web.ViewEditor.FieldSelect.ext }); openerp.web.ViewEditor.GroupsProperty = openerp.web.ViewEditor.FieldSelect.extend({ start: function () { - this.$element.find("select[id=" + this.name + "]").css('height', '100px').attr("multiple",true); this._super(); + this.$element.find("select[id=" + this.name + "]").css('height', '100px').attr("multiple",true); }, set_value: function(value) { var self = this; @@ -855,7 +857,7 @@ openerp.web.ViewEditor.GroupsProperty = openerp.web.ViewEditor.FieldSelect.exten if (!value) return false; _.each(this.selection, function(item) { if (_.include(value.split(','), item[0])) { - self.$element.find("select[id="+self.name+"] option[value='" + item[0] +"']").attr("selected",1) + self.$element.find("select option[value='" + item[0] +"']").attr("selected",1) } }); } From 17c81331aaf7457cb2789df448819f57aca2623e Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 15 Nov 2011 11:24:53 +0530 Subject: [PATCH 110/278] [IMP] vieweditor :- add property attribute. bzr revid: ysa@tinyerp.com-20111115055453-5b3zse1uz29yl4lb --- addons/web/static/src/js/view_editor.js | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 8e630089e3f..eb0cceb387e 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -881,6 +881,43 @@ var _PROPERTIES = { 'graph' : ['string', 'type'], 'calendar' : ['string', 'date_start', 'date_stop', 'date_delay', 'day_length', 'color', 'mode'], }; +var _PROPERTIES_ATTRIBUTES = { + 'name' : {'string': 'Name', 'type': 'char'}, + 'string' : {'string': 'String', 'type': 'char'}, + 'required' : {'string': 'Required', 'type': 'boolean'}, + 'readonly' : {'string': 'Readonly', 'type': 'boolean'}, + 'domain' : {'string': 'Domain', 'type': 'char'}, + 'context' : {'string': 'Context', 'type': 'char'}, + 'limit' : {'string': 'Limit', 'type': 'selection'}, + 'min_rows' : {'string': 'Minimum rows', 'type': 'char'}, + 'date_start' : {'string': 'Start date', 'type': 'char'}, + 'date_delay' : {'string': 'Delay date', 'type': 'char'}, + 'day_length' : {'string': 'Day length', 'type': 'char'}, + 'mode' : {'string': 'Mode', 'type': 'char'}, + 'align' : {'string': 'Alignment ', 'type': 'selection'}, + 'icon' : {'string': 'Icon', 'type': 'selection'}, + 'type' : {'string': 'Type', 'type': 'selection'}, + 'special' : {'string': 'Special', 'type': 'selection'}, + 'target' : {'string': 'Target', 'type': 'selection'}, + 'confirm' : {'string': 'Confirm', 'type': 'char'}, + 'style' : {'string': 'Style', 'type': 'selection'}, + 'filename' : {'string': 'File Name', 'type': 'char'}, + 'width' : {'string': 'Width', 'type': 'char'}, + 'height' : {'string': 'Height', 'type': 'char'}, + 'groups' : {'string': 'Groups', 'type': 'seleciton_multi'}, + 'attrs' : {'string': 'Attrs', 'type': 'char'}, + 'col' : {'string': 'col', 'type': 'char'}, + 'link' : {'string': 'Link', 'type': 'char'}, + 'position' : {'string': 'Position', 'type': 'selection'}, + 'states' : {'string': 'states', 'type': 'char'}, + 'eval' : {'string': 'Eval', 'type': 'char'}, + 'ref' : {'string': 'Ref', 'type': 'char'}, + 'on_change' : {'string': 'On change', 'type': 'char'}, + 'nolabel' : {'string': 'No label', 'type': 'boolean'}, + 'completion' : {'string': 'Completion', 'type': 'boolean'}, + 'colspan' : {'string': 'Colspan', 'type': 'char'}, + 'widget' : {'string': 'widget', 'type': 'selection'}, +}; var _ICONS = ['','STOCK_ABOUT', 'STOCK_ADD', 'STOCK_APPLY', 'STOCK_BOLD', 'STOCK_CANCEL', 'STOCK_CDROM', 'STOCK_CLEAR', 'STOCK_CLOSE', 'STOCK_COLOR_PICKER', 'STOCK_CONNECT', 'STOCK_CONVERT', 'STOCK_COPY', 'STOCK_CUT', 'STOCK_DELETE', From 41ee96e532d02837b35a5cc999dcc69a6413a9e6 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 15 Nov 2011 13:11:11 +0530 Subject: [PATCH 111/278] [IMP] vieweditor :- improve selector in widget. bzr revid: ysa@tinyerp.com-20111115074111-ij7kp2kr7rlxr0v6 --- addons/web/static/src/js/view_editor.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 8e630089e3f..ba68e55c3a0 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -718,12 +718,11 @@ openerp.web.ViewEditor.Field = openerp.web.Class.extend({ this.invalid = false; }, start: function () { - this.$element = this.$element.find("td[id="+ this.name+"]"); this.update_dom(); }, update_dom: function() { - this.$element.toggleClass('invalid', this.invalid); - this.$element.toggleClass('required', this.required); + this.$element.find("td[id="+ this.name+"]").toggleClass('invalid', this.invalid); + this.$element.find("td[id="+ this.name+"]").toggleClass('required', this.required); }, on_ui_change: function() { var value = this.get_value(); @@ -745,18 +744,18 @@ openerp.web.ViewEditor.FieldBoolean = openerp.web.ViewEditor.Field.extend({ start: function() { var self = this; this._super(); - this.$element.find("input").change(function() { + this.$element.find("input[id="+ self.name+"]").change(function() { self.on_ui_change(); }); }, set_value: function(value) { if (value) { - this.$element.find("input").attr('checked', true); + this.$element.find("input[id=" + this.name+ "]").attr('checked', true); } }, get_value: function() { - return this.$element.find("input").is(':checked') || null; + return this.$element.find("input[id=" + this.name + "]").is(':checked') || null; } }); openerp.web.ViewEditor.FieldChar = openerp.web.ViewEditor.Field.extend({ @@ -764,15 +763,15 @@ openerp.web.ViewEditor.FieldChar = openerp.web.ViewEditor.Field.extend({ start: function () { var self = this; this._super(); - this.$element.find("input").css('width','100%').change(function() { + this.$element.find("input[id="+ this.name+"]").css('width','100%').change(function() { self.on_ui_change(); }); }, set_value: function(value) { - this.$element.find("input").val(value); + this.$element.find("input[id=" + this.name + "]").val(value); }, get_value: function() { - return this.$element.find("input").val(); + return this.$element.find("input[id=" + this.name + "]").val(); } }); openerp.web.ViewEditor.FieldSelect = openerp.web.ViewEditor.Field.extend({ @@ -784,7 +783,7 @@ openerp.web.ViewEditor.FieldSelect = openerp.web.ViewEditor.Field.extend({ start: function () { var self = this; this._super(); - this.$element.find("select").css('width', '100%').change(function() { + this.$element.find("select[id=" + this.name + "]").css('width', '100%').change(function() { self.on_ui_change(); }); }, @@ -794,10 +793,10 @@ openerp.web.ViewEditor.FieldSelect = openerp.web.ViewEditor.Field.extend({ for (var i = 0, ii = this.selection.length; i < ii; i++) { if ((this.selection[i] instanceof Array && this.selection[i][1] === value) || this.selection[i] === value) index = i; } - this.$element.find("select")[0].selectedIndex = index; + this.$element.find("select[id=" + this.name + "]")[0].selectedIndex = index; }, get_value: function() { - return this.$element.find("select").val(); + return this.$element.find("select[id=" + this.name + "]").val(); } }); openerp.web.ViewEditor.WidgetProperty = openerp.web.ViewEditor.FieldSelect.extend({ @@ -857,7 +856,7 @@ openerp.web.ViewEditor.GroupsProperty = openerp.web.ViewEditor.FieldSelect.exten if (!value) return false; _.each(this.selection, function(item) { if (_.include(value.split(','), item[0])) { - self.$element.find("select option[value='" + item[0] +"']").attr("selected",1) + self.$element.find("select[id="+self.name+"] option[value='" + item[0] +"']").attr("selected",1) } }); } From 322bbae26a4d01671ca4d2eaa27e250c5203a80b Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 15 Nov 2011 14:46:15 +0530 Subject: [PATCH 112/278] [IMP] vieweditor :- add selection and value attribute on properties attribute and render attributes bzr revid: ysa@tinyerp.com-20111115091615-w6v2wq3acf5twm6s --- addons/web/static/src/js/view_editor.js | 164 ++++++++---------------- 1 file changed, 54 insertions(+), 110 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index eb0cceb387e..c45d5eed4da 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -651,24 +651,61 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }); this.edit_node_dialog.start().open(); + var _PROPERTIES_ATTRIBUTES = { + 'name' : {'string': 'Name', 'type': 'char'}, + 'string' : {'string': 'String', 'type': 'char'}, + 'required' : {'string': 'Required', 'type': 'boolean'}, + 'readonly' : {'string': 'Readonly', 'type': 'boolean'}, + 'domain' : {'string': 'Domain', 'type': 'char'}, + 'context' : {'string': 'Context', 'type': 'char'}, + 'limit' : {'string': 'Limit', 'type': 'char'}, + 'min_rows' : {'string': 'Minimum rows', 'type': 'char'}, + 'date_start' : {'string': 'Start date', 'type': 'char'}, + 'date_delay' : {'string': 'Delay date', 'type': 'char'}, + 'day_length' : {'string': 'Day length', 'type': 'char'}, + 'mode' : {'string': 'Mode', 'type': 'char'}, + 'align' : {'string': 'Alignment ', 'type': 'selection', 'selection': [['', ''], ['0.0', 'Left'], ['0.5', 'Center'], ['1.0', 'Right']]}, + 'icon' : {'string': 'Icon', 'type': 'selection', 'selection': _ICONS}, + 'type' : {'string': 'Type', 'type': 'selection', 'selection': [['', ''], ['action', 'Action'], ['object', 'Object'], ['workflow', 'Workflow'], ['server_action', 'Server Action']]}, + 'special' : {'string': 'Special', 'type': 'selection', 'selection': [['',''],['save', 'Save Button'], ['cancel', 'Cancel Button'], ['open', 'Open Button']]}, + 'target' : {'string': 'Target', 'type': 'selection', 'selection': [['', ''], ['new', 'New Window']]}, + 'confirm' : {'string': 'Confirm', 'type': 'char'}, + 'style' : {'string': 'Style', 'type': 'selection', 'selection':[["",""],["1", "1"],["1-1", "1-1"],["1-2", "1-2"],["2-1", "2-1"],["1-1-1", "1-1-1"]]}, + 'filename' : {'string': 'File Name', 'type': 'char'}, + 'width' : {'string': 'Width', 'type': 'char'}, + 'height' : {'string': 'Height', 'type': 'char'}, + 'attrs' : {'string': 'Attrs', 'type': 'char'}, + 'col' : {'string': 'col', 'type': 'char'}, + 'link' : {'string': 'Link', 'type': 'char'}, + 'position' : {'string': 'Position', 'type': 'selection', 'selection': [['',''],['after', 'After'],['before', 'Before'],['inside', 'Inside'],['replace', 'Replace']]}, + 'states' : {'string': 'states', 'type': 'char'}, + 'eval' : {'string': 'Eval', 'type': 'char'}, + 'ref' : {'string': 'Ref', 'type': 'char'}, + 'on_change' : {'string': 'On change', 'type': 'char'}, + 'nolabel' : {'string': 'No label', 'type': 'boolean'}, + 'completion' : {'string': 'Completion', 'type': 'boolean'}, + 'colspan' : {'string': 'Colspan', 'type': 'char'}, + 'widget' : {'string': 'widget', 'type': 'selection'}, + 'groups' : {'string': 'Groups', 'type': 'seleciton_multi'}, + }; var widget = _.keys(self.property.map); var arch_val = self.get_object_by_id(clicked_tr_id,obj['main_object'], []); this.edit_node_dialog.$element.append('
'); this.edit_widget = []; - _.each(properties, function(property) { - type_widget = false; - self.ready = $.when(self.on_groups(property)).then(function () { - if (_.include(widget, property)){ - type_widget = new (self.property.get_any([property])) (self.edit_node_dialog, property); - } else { - type_widget = new openerp.web.ViewEditor.FieldChar (self.edit_node_dialog, property); - } + self.ready = $.when(self.on_groups(properties)).then(function () { + _PROPERTIES_ATTRIBUTES['groups']['selection'] = self.groups; + var values = _.keys( openerp.web.form.widgets.map); + values.push(''); + values.sort(); + _PROPERTIES_ATTRIBUTES['widget']['selection'] = values; + _.each(properties, function(property) { + var type_widget = new (self.property.get_any([_PROPERTIES_ATTRIBUTES[property].type])) (self.edit_node_dialog, property); var value = _.detect(arch_val[0]['att_list'],function(res) { return _.include(res, property); }); + type_widget.selection = _PROPERTIES_ATTRIBUTES[property].selection value = value instanceof Array ? value[1] : value; - if (property == 'groups') type_widget.selection = self.groups; - self.edit_node_dialog.$element.find('table[id=rec_table]').append('' + property + ':' + type_widget.render() + ''); + self.edit_node_dialog.$element.find('table[id=rec_table]').append('' + _PROPERTIES_ATTRIBUTES[property].string + ':' + type_widget.render() + ''); type_widget.start(); type_widget.set_value(value) self.edit_widget.push(type_widget); @@ -676,12 +713,12 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); }, //for getting groups - on_groups: function(property){ + on_groups: function(properties){ var self = this, def = $.Deferred(); - if (property != 'groups') { + if (!_.include(properties, 'groups')) { self.groups = false; - return false; + def.resolve(); } var group_ids = [], group_names = {}, @@ -800,53 +837,7 @@ openerp.web.ViewEditor.FieldSelect = openerp.web.ViewEditor.Field.extend({ return this.$element.find("select").val(); } }); -openerp.web.ViewEditor.WidgetProperty = openerp.web.ViewEditor.FieldSelect.extend({ - init: function(view, name) { - this._super(view, name); - this.registry = openerp.web.form.widgets; - var values = _.keys(this.registry.map); - values.push(''); - values.sort(); - this.selection = values; - }, -}); -openerp.web.ViewEditor.IconProperty = openerp.web.ViewEditor.FieldSelect.extend({ - init: function(view, name) { - this._super(view, name); - this.selection = _ICONS; - }, -}); -openerp.web.ViewEditor.ButtonTargetProperty = openerp.web.ViewEditor.FieldSelect.extend({ - init: function(view, name) { - this._super(view, name); - this.selection = [['', ''], ['new', 'New Window']]; - }, -}); -openerp.web.ViewEditor.ButtonTypeProperty = openerp.web.ViewEditor.FieldSelect.extend({ - init: function(view, name) { - this._super(view, name); - this.selection = [['', ''], ['action', 'Action'], ['object', 'Object'], ['workflow', 'Workflow'], ['server_action', 'Server Action']]; - }, -}); -openerp.web.ViewEditor.AlignProperty = openerp.web.ViewEditor.FieldSelect.extend({ - init: function(view, name) { - this._super(view, name); - this.selection = [['', ''], ['0.0', 'Left'], ['0.5', 'Center'], ['1.0', 'Right']]; - }, -}); -openerp.web.ViewEditor.ButtonSpecialProperty = openerp.web.ViewEditor.FieldSelect.extend({ - init: function(view, name) { - this._super(view, name); - this.selection = [['',''],['save', 'Save Button'], ['cancel', 'Cancel Button'], ['open', 'Open Button']]; - }, -}); -openerp.web.ViewEditor.PositionProperty = openerp.web.ViewEditor.FieldSelect.extend({ - init: function(view, name) { - this._super(view, name); - this.selection = [['',''],['after', 'After'],['before', 'Before'],['inside', 'Inside'],['replace', 'Replace']]; - }, -}); -openerp.web.ViewEditor.GroupsProperty = openerp.web.ViewEditor.FieldSelect.extend({ +openerp.web.ViewEditor.FieldSelectMulti = openerp.web.ViewEditor.FieldSelect.extend({ start: function () { this._super(); this.$element.find("select[id=" + this.name + "]").css('height', '100px').attr("multiple",true); @@ -864,7 +855,7 @@ openerp.web.ViewEditor.GroupsProperty = openerp.web.ViewEditor.FieldSelect.exten }); var _PROPERTIES = { 'field' : ['name', 'string', 'required', 'readonly', 'domain', 'context', 'nolabel', 'completion', - 'colspan', 'widget', 'eval', 'ref', 'on_change', 'groups', 'attrs'], + 'colspan', 'widget', 'eval', 'ref', 'on_change', 'attrs', 'groups'], 'form' : ['string', 'col', 'link'], 'notebook' : ['colspan', 'position', 'groups'], 'page' : ['string', 'states', 'attrs', 'groups'], @@ -881,43 +872,6 @@ var _PROPERTIES = { 'graph' : ['string', 'type'], 'calendar' : ['string', 'date_start', 'date_stop', 'date_delay', 'day_length', 'color', 'mode'], }; -var _PROPERTIES_ATTRIBUTES = { - 'name' : {'string': 'Name', 'type': 'char'}, - 'string' : {'string': 'String', 'type': 'char'}, - 'required' : {'string': 'Required', 'type': 'boolean'}, - 'readonly' : {'string': 'Readonly', 'type': 'boolean'}, - 'domain' : {'string': 'Domain', 'type': 'char'}, - 'context' : {'string': 'Context', 'type': 'char'}, - 'limit' : {'string': 'Limit', 'type': 'selection'}, - 'min_rows' : {'string': 'Minimum rows', 'type': 'char'}, - 'date_start' : {'string': 'Start date', 'type': 'char'}, - 'date_delay' : {'string': 'Delay date', 'type': 'char'}, - 'day_length' : {'string': 'Day length', 'type': 'char'}, - 'mode' : {'string': 'Mode', 'type': 'char'}, - 'align' : {'string': 'Alignment ', 'type': 'selection'}, - 'icon' : {'string': 'Icon', 'type': 'selection'}, - 'type' : {'string': 'Type', 'type': 'selection'}, - 'special' : {'string': 'Special', 'type': 'selection'}, - 'target' : {'string': 'Target', 'type': 'selection'}, - 'confirm' : {'string': 'Confirm', 'type': 'char'}, - 'style' : {'string': 'Style', 'type': 'selection'}, - 'filename' : {'string': 'File Name', 'type': 'char'}, - 'width' : {'string': 'Width', 'type': 'char'}, - 'height' : {'string': 'Height', 'type': 'char'}, - 'groups' : {'string': 'Groups', 'type': 'seleciton_multi'}, - 'attrs' : {'string': 'Attrs', 'type': 'char'}, - 'col' : {'string': 'col', 'type': 'char'}, - 'link' : {'string': 'Link', 'type': 'char'}, - 'position' : {'string': 'Position', 'type': 'selection'}, - 'states' : {'string': 'states', 'type': 'char'}, - 'eval' : {'string': 'Eval', 'type': 'char'}, - 'ref' : {'string': 'Ref', 'type': 'char'}, - 'on_change' : {'string': 'On change', 'type': 'char'}, - 'nolabel' : {'string': 'No label', 'type': 'boolean'}, - 'completion' : {'string': 'Completion', 'type': 'boolean'}, - 'colspan' : {'string': 'Colspan', 'type': 'char'}, - 'widget' : {'string': 'widget', 'type': 'selection'}, -}; var _ICONS = ['','STOCK_ABOUT', 'STOCK_ADD', 'STOCK_APPLY', 'STOCK_BOLD', 'STOCK_CANCEL', 'STOCK_CDROM', 'STOCK_CLEAR', 'STOCK_CLOSE', 'STOCK_COLOR_PICKER', 'STOCK_CONNECT', 'STOCK_CONVERT', 'STOCK_COPY', 'STOCK_CUT', 'STOCK_DELETE', @@ -946,18 +900,8 @@ var _ICONS = ['','STOCK_ABOUT', 'STOCK_ADD', 'STOCK_APPLY', 'STOCK_BOLD', 'terp-project', 'terp-report', 'terp-stock', 'terp-calendar', 'terp-graph' ]; openerp.web.ViewEditor.property_widget = new openerp.web.Registry({ - 'required' : 'openerp.web.ViewEditor.FieldBoolean', - 'readonly' : 'openerp.web.ViewEditor.FieldBoolean', - 'nolabel' : 'openerp.web.ViewEditor.FieldBoolean', - 'completion' : 'openerp.web.ViewEditor.FieldBoolean', - 'widget' : 'openerp.web.ViewEditor.WidgetProperty', - 'groups' : 'openerp.web.ViewEditor.GroupsProperty', - 'position' : 'openerp.web.ViewEditor.PositionProperty', - 'icon' : 'openerp.web.ViewEditor.IconProperty', - 'align' : 'openerp.web.ViewEditor.AlignProperty', - 'special' : 'openerp.web.ViewEditor.ButtonSpecialProperty', - 'type' : 'openerp.web.ViewEditor.ButtonTypeProperty', - 'target' : 'openerp.web.ViewEditor.ButtonTargetProperty', + 'boolean' : 'openerp.web.ViewEditor.FieldBoolean', + 'seleciton_multi' : 'openerp.web.ViewEditor.FieldSelectMulti', 'selection' : 'openerp.web.ViewEditor.FieldSelect', 'char' : 'openerp.web.ViewEditor.FieldChar', }); From b1f0df7418d25ea2a5e365dbbc637ae66bab5c9f Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 15 Nov 2011 16:15:39 +0530 Subject: [PATCH 113/278] [IMP] Vieweditor:- implement functionality of floatwidget. bzr revid: ysa@tinyerp.com-20111115104539-418py0oj656q1gr5 --- addons/web/static/src/js/view_editor.js | 68 +++++++++++++++++-------- 1 file changed, 47 insertions(+), 21 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index c45d5eed4da..5a789856678 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -85,11 +85,11 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var view_values = {}; var warn = false; _.each(self.create_view_widget, function(widget) { - if (widget.invalid) { + if (widget.is_invalid) { warn = true; return false; }; - if (widget.dirty && !widget.invalid) { + if (widget.dirty && !widget.is_invalid) { view_values[widget.name] = widget.get_value(); } }); @@ -111,7 +111,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ this.create_view_dialog.start().open(); var view_widget = [{'name': 'view_name', 'string':'View Name', 'type': 'char', 'required': true, 'value' : this.model + '.custom_' + Math.round(Math.random() * 1000)}, {'name': 'view_type', 'string': 'View Type', 'type': 'selection', 'required': true, 'value': 'Form', 'selection': [['',''],['tree', 'Tree'],['form', 'Form'],['graph', 'Graph'],['calendar', 'Calender']]}, - {'name': 'proirity', 'string': 'Priority', 'type': 'char', 'required': true, 'value':'16'}]; + {'name': 'proirity', 'string': 'Priority', 'type': 'float', 'required': true, 'value':'16'}]; this.create_view_dialog.$element.append('
'); this.create_view_widget = []; _.each(view_widget, function(widget) { @@ -120,6 +120,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ type_widget.selection = widget.selection; } type_widget.required = widget.required; + type_widget.type = widget.type; self.create_view_dialog.$element.find('table[id=create_view]').append('' + widget.string + ':' + type_widget.render()+''); var value = null; if (widget.value) { @@ -159,12 +160,12 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ on_valid_create_view: function() { var msg = "
    "; _.each(self.create_view_widget, function(widget) { - if (widget.invalid) { + if (widget.is_invalid) { msg += "
  • " + widget.name + "
  • "; } }); msg += "
"; - self.do_warn("The following fields are invalid :", msg); + this.do_warn("The following fields are invalid :", msg); }, add_node_name : function(node) { if(node.tagName.toLowerCase() == "button" || node.tagName.toLowerCase() == "field"){ @@ -636,14 +637,23 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ height: 400, buttons: { "Update": function(){ + var warn = false; var update_values = []; _.each(self.edit_widget, function(widget) { - if (widget.dirty && !widget.invalid) { + if (widget.is_invalid) { + warn = true; + return false; + }; + if (widget.dirty && !widget.is_invalid) { update_values.push([widget.name, widget.get_value()]); } }); - self.do_save_update_arch(obj, view_id, view_xml_id, clicked_tr_id, clicked_tr_level, "update_node", update_values); - self.edit_node_dialog.close(); + if (warn) { + self.on_valid_create_view(); + } else { + self.do_save_update_arch(obj, view_id, view_xml_id, clicked_tr_id, clicked_tr_level, "update_node", update_values); + self.edit_node_dialog.close(); + } }, "Cancel": function(){ self.edit_node_dialog.close(); @@ -658,8 +668,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ 'readonly' : {'string': 'Readonly', 'type': 'boolean'}, 'domain' : {'string': 'Domain', 'type': 'char'}, 'context' : {'string': 'Context', 'type': 'char'}, - 'limit' : {'string': 'Limit', 'type': 'char'}, - 'min_rows' : {'string': 'Minimum rows', 'type': 'char'}, + 'limit' : {'string': 'Limit', 'type': 'float'}, + 'min_rows' : {'string': 'Minimum rows', 'type': 'float'}, 'date_start' : {'string': 'Start date', 'type': 'char'}, 'date_delay' : {'string': 'Delay date', 'type': 'char'}, 'day_length' : {'string': 'Day length', 'type': 'char'}, @@ -672,10 +682,10 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ 'confirm' : {'string': 'Confirm', 'type': 'char'}, 'style' : {'string': 'Style', 'type': 'selection', 'selection':[["",""],["1", "1"],["1-1", "1-1"],["1-2", "1-2"],["2-1", "2-1"],["1-1-1", "1-1-1"]]}, 'filename' : {'string': 'File Name', 'type': 'char'}, - 'width' : {'string': 'Width', 'type': 'char'}, - 'height' : {'string': 'Height', 'type': 'char'}, + 'width' : {'string': 'Width', 'type': 'float'}, + 'height' : {'string': 'Height', 'type': 'float'}, 'attrs' : {'string': 'Attrs', 'type': 'char'}, - 'col' : {'string': 'col', 'type': 'char'}, + 'col' : {'string': 'col', 'type': 'float'}, 'link' : {'string': 'Link', 'type': 'char'}, 'position' : {'string': 'Position', 'type': 'selection', 'selection': [['',''],['after', 'After'],['before', 'Before'],['inside', 'Inside'],['replace', 'Replace']]}, 'states' : {'string': 'states', 'type': 'char'}, @@ -684,8 +694,10 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ 'on_change' : {'string': 'On change', 'type': 'char'}, 'nolabel' : {'string': 'No label', 'type': 'boolean'}, 'completion' : {'string': 'Completion', 'type': 'boolean'}, - 'colspan' : {'string': 'Colspan', 'type': 'char'}, + 'colspan' : {'string': 'Colspan', 'type': 'float'}, 'widget' : {'string': 'widget', 'type': 'selection'}, + 'colors' : {'string': 'Colors', 'type': 'char'}, + 'editable' : {'string': 'Editable', 'type': 'selection', 'selection': [["",""],["top","Top"],["bottom", "Bottom"]]}, 'groups' : {'string': 'Groups', 'type': 'seleciton_multi'}, }; var widget = _.keys(self.property.map); @@ -704,6 +716,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ return _.include(res, property); }); type_widget.selection = _PROPERTIES_ATTRIBUTES[property].selection + type_widget.type = _PROPERTIES_ATTRIBUTES[property].type value = value instanceof Array ? value[1] : value; self.edit_node_dialog.$element.find('table[id=rec_table]').append('' + _PROPERTIES_ATTRIBUTES[property].string + ':' + type_widget.render() + ''); type_widget.start(); @@ -752,27 +765,36 @@ openerp.web.ViewEditor.Field = openerp.web.Class.extend({ this.dirty = false; this.name = name; this.required = false; - this.invalid = false; + this.is_invalid = false; }, start: function () { this.$element = this.$element.find("td[id="+ this.name+"]"); this.update_dom(); }, update_dom: function() { - this.$element.toggleClass('invalid', this.invalid); + this.$element.toggleClass('invalid', this.is_invalid); this.$element.toggleClass('required', this.required); }, on_ui_change: function() { + this.validate(); var value = this.get_value(); - value = value instanceof Array ? value[1] : value; - if (this.required && !value) { - this.invalid = true; + if (this.is_invalid) { + this.is_invalid = true; } else { - this.invalid = false; + this.is_invalid = false; } this.dirty = true; this.update_dom(); }, + validate: function() { + this.is_invalid = false; + try { + var value = openerp.web.parse_value(this.get_value(), this, ''); + this.is_invalid = this.required && value === ''; + } catch(e) { + this.is_invalid = true; + } + }, render: function() { return _.sprintf("%s", this.name, QWeb.render(this.template, {widget: this})) }, @@ -785,7 +807,6 @@ openerp.web.ViewEditor.FieldBoolean = openerp.web.ViewEditor.Field.extend({ this.$element.find("input").change(function() { self.on_ui_change(); }); - }, set_value: function(value) { if (value) { @@ -853,6 +874,10 @@ openerp.web.ViewEditor.FieldSelectMulti = openerp.web.ViewEditor.FieldSelect.ext }); } }); +openerp.web.ViewEditor.FieldFloat = openerp.web.ViewEditor.FieldChar.extend({ + +}); + var _PROPERTIES = { 'field' : ['name', 'string', 'required', 'readonly', 'domain', 'context', 'nolabel', 'completion', 'colspan', 'widget', 'eval', 'ref', 'on_change', 'attrs', 'groups'], @@ -904,5 +929,6 @@ openerp.web.ViewEditor.property_widget = new openerp.web.Registry({ 'seleciton_multi' : 'openerp.web.ViewEditor.FieldSelectMulti', 'selection' : 'openerp.web.ViewEditor.FieldSelect', 'char' : 'openerp.web.ViewEditor.FieldChar', + 'float' : 'openerp.web.ViewEditor.FieldFloat', }); }; From a42aeec255b27ab34dbc6533c2be8ca8c27dedcf Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 15 Nov 2011 16:22:03 +0530 Subject: [PATCH 114/278] [IMP] vieweidtor :- improve warning method. bzr revid: ysa@tinyerp.com-20111115105203-umsohg7hz8evuh79 --- addons/web/static/src/js/view_editor.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 5a789856678..5c576b2267d 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -94,7 +94,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }); if (warn) { - self.on_valid_create_view(); + self.on_valid_create_view(self.create_view_widget); } else { $.when(self.do_save_view(view_values)).then(function() { self.create_view_dialog.close(); @@ -157,9 +157,9 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); return def.promise(); }, - on_valid_create_view: function() { + on_valid_create_view: function(widgets) { var msg = "
    "; - _.each(self.create_view_widget, function(widget) { + _.each(widgets, function(widget) { if (widget.is_invalid) { msg += "
  • " + widget.name + "
  • "; } @@ -649,7 +649,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }); if (warn) { - self.on_valid_create_view(); + self.on_valid_create_view(self.edit_widget); } else { self.do_save_update_arch(obj, view_id, view_xml_id, clicked_tr_id, clicked_tr_level, "update_node", update_values); self.edit_node_dialog.close(); From 8ec52797ad2b63c900087506cf945d6aaeb792d9 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 15 Nov 2011 16:51:19 +0530 Subject: [PATCH 115/278] [IMP] Vieweditor :- improve on_ui_change method. bzr revid: ysa@tinyerp.com-20111115112119-vopxmyqheoyci7vu --- addons/web/static/src/js/view_editor.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index fcfe7e5bd34..f023db74bbd 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -776,12 +776,6 @@ openerp.web.ViewEditor.Field = openerp.web.Class.extend({ }, on_ui_change: function() { this.validate(); - var value = this.get_value(); - if (this.is_invalid) { - this.is_invalid = true; - } else { - this.is_invalid = false; - } this.dirty = true; this.update_dom(); }, From 915ec137ab90a38caaea81eb808345640aff891d Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Tue, 15 Nov 2011 17:44:34 +0530 Subject: [PATCH 116/278] [IMP] implement code for remove element in view editor. bzr revid: vme@tinyerp.com-20111115121434-u0x8pf6nf9clcp6r --- addons/web/static/src/js/view_editor.js | 35 ++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 4dc4eab5301..9f89ac0314b 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -459,6 +459,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); break; case "side-remove": + self.do_save_update_arch + (one_object, view_id, view_xml_id, clicked_tr_id, clicked_tr_level, "remove_node"); break; case "side-edit": var tr = $(this).closest("tr[id^='viewedit-']").find('a').text(); @@ -591,11 +593,13 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ $(next).after(arch1); var re_insert_obj = child_list.splice(index, 1); child_list.splice(index+1, 0, re_insert_obj[0]); + var parent = $(arch1).parents(); } else if (move_direct == "up") { var prev = $(arch1).prev(); $(prev).before(arch1); var re_insert_obj = child_list.splice(index, 1); child_list.splice(index-1, 0, re_insert_obj[0]); + var parent = $(arch1).parents(); } else if (move_direct == "update_node") { _.each(update_values, function(val){ if(val[0] == "required"){ @@ -608,6 +612,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ new_obj.id = obj.id,new_obj.child_id = obj.child_id; self.edit_xml_dialog.$element.find("tr[id='viewedit-"+id+"']").find('a').text(new_obj.name); child_list.splice(index, 1, new_obj); + var parent = $(arch1).parents(); }else if(move_direct == "add_node"){ switch (update_values[1]) { case "After": @@ -620,8 +625,17 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ $(arch1).append(update_values[0]); break; } + var parent = $(arch1).parents(); + }else if(move_direct == "remove_node"){ + var parent = $(arch1).parents(); + $(arch1).remove(); + child_list.splice(index,1); + var cur_tr = self.edit_xml_dialog.$element.find("tr[id='viewedit-"+id+"']"); + _.each(self.get_list_tr(cur_tr,obj.level), function(tr_element){ + tr_element.remove(); + }); + cur_tr.remove(); } - var parent = $(arch1).parents(); var convert_to_utf = (parent.length != 0)?parent[parent.length-1]:arch1; convert_to_utf = QWeb.tools.xml_node_to_string(convert_to_utf); convert_to_utf = convert_to_utf.replace('xmlns="http://www.w3.org/1999/xhtml"', ""); @@ -645,12 +659,18 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ on_expand: function(expand_img){ var level = parseInt($(expand_img).closest("tr[id^='viewedit-']").attr('level')); var cur_tr = $(expand_img).closest("tr[id^='viewedit-']"); + _.each(this.get_list_tr(cur_tr,level), function(tr_element){ + tr_element.hide(); + }); + }, + get_list_tr: function(cur_tr,level){ + tr_list = []; while (1) { var nxt_tr = cur_tr.next(); if (parseInt(nxt_tr.attr('level')) > level) { cur_tr = nxt_tr; - nxt_tr.hide(); - } else return nxt_tr; + tr_list.push(nxt_tr); + } else return tr_list; } }, on_collapse: function(collapse_img, parent_child_id, id, main_object) { @@ -807,7 +827,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }, render_new_field :function(id){ var action = { - context: {'default_model_id':id, 'manual':true},//self.session.user_context, + context: {'default_model_id':id, 'manual':true}, res_model: "ir.model.fields", views: [[false, 'form']], type: 'ir.actions.act_window', @@ -818,6 +838,13 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } var action_manager = new openerp.web.ActionManager(self); action_manager.do_action(action); + $.when(action_manager.do_action(action)).then(function() { + var add_controller = action_manager.dialog_viewmanager.views['form'].controller; + add_controller.do_set_readonly.add_last(function(){ + var aa = controller; + }); + }); + } }); openerp.web.ViewEditor.Field = openerp.web.Class.extend({ From eb36286eea84432f21393512e1ce60e792ab889c Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Wed, 16 Nov 2011 12:10:50 +0530 Subject: [PATCH 117/278] [IMP]:added Doc string bzr revid: nch@tinyerp.com-20111116064050-cve3d7pcx8pdrsv0 --- addons/audittrail/audittrail.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index b82d22f5450..3d7bf8587f7 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -179,7 +179,16 @@ class audittrail_objects_proxy(object_proxy): If the field is a many2one, it returns the name. If it's a one2many or a many2many, it returns a list of name. In other cases, it just returns the value. + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param pool: current db's pooler object. + @param resource_pool: pooler object of the model who's values are being changed. + @param field: for which the text value is to be returned. + @param value: value of the field. + @param recursive: True or False, True will repeat the process recursively + @return: string value or a list of values(for O2M/M2M) """ + field_obj = (resource_pool._all_columns.get(field)).column if field_obj._type in ('one2many','many2many'): if recursive: @@ -232,6 +241,18 @@ class audittrail_objects_proxy(object_proxy): return True def start_log_process(self, cr, user_id, model, method, resource_data, pool, resource_pool): + """ + Logging function: This function performs the logging operation for create/read/unlink operation + :@param cr: the current row, from the database cursor, + :@param user_id: the current user’s ID, + :param model: Object which values are being changed + :param method: method to log: create, read, unlink + :param resource_data: list of data modified for the model + :@param pool: current db's pooler object. + :@param resource_pool: pooler object of the model who's values are being changed. + :return:True + + """ key1 = '%s_value'%(method == 'create' and 'new' or 'old') key2 = '%s_value_text'%(method == 'create' and 'new' or 'old') uid = 1 From 5ed7d8a8c262cb32a127c92b8b754d36128f5f16 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 16 Nov 2011 13:14:41 +0530 Subject: [PATCH 118/278] [IMP]improve code for remove view in remove node functionality. bzr revid: vme@tinyerp.com-20111116074441-eduxxr9o2ceno92h --- addons/web/static/src/js/view_editor.js | 57 ++++++++++++++++--------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 9f89ac0314b..b4ca58eb8ee 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -415,7 +415,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); this.edit_xml_dialog.$element.find("img[id^='side-']").click(function() { var side = $(this).closest("tr[id^='viewedit-']"); - var clicked_tr_id = (side.attr('id')).split('-')[1]; + var clicked_tr_id = parseInt((side.attr('id')).split('-')[1]); var img = side.find("img[id='parentimg-" + clicked_tr_id + "']").attr('src'); var clicked_tr_level = parseInt(side.attr('level')); var cur_tr = side; @@ -427,16 +427,24 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var view_xml_id; var view_find = side; var min_level = clicked_tr_level; - while (1) { - view_find = view_find.prev(); - if ((self.edit_xml_dialog.$element.find(view_find).find('a').text()).search("view_id") != -1 - && parseInt(view_find.attr('level')) < min_level ) { - view_id = parseInt(($(view_find).find('a').text()).replace(/[^0-9]+/g, '')); - view_xml_id = (view_find.attr('id')).split('-')[1]; - break; - } - if(view_find.attr('level') < min_level){ - min_level = parseInt(view_find.attr('level')); + if(($(side).find('a').text()).search("view_id") != -1){ + view_id = parseInt(($(view_find).find('a').text()).replace(/[^0-9]+/g, '')); + view_xml_id = (view_find.attr('id')).split('-')[1]; + clicked_tr_id += 1; + clicked_tr_level += 1; + }else{ + while (1) { + view_find = view_find.prev(); + if (view_find.length == 0 || + (self.edit_xml_dialog.$element.find(view_find).find('a').text()).search("view_id") != -1 + && parseInt(view_find.attr('level')) < min_level ) { + view_id = parseInt(($(view_find).find('a').text()).replace(/[^0-9]+/g, '')); + view_xml_id = (view_find.attr('id')).split('-')[1]; + break; + } + if(view_find.attr('level') < min_level){ + min_level = parseInt(view_find.attr('level')); + } } } switch (this.id) { @@ -563,6 +571,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ arch_to_pass = _.filter($(arch.arch), function (child) { return child.nodeType == 1; }); + return self.do_save_xml(arch_to_pass[0], obj[0].child_id[0], parseInt(clicked_tr_id), [], parseInt(clicked_tr_level), parseInt(view_id), arch, move_direct, update_values); @@ -628,21 +637,31 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var parent = $(arch1).parents(); }else if(move_direct == "remove_node"){ var parent = $(arch1).parents(); + if(parent.length == 0 || (parent[0].tagName.toLowerCase() == "data")){ + id = id -1; + level = level - 1; + (parent.length == 0)?parent.push("remove_view"):false; + } $(arch1).remove(); child_list.splice(index,1); - var cur_tr = self.edit_xml_dialog.$element.find("tr[id='viewedit-"+id+"']"); - _.each(self.get_list_tr(cur_tr,obj.level), function(tr_element){ + var cur_tr = self.edit_xml_dialog.$element.find("tr[id='viewedit-"+id +"']"); + _.each(self.get_list_tr(cur_tr,level), function(tr_element){ tr_element.remove(); }); cur_tr.remove(); } var convert_to_utf = (parent.length != 0)?parent[parent.length-1]:arch1; - convert_to_utf = QWeb.tools.xml_node_to_string(convert_to_utf); - convert_to_utf = convert_to_utf.replace('xmlns="http://www.w3.org/1999/xhtml"', ""); - convert_to_utf = '' + convert_to_utf; - arch.arch = convert_to_utf; - this.dataset.write(parseInt(view_id),{"arch":convert_to_utf}, function(r) { - }); + if(convert_to_utf != "remove_view"){ + convert_to_utf = QWeb.tools.xml_node_to_string(convert_to_utf); + convert_to_utf = convert_to_utf.replace('xmlns="http://www.w3.org/1999/xhtml"', ""); + convert_to_utf = '' + convert_to_utf; + arch.arch = convert_to_utf; + /*this.dataset.write(parseInt(view_id),{"arch":convert_to_utf}, function(r) { + });*/ + }else{ + /*this.dataset.unlink([parseInt(view_id)],function(res) { + });*/ + } if(move_direct == "add_node"){ self.add_node_dialog.close(); self.edit_xml_dialog.close(); From d9d16da37b151c19f069761be3151dcc2c27b267 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Wed, 16 Nov 2011 14:33:32 +0530 Subject: [PATCH 119/278] [IMP] Vieweditor :- improve code . bzr revid: ysa@tinyerp.com-20111116090332-jol5v8k7ahq5nhuu --- addons/web/static/src/js/view_editor.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index f023db74bbd..fbdaa6ed7de 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -376,7 +376,15 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ height: 500, buttons: { "Inherited View": function() { - //todo + var selected_row = self.edit_xml_dialog.$element.find('.ui-selected'); + if (selected_row.length) { + var xml_arch = QWeb.load_xml(selected_row.find('a').text()); + var tag_name = xml_arch.childNodes? xml_arch.childNodes[0].tagName: ""; + console.log(" xml_arch.childNodes[0]::::", xml_arch.childNodes[0].getAttribute()); + if (tag_name == 'field') { + return true; + } + } }, "Preview": function() { var action = { @@ -700,7 +708,6 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ 'editable' : {'string': 'Editable', 'type': 'selection', 'selection': [["",""],["top","Top"],["bottom", "Bottom"]]}, 'groups' : {'string': 'Groups', 'type': 'seleciton_multi'}, }; - var widget = _.keys(self.property.map); var arch_val = self.get_object_by_id(clicked_tr_id,obj['main_object'], []); this.edit_node_dialog.$element.append('
    '); this.edit_widget = []; @@ -746,7 +753,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ group_names[key]=res.name; group_ids.push(res.id); }); - model_data + model_data .read_slice([],{domain:[['res_id', 'in', group_ids],['model','=','res.groups']]}) .done(function(model_grp) { _.each(model_grp,function(res_group){ @@ -807,7 +814,8 @@ openerp.web.ViewEditor.FieldBoolean = openerp.web.ViewEditor.Field.extend({ } }, get_value: function() { - return this.$element.find("input[id=" + this.name + "]").is(':checked') || null; + var value = this.$element.find("input[id=" + this.name + "]").is(':checked') + return value? "1" : null; } }); openerp.web.ViewEditor.FieldChar = openerp.web.ViewEditor.Field.extend({ From a03506d84a45429dcfade2e33625dcadd0a554ad Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 16 Nov 2011 14:34:21 +0530 Subject: [PATCH 120/278] [IMP]improve code in view editor. bzr revid: vme@tinyerp.com-20111116090421-qri7wmviyiygoxlo --- addons/web/static/src/js/view_editor.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index b4ca58eb8ee..77d61a2d228 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -467,8 +467,10 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); break; case "side-remove": - self.do_save_update_arch - (one_object, view_id, view_xml_id, clicked_tr_id, clicked_tr_level, "remove_node"); + if (confirm(_t("Do you really want to remove this node?"))) { + self.do_save_update_arch + (one_object, view_id, view_xml_id, clicked_tr_id, clicked_tr_level, "remove_node"); + } break; case "side-edit": var tr = $(this).closest("tr[id^='viewedit-']").find('a').text(); @@ -656,11 +658,11 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ convert_to_utf = convert_to_utf.replace('xmlns="http://www.w3.org/1999/xhtml"', ""); convert_to_utf = '' + convert_to_utf; arch.arch = convert_to_utf; - /*this.dataset.write(parseInt(view_id),{"arch":convert_to_utf}, function(r) { - });*/ + this.dataset.write(parseInt(view_id),{"arch":convert_to_utf}, function(r) { + }); }else{ - /*this.dataset.unlink([parseInt(view_id)],function(res) { - });*/ + this.dataset.unlink([parseInt(view_id)],function(res) { + }); } if(move_direct == "add_node"){ self.add_node_dialog.close(); From a081cdf79bb1ea53997a3c8a36deaaa857e9e160 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Wed, 16 Nov 2011 14:53:08 +0530 Subject: [PATCH 121/278] [IMP] vieweditor :- improve code in fetch tagname on edit node. bzr revid: ysa@tinyerp.com-20111116092308-9iv5coeqbu1cgdsb --- addons/web/static/src/js/view_editor.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index fbdaa6ed7de..9bbfbdf8f9a 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -458,12 +458,12 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ case "side-remove": break; case "side-edit": - var tr = $(this).closest("tr[id^='viewedit-']").find('a').text(); - var tag = _.detect(_.keys(_PROPERTIES),function(res){ - return _.includes(tr, res); - }); - var properties = _PROPERTIES[tag]; - self.on_edit_node(properties, clicked_tr_id, one_object, view_id, view_xml_id, clicked_tr_level); + var xml_arch = QWeb.load_xml($(this).closest("tr[id^='viewedit-']").find('a').text()); + var tag_name = xml_arch.childNodes? xml_arch.childNodes[0].tagName: false; + if (tag_name) { + var properties = _PROPERTIES[tag_name]; + self.on_edit_node(properties, clicked_tr_id, one_object, view_id, view_xml_id, clicked_tr_level); + } break; case "side-up": while (1) { From bc3a1f52940ec65db7b72141490711aacb6703a5 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Wed, 16 Nov 2011 17:06:24 +0530 Subject: [PATCH 122/278] [IMP] vieweditor :- remove inherit button code and improve code. bzr revid: ysa@tinyerp.com-20111116113624-p1dwbl4oefut2lse --- addons/web/static/src/js/view_editor.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 9bbfbdf8f9a..e2f818870ec 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -376,15 +376,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ height: 500, buttons: { "Inherited View": function() { - var selected_row = self.edit_xml_dialog.$element.find('.ui-selected'); - if (selected_row.length) { - var xml_arch = QWeb.load_xml(selected_row.find('a').text()); - var tag_name = xml_arch.childNodes? xml_arch.childNodes[0].tagName: ""; - console.log(" xml_arch.childNodes[0]::::", xml_arch.childNodes[0].getAttribute()); - if (tag_name == 'field') { - return true; - } - } + //TODO }, "Preview": function() { var action = { @@ -458,12 +450,12 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ case "side-remove": break; case "side-edit": - var xml_arch = QWeb.load_xml($(this).closest("tr[id^='viewedit-']").find('a').text()); - var tag_name = xml_arch.childNodes? xml_arch.childNodes[0].tagName: false; - if (tag_name) { - var properties = _PROPERTIES[tag_name]; - self.on_edit_node(properties, clicked_tr_id, one_object, view_id, view_xml_id, clicked_tr_level); - } + var tr = $(this).closest("tr[id^='viewedit-']").find('a').text(); + var tag = _.detect(_.keys(_PROPERTIES),function(res){ + return _.include(tr, res); + }); + var properties = _PROPERTIES[tag]; + self.on_edit_node(properties, clicked_tr_id, one_object, view_id, view_xml_id, clicked_tr_level); break; case "side-up": while (1) { From a2bc7dc12c7824299881dd1ccfb7613c849e81e0 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Thu, 17 Nov 2011 11:24:36 +0530 Subject: [PATCH 123/278] [FIX] Vieweditor :- fix some merge problem like change _.sprintf to _.str.sprintf. bzr revid: ysa@tinyerp.com-20111117055436-3pqgbd7exh4h18sm --- addons/web/static/src/js/view_editor.js | 43 +++++++++++++------------ 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index e2f818870ec..d2e9cb84dc0 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -17,7 +17,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ init_view_editor: function() { var self = this; var action = { - name: _.sprintf("Manage Views (%s)", this.model), + name: _.str.sprintf("Manage Views (%s)", this.model), context: this.session.user_context, domain: [["model", "=", this.model]], res_model: 'ir.ui.view', @@ -77,7 +77,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var self = this; this.create_view_dialog = new openerp.web.Dialog(this, { modal: true, - title: _.sprintf("Create a view (%s)", self.model), + title: _.str.sprintf("Create a view (%s)", self.model), width: 500, height: 400, buttons: { @@ -147,7 +147,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ if (field_name) { model_dataset.read_slice(['name','field_id'], {"domain": [['model','=',self.model]]}, function(records) { if (records) {view_string = records[0].name;} - var arch = _.sprintf("\n<%s string='%s'>\n\t\n", values.view_type, view_string, field_name, values.view_type); + var arch = _.str.sprintf("\n<%s string='%s'>\n\t\n", values.view_type, view_string, field_name, values.view_type); var vals = {'model': self.model, 'name': values.view_name, 'priority': values.priority, 'type': values.view_type, 'arch': arch}; self.dataset.create(vals, function(suc) { def.resolve(); @@ -170,16 +170,16 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ add_node_name : function(node) { if(node.tagName.toLowerCase() == "button" || node.tagName.toLowerCase() == "field"){ return (node.getAttribute('name'))? - _.sprintf( "<%s name='%s'>",node.tagName.toLowerCase(), node.getAttribute('name')): - _.sprintf( "<%s>",node.tagName.toLowerCase()); + _.str.sprintf( "<%s name='%s'>",node.tagName.toLowerCase(), node.getAttribute('name')): + _.str.sprintf( "<%s>",node.tagName.toLowerCase()); }else if(node.tagName.toLowerCase() == "group"){ return (node.getAttribute('string'))? - _.sprintf( "<%s>",node.getAttribute('string')): - _.sprintf( "<%s>",node.tagName.toLowerCase()); + _.str.sprintf( "<%s>",node.getAttribute('string')): + _.str.sprintf( "<%s>",node.tagName.toLowerCase()); }else{ return (node.getAttribute('string'))? - _.sprintf( "<%s string='%s'>",node.tagName.toLowerCase(), node.getAttribute('string')): - _.sprintf( "<%s>",node.tagName.toLowerCase()); + _.str.sprintf( "<%s string='%s'>",node.tagName.toLowerCase(), node.getAttribute('string')): + _.str.sprintf( "<%s>",node.tagName.toLowerCase()); } }, do_delete_view: function() { @@ -241,7 +241,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ 'level': 0, 'id': this.xml_element_id +=1, 'att_list': [], - 'name': _.sprintf("", view_id), + 'name': _.str.sprintf("", view_id), 'child_id': [] }; var xml_arch = QWeb.load_xml(arch); @@ -298,7 +298,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ expr_to_list.push(_.without($.trim(part.replace(/[^a-zA-Z 0-9 _]+/g,'!')).split("!"), "")); }); }else{ - var temp = _.reject(xpath_arch_object[0].child_id[0].att_list, function(list) { + var temp = _.str.reject(xpath_arch_object[0].child_id[0].att_list, function(list) { return _.include(list, "position") }); expr_to_list = [_.flatten(temp)]; @@ -371,7 +371,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var self = this; this.edit_xml_dialog = new openerp.web.Dialog(this, { modal: true, - title: _.sprintf("View Editor %d - %s", self.main_view_id, self.model), + title: _.str.sprintf("View Editor %d - %s", self.main_view_id, self.model), width: 750, height: 500, buttons: { @@ -450,12 +450,12 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ case "side-remove": break; case "side-edit": - var tr = $(this).closest("tr[id^='viewedit-']").find('a').text(); - var tag = _.detect(_.keys(_PROPERTIES),function(res){ - return _.include(tr, res); - }); - var properties = _PROPERTIES[tag]; - self.on_edit_node(properties, clicked_tr_id, one_object, view_id, view_xml_id, clicked_tr_level); + var row_id = $(this).closest("tr[id^='viewedit-']").attr('id').split("-")[1]; + var result = self.get_object_by_id(row_id, one_object['main_object'], []); + if (result.length && result[0] && result[0].att_list) { + var properties = _PROPERTIES[result[0].att_list[0]]; + self.on_edit_node(properties, clicked_tr_id, one_object, view_id, view_xml_id, clicked_tr_level); + } break; case "side-up": while (1) { @@ -712,7 +712,10 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ _.each(properties, function(property) { var type_widget = new (self.property.get_any([_PROPERTIES_ATTRIBUTES[property].type])) (self.edit_node_dialog, property); var value = _.detect(arch_val[0]['att_list'],function(res) { - return _.include(res, property); + if (res instanceof Array) { + return _.include(res, property); + } + return false; }); type_widget.selection = _PROPERTIES_ATTRIBUTES[property].selection type_widget.type = _PROPERTIES_ATTRIBUTES[property].type @@ -788,7 +791,7 @@ openerp.web.ViewEditor.Field = openerp.web.Class.extend({ } }, render: function() { - return _.sprintf("%s", this.name, QWeb.render(this.template, {widget: this})) + return _.str.sprintf("%s", this.name, QWeb.render(this.template, {widget: this})) }, }); openerp.web.ViewEditor.FieldBoolean = openerp.web.ViewEditor.Field.extend({ From 1d76679c4ac1cf2130c589346d87670be877d231 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Thu, 17 Nov 2011 11:35:20 +0530 Subject: [PATCH 124/278] [IMP] vieweditor :- used setAttribute and removeAttribute instead of attr. bzr revid: ysa@tinyerp.com-20111117060520-x0z8xvb4q5s8s1yt --- addons/web/static/src/js/view_editor.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index d2e9cb84dc0..8747e597b79 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -583,7 +583,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ child_list.splice(index-1, 0, re_insert_obj[0]); } else if (move_direct == "update_node") { _.each(update_values, function(val){ - $(arch1).attr(val[0],val[1]); + if (val[1]) $(arch1)[0].setAttribute(val[0], val[1]); + else $(arch1)[0].removeAttribute(val[0]); }); var new_obj = self.create_View_Node(arch1); new_obj.id = obj.id,new_obj.child_id = obj.child_id; From 7a71c2c821fd0548edc4e819d91b1b07a4ead8db Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Thu, 17 Nov 2011 11:41:36 +0530 Subject: [PATCH 125/278] [IMP] vieweditor :- improve some small issue. bzr revid: ysa@tinyerp.com-20111117061136-h4eh9ksi2kydqaz5 --- addons/web/static/src/js/view_editor.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 8747e597b79..ae1d8e9c2ed 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -569,7 +569,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var list_obj_xml = _.zip(children_list, obj.child_id); if (id) { if (obj.id == id) { - var id; + var id = false;; var index = _.indexOf(child_list, obj); if (move_direct == "down") { var next = $(arch1).next(); @@ -594,10 +594,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var parent = $(arch1).parents(); var convert_to_utf = QWeb.tools.xml_node_to_string(parent[parent.length-1]); convert_to_utf = convert_to_utf.replace('xmlns="http://www.w3.org/1999/xhtml"', ""); - convert_to_utf = '' + convert_to_utf; - arch.arch = convert_to_utf; - this.dataset.write(parseInt(view_id),{"arch":convert_to_utf}, function(r) { - }); + arch.arch = '' + convert_to_utf; + this.dataset.write(parseInt(view_id), {"arch":convert_to_utf}); } if (obj.level <= level) { _.each(list_obj_xml, function(child_node) { From d272f9d03b03049da42378fce434c4713f613eb6 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 17 Nov 2011 12:25:25 +0530 Subject: [PATCH 126/278] [IMP] implement functionlity of new field add. bzr revid: vme@tinyerp.com-20111117065525-60ooggze1xh38v63 --- addons/web/static/src/js/view_editor.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 77d61a2d228..8ebd617e0c2 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -847,6 +847,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); }, render_new_field :function(id){ + var self = this; var action = { context: {'default_model_id':id, 'manual':true}, res_model: "ir.model.fields", @@ -858,14 +859,21 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } } var action_manager = new openerp.web.ActionManager(self); - action_manager.do_action(action); $.when(action_manager.do_action(action)).then(function() { - var add_controller = action_manager.dialog_viewmanager.views['form'].controller; - add_controller.do_set_readonly.add_last(function(){ - var aa = controller; + var controller = action_manager.dialog_viewmanager.views['form'].controller; + controller.do_set_readonly.add_last(function(){ + action_manager.stop(); + new_fields_name = new openerp.web.DataSetSearch(self,'ir.model.fields', null, null); + new_fields_name.read_ids([controller.datarecord.id], ['name'], function(result) { + self.add_node_dialog.$element. + find('select[id=field_value]'). append($(""). + attr("value",result[0].name).text(result[0].name)); + _.detect(self.add_widget,function(widget){ + (widget.name == "field_value")?widget.selection.push(result[0].name):false; + }); + }); }); }); - } }); openerp.web.ViewEditor.Field = openerp.web.Class.extend({ From 3da3b4873a486df35fb6a315757eda260a71b7b7 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Thu, 17 Nov 2011 12:38:40 +0530 Subject: [PATCH 127/278] [IMP] Vieweditor :- improve widget. bzr revid: ysa@tinyerp.com-20111117070840-obtnw5c98e7ywncz --- addons/web/static/src/js/view_editor.js | 103 +++++++++++------------- 1 file changed, 47 insertions(+), 56 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index ae1d8e9c2ed..8051aa8f7cd 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -115,12 +115,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ this.create_view_dialog.$element.append('
    '); this.create_view_widget = []; _.each(view_widget, function(widget) { - var type_widget = new (self.property.get_any([widget.type])) (self.create_view_dialog, widget.name); - if (widget.selection) { - type_widget.selection = widget.selection; - } - type_widget.required = widget.required; - type_widget.type = widget.type; + var type_widget = new (self.property.get_any([widget.type])) (self.create_view_dialog, widget); self.create_view_dialog.$element.find('table[id=create_view]').append('' + widget.string + ':' + type_widget.render()+''); var value = null; if (widget.value) { @@ -450,8 +445,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ case "side-remove": break; case "side-edit": - var row_id = $(this).closest("tr[id^='viewedit-']").attr('id').split("-")[1]; - var result = self.get_object_by_id(row_id, one_object['main_object'], []); + var result = self.get_object_by_id(clicked_tr_id, one_object['main_object'], []); if (result.length && result[0] && result[0].att_list) { var properties = _PROPERTIES[result[0].att_list[0]]; self.on_edit_node(properties, clicked_tr_id, one_object, view_id, view_xml_id, clicked_tr_level); @@ -661,43 +655,43 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); this.edit_node_dialog.start().open(); var _PROPERTIES_ATTRIBUTES = { - 'name' : {'string': 'Name', 'type': 'char'}, - 'string' : {'string': 'String', 'type': 'char'}, - 'required' : {'string': 'Required', 'type': 'boolean'}, - 'readonly' : {'string': 'Readonly', 'type': 'boolean'}, - 'domain' : {'string': 'Domain', 'type': 'char'}, - 'context' : {'string': 'Context', 'type': 'char'}, - 'limit' : {'string': 'Limit', 'type': 'float'}, - 'min_rows' : {'string': 'Minimum rows', 'type': 'float'}, - 'date_start' : {'string': 'Start date', 'type': 'char'}, - 'date_delay' : {'string': 'Delay date', 'type': 'char'}, - 'day_length' : {'string': 'Day length', 'type': 'char'}, - 'mode' : {'string': 'Mode', 'type': 'char'}, - 'align' : {'string': 'Alignment ', 'type': 'selection', 'selection': [['', ''], ['0.0', 'Left'], ['0.5', 'Center'], ['1.0', 'Right']]}, - 'icon' : {'string': 'Icon', 'type': 'selection', 'selection': _ICONS}, - 'type' : {'string': 'Type', 'type': 'selection', 'selection': [['', ''], ['action', 'Action'], ['object', 'Object'], ['workflow', 'Workflow'], ['server_action', 'Server Action']]}, - 'special' : {'string': 'Special', 'type': 'selection', 'selection': [['',''],['save', 'Save Button'], ['cancel', 'Cancel Button'], ['open', 'Open Button']]}, - 'target' : {'string': 'Target', 'type': 'selection', 'selection': [['', ''], ['new', 'New Window']]}, - 'confirm' : {'string': 'Confirm', 'type': 'char'}, - 'style' : {'string': 'Style', 'type': 'selection', 'selection':[["",""],["1", "1"],["1-1", "1-1"],["1-2", "1-2"],["2-1", "2-1"],["1-1-1", "1-1-1"]]}, - 'filename' : {'string': 'File Name', 'type': 'char'}, - 'width' : {'string': 'Width', 'type': 'float'}, - 'height' : {'string': 'Height', 'type': 'float'}, - 'attrs' : {'string': 'Attrs', 'type': 'char'}, - 'col' : {'string': 'col', 'type': 'float'}, - 'link' : {'string': 'Link', 'type': 'char'}, - 'position' : {'string': 'Position', 'type': 'selection', 'selection': [['',''],['after', 'After'],['before', 'Before'],['inside', 'Inside'],['replace', 'Replace']]}, - 'states' : {'string': 'states', 'type': 'char'}, - 'eval' : {'string': 'Eval', 'type': 'char'}, - 'ref' : {'string': 'Ref', 'type': 'char'}, - 'on_change' : {'string': 'On change', 'type': 'char'}, - 'nolabel' : {'string': 'No label', 'type': 'boolean'}, - 'completion' : {'string': 'Completion', 'type': 'boolean'}, - 'colspan' : {'string': 'Colspan', 'type': 'float'}, - 'widget' : {'string': 'widget', 'type': 'selection'}, - 'colors' : {'string': 'Colors', 'type': 'char'}, - 'editable' : {'string': 'Editable', 'type': 'selection', 'selection': [["",""],["top","Top"],["bottom", "Bottom"]]}, - 'groups' : {'string': 'Groups', 'type': 'seleciton_multi'}, + 'name' : {'name':'name', 'string': 'Name', 'type': 'char'}, + 'string' : {'name':'string', 'string': 'String', 'type': 'char'}, + 'required' : {'name':'required', 'string': 'Required', 'type': 'boolean'}, + 'readonly' : {'name':'readonly', 'string': 'Readonly', 'type': 'boolean'}, + 'domain' : {'name':'domain', 'string': 'Domain', 'type': 'char'}, + 'context' : {'name':'context', 'string': 'Context', 'type': 'char'}, + 'limit' : {'name':'limit', 'string': 'Limit', 'type': 'float'}, + 'min_rows' : {'name':'min_rows', 'string': 'Minimum rows', 'type': 'float'}, + 'date_start' : {'name':'date_start', 'string': 'Start date', 'type': 'char'}, + 'date_delay' : {'name':'date_delay', 'string': 'Delay date', 'type': 'char'}, + 'day_length' : {'name':'day_length', 'string': 'Day length', 'type': 'char'}, + 'mode' : {'name':'mode', 'string': 'Mode', 'type': 'char'}, + 'align' : {'name':'align', 'string': 'Alignment ', 'type': 'selection', 'selection': [['', ''], ['0.0', 'Left'], ['0.5', 'Center'], ['1.0', 'Right']]}, + 'icon' : {'name':'icon', 'string': 'Icon', 'type': 'selection', 'selection': _ICONS}, + 'type' : {'name':'type', 'string': 'Type', 'type': 'selection', 'selection': [['', ''], ['action', 'Action'], ['object', 'Object'], ['workflow', 'Workflow'], ['server_action', 'Server Action']]}, + 'special' : {'name':'special', 'string': 'Special', 'type': 'selection', 'selection': [['',''],['save', 'Save Button'], ['cancel', 'Cancel Button'], ['open', 'Open Button']]}, + 'target' : {'name':'target', 'string': 'Target', 'type': 'selection', 'selection': [['', ''], ['new', 'New Window']]}, + 'confirm' : {'name':'confirm', 'string': 'Confirm', 'type': 'char'}, + 'style' : {'name':'style', 'string': 'Style', 'type': 'selection', 'selection':[["",""],["1", "1"],["1-1", "1-1"],["1-2", "1-2"],["2-1", "2-1"],["1-1-1", "1-1-1"]]}, + 'filename' : {'name':'filename', 'string': 'File Name', 'type': 'char'}, + 'width' : {'name':'width', 'string': 'Width', 'type': 'float'}, + 'height' : {'name':'height', 'string': 'Height', 'type': 'float'}, + 'attrs' : {'name':'attrs', 'string': 'Attrs', 'type': 'char'}, + 'col' : {'name':'col', 'string': 'col', 'type': 'float'}, + 'link' : {'name':'link', 'string': 'Link', 'type': 'char'}, + 'position' : {'name':'position', 'string': 'Position', 'type': 'selection', 'selection': [['',''],['after', 'After'],['before', 'Before'],['inside', 'Inside'],['replace', 'Replace']]}, + 'states' : {'name':'states', 'string': 'states', 'type': 'char'}, + 'eval' : {'name':'eval', 'string': 'Eval', 'type': 'char'}, + 'ref' : {'name':'ref', 'string': 'Ref', 'type': 'char'}, + 'on_change' : {'name':'on_change', 'string': 'On change', 'type': 'char'}, + 'nolabel' : {'name':'nolabel', 'string': 'No label', 'type': 'boolean'}, + 'completion' : {'name':'completion', 'string': 'Completion', 'type': 'boolean'}, + 'colspan' : {'name':'colspan', 'string': 'Colspan', 'type': 'float'}, + 'widget' : {'name':'widget', 'string': 'widget', 'type': 'selection'}, + 'colors' : {'name':'colors', 'string': 'Colors', 'type': 'char'}, + 'editable' : {'name':'editable', 'string': 'Editable', 'type': 'selection', 'selection': [["",""],["top","Top"],["bottom", "Bottom"]]}, + 'groups' : {'name':'groups', 'string': 'Groups', 'type': 'seleciton_multi'}, }; var arch_val = self.get_object_by_id(clicked_tr_id,obj['main_object'], []); this.edit_node_dialog.$element.append('
    '); @@ -709,15 +703,13 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ values.sort(); _PROPERTIES_ATTRIBUTES['widget']['selection'] = values; _.each(properties, function(property) { - var type_widget = new (self.property.get_any([_PROPERTIES_ATTRIBUTES[property].type])) (self.edit_node_dialog, property); + var type_widget = new (self.property.get_any([_PROPERTIES_ATTRIBUTES[property].type])) (self.edit_node_dialog, _PROPERTIES_ATTRIBUTES[property]); var value = _.detect(arch_val[0]['att_list'],function(res) { if (res instanceof Array) { return _.include(res, property); } return false; }); - type_widget.selection = _PROPERTIES_ATTRIBUTES[property].selection - type_widget.type = _PROPERTIES_ATTRIBUTES[property].type value = value instanceof Array ? value[1] : value; self.edit_node_dialog.$element.find('table[id=rec_table]').append('' + _PROPERTIES_ATTRIBUTES[property].string + ':' + type_widget.render() + ''); type_widget.start(); @@ -761,11 +753,14 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }); openerp.web.ViewEditor.Field = openerp.web.Class.extend({ - init: function(view, name) { + init: function(view, widget) { this.$element = view.$element; this.dirty = false; - this.name = name; - this.required = false; + this.name = widget.name; + this.selection = widget.selection || []; + this.required = widget.required || false; + this.string = widget.string || ""; + this.type = widget.type; this.is_invalid = false; }, start: function () { @@ -830,10 +825,6 @@ openerp.web.ViewEditor.FieldChar = openerp.web.ViewEditor.Field.extend({ }); openerp.web.ViewEditor.FieldSelect = openerp.web.ViewEditor.Field.extend({ template : "vieweditor_selection", - init: function(view, name) { - this._super(view, name); - this.selection = false; - }, start: function () { var self = this; this._super(); @@ -883,7 +874,7 @@ var _PROPERTIES = { 'image' : ['filename', 'width', 'height', 'groups'], 'separator' : ['string', 'colspan', 'groups'], 'label': ['string', 'align', 'colspan', 'groups'], - 'button': ['name', 'string', 'icon', 'type', 'states', 'readonly', 'special', 'target', 'confirm', 'context', 'attrs', 'groups','colspan'], + 'button': ['name', 'string', 'icon', 'type', 'states', 'readonly', 'special', 'target', 'confirm', 'context', 'attrs', 'colspan', 'groups'], 'newline' : [], 'board': ['style'], 'column' : [], From f2c68745f0d3fbdcbf93eb2b39da2f61d35bb717 Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Thu, 17 Nov 2011 12:39:05 +0530 Subject: [PATCH 128/278] [FIX/IMP/REF]:1::fix copy,unlink,workflow actions,refactored the way data was processed and logged for the actions and workflow actions. bzr revid: nch@tinyerp.com-20111117070905-14b23ir45vx7rg7x --- addons/audittrail/audittrail.py | 118 ++++++++++++++------------------ 1 file changed, 52 insertions(+), 66 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index 3d7bf8587f7..60a5aa4f9be 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -194,7 +194,7 @@ class audittrail_objects_proxy(object_proxy): if recursive: self.log_fct(cr, uid, field_obj._obj, method, None, value, 'child_relation_log') data = pool.get(field_obj._obj).name_get(cr, uid, value) - #return the modifications on *2many fields as a list of names + #return the modifications on x2many fields as a list of names return map(lambda x:x[1], data) elif field_obj._type == 'many2one': #return the modifications on a many2one field as the name of the value @@ -287,7 +287,6 @@ class audittrail_objects_proxy(object_proxy): pool = pooler.get_pool(cr.dbname) resource_pool = pool.get(model) model_pool = pool.get('ir.model') - log_pool = pool.get('audittrail.log') model_ids = model_pool.search(cr, 1, [('model', '=', model)]) model_id = model_ids and model_ids[0] or False assert model_id, _("'%s' Model does not exist..." %(model)) @@ -335,74 +334,61 @@ class audittrail_objects_proxy(object_proxy): if isinstance(res_ids, (long, int)): res_ids = [res_ids] if res_ids: - x2m_old_values = {} - old_values = {} - def inline_process_old_data(res_ids, model, model_id=False): - resource_pool = pool.get(model) - resource_data = resource_pool.read(cr, uid, res_ids) - _old_values = {} - for resource in resource_data: - _old_values_text = {} - _old_value = {} - resource_id = resource['id'] - for field in resource.keys(): - if field in ('__last_update', 'id'):continue - field_obj = (resource_pool._all_columns.get(field)).column - if field_obj._type in ('one2many','many2many'): - if self.check_rules(cr, uid, field_obj._obj, method): - x2m_model_ids = model_pool.search(cr, 1, [('model', '=', field_obj._obj)]) - x2m_model_id = x2m_model_ids and x2m_model_ids[0] or False - assert x2m_model_id, _("'%s' Model does not exist..." %(field_obj._obj)) - x2m_model = model_pool.browse(cr, uid, x2m_model_id) - x2m_old_values.update(inline_process_old_data(resource[field], field_obj._obj, x2m_model)) - ret_val = self.get_value_text(cr, uid, pool, resource_pool, method, field, resource[field], False) - _old_value[field] = resource[field] - _old_values_text[field] = ret_val and ret_val or resource[field] - _old_values[resource_id] = {'text':_old_values_text, 'value': _old_value} - if model_id: - _old_values[resource_id].update({'model_id':model_id}) - return _old_values - old_values.update(inline_process_old_data(res_ids, model.model)) + old_values = self.process_data(cr, uid_orig, pool, res_ids, model, method, type='old') res = fct_src(cr, uid_orig, model.model, method, *args) + if method == 'copy': + res_ids = [res] if res_ids: - def inline_process_new_data(res_ids, model, dict_to_use={}): - resource_pool = pool.get(model.model) - resource_data = resource_pool.read(cr, uid, res_ids) - vals = {'method': method,'object_id': model.id,'user_id': uid_orig } - for resource in resource_data: - resource_id = resource['id'] - vals.update({'res_id': resource_id}) - if resource_id not in dict_to_use: - vals.update({'method': 'create'}) - lines = [] - for field in resource.keys(): - if field in ('__last_update', 'id'):continue - field_obj = (resource_pool._all_columns.get(field)).column - if field_obj._type in ('one2many','many2many'): - if self.check_rules(cr, uid, field_obj._obj, method): - x2m_model_ids = model_pool.search(cr, 1, [('model', '=', field_obj._obj)]) - x2m_model_id = x2m_model_ids and x2m_model_ids[0] or False - assert x2m_model_id, _("'%s' Model does not exist..." %(field_obj._obj)) - x2m_model = model_pool.browse(cr, uid, x2m_model_id) - inline_process_new_data(resource[field], x2m_model, x2m_old_values) - ret_val = self.get_value_text(cr, uid, pool, resource_pool, method, field, resource[field], False) - line = { - 'name': field, - 'new_value': resource[field], - 'old_value': resource_id in dict_to_use and dict_to_use[resource_id]['value'].get(field), - 'new_value_text': ret_val and ret_val or resource[field], - 'old_value_text': resource_id in dict_to_use and dict_to_use[resource_id]['text'].get(field) - } - if line.get('new_value_text') != line.get('old_value_text'): - lines.append(line) - if lines: - log_id = log_pool.create(cr, uid, vals) - self.create_log_line(cr, uid, log_id, model, lines) - return True - inline_process_new_data(res_ids, model, old_values) + self.process_data(cr, uid_orig, pool, res_ids, model, method, old_values) return res return True - + + def process_data(self, cr, uid_orig, pool, res_ids, model, method, original_values={}, type='new'): + resource_pool = pool.get(model.model) + resource_data = resource_pool.read(cr, 1, res_ids) + _old_values = {} + for resource in resource_data: + _old_values_text = {} + _old_value = {} + resource_id = resource['id'] + if type == 'new': + vals = {'method': method,'object_id': model.id,'user_id': uid_orig } + vals.update({'res_id': resource_id}) + if resource_id not in original_values and method !='copy': + vals.update({'method': 'create'}) + lines = [] + for field in resource: + if field in ('__last_update', 'id'):continue + field_obj = (resource_pool._all_columns.get(field)).column + if field_obj._type in ('one2many','many2many'): + if self.check_rules(cr, 1, field_obj._obj, method): + x2m_model_ids = pool.get('ir.model').search(cr, 1, [('model', '=', field_obj._obj)]) + x2m_model_id = x2m_model_ids and x2m_model_ids[0] or False + assert x2m_model_id, _("'%s' Model does not exist..." %(field_obj._obj)) + x2m_model = pool.get('ir.model').browse(cr, 1, x2m_model_id) + _old_values[field] = self.process_data(cr, 1, pool, resource[field], x2m_model, method, original_values.get(field,{}), type=type) + ret_val = self.get_value_text(cr, 1, pool, resource_pool, method, field, resource[field], False) + if type == 'new': + line = { + 'name': field, + 'new_value': resource[field], + 'old_value': resource_id in original_values and original_values[resource_id]['value'].get(field), + 'new_value_text': ret_val and ret_val or resource[field], + 'old_value_text': resource_id in original_values and original_values[resource_id]['text'].get(field) + } + if line.get('new_value_text') != line.get('old_value_text'): + lines.append(line) + else: + _old_value[field] = resource[field] + _old_values_text[field] = ret_val and ret_val or resource[field] + if type == 'new': + if lines: + log_id = pool.get('audittrail.log').create(cr, 1, vals) + self.create_log_line(cr, 1, log_id, model, lines) + else: + _old_values[resource_id] = {'text':_old_values_text, 'value': _old_value} + return _old_values + def check_rules(self, cr, uid, model, method): pool = pooler.get_pool(cr.dbname) # Check if auditrails is installed for that db and then if one rule match From 98f060b12861fda6f29e9a0b9d94a11d767d5fe4 Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Thu, 17 Nov 2011 12:55:18 +0530 Subject: [PATCH 129/278] [IMP]:added doc string for missing methods bzr revid: nch@tinyerp.com-20111117072518-iohc292j52qke927 --- addons/audittrail/audittrail.py | 54 ++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index 60a5aa4f9be..9c7ea06fad5 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -207,7 +207,7 @@ class audittrail_objects_proxy(object_proxy): @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, - @param model: Object who's values are being changed + @param model: Object whose values are being changed @param lines: List of values for line is to be created """ pool = pooler.get_pool(cr.dbname) @@ -243,14 +243,14 @@ class audittrail_objects_proxy(object_proxy): def start_log_process(self, cr, user_id, model, method, resource_data, pool, resource_pool): """ Logging function: This function performs the logging operation for create/read/unlink operation - :@param cr: the current row, from the database cursor, - :@param user_id: the current user’s ID, - :param model: Object which values are being changed - :param method: method to log: create, read, unlink - :param resource_data: list of data modified for the model - :@param pool: current db's pooler object. - :@param resource_pool: pooler object of the model who's values are being changed. - :return:True + @param cr: the current row, from the database cursor, + @param user_id: the current user’s ID, + param model: Object whose values are being changed + param method: method to log: create, read, unlink + param resource_data: list of data modified for the model + @param pool: current db's pooler object. + @param resource_pool: pooler object of the model who's values are being changed. + return:True """ key1 = '%s_value'%(method == 'create' and 'new' or 'old') @@ -276,11 +276,11 @@ class audittrail_objects_proxy(object_proxy): def log_fct(self, cr, uid, model, method, fct_src, *args): """ Logging function: This function is performing the logging operation - :param model: Object which values are being changed - :param method: method to log: create, read, write, unlink - :param fct_src: execute method of Object proxy + @param model: Object whose values are being changed + @param method: method to log: create, read, write, unlink + @param fct_src: execute method of Object proxy - :return: Returns result as per method of Object proxy + @return: Returns result as per method of Object proxy """ uid_orig = uid uid = 1 @@ -344,6 +344,22 @@ class audittrail_objects_proxy(object_proxy): return True def process_data(self, cr, uid_orig, pool, res_ids, model, method, original_values={}, type='new'): + """ + This is specially created to log actions and workflow actions on an object recursively + processes and iterates recursively old data (i.e before the method was executed ) + and stores it in a dict then this dict is used to compare with the new data + (i.e after the method execution) and log the changes. + + @param cr: the current row, from the database cursor, + @param uid_orig: the current user’s ID, + @param pool: current db's pooler object. + @param res_ids: Id's of resource to be logged/compared. + @param model: Object whose values are being changed + @param method: method to log: create, read, unlink,write,actions,workflow actions + @param original_values: dict of values of res_ids read before execution of the method only when type is 'new' + @param type: Either of 'new' or 'old' to know which data to process. + @return: dict of values + """ resource_pool = pool.get(model.model) resource_data = resource_pool.read(cr, 1, res_ids) _old_values = {} @@ -390,15 +406,23 @@ class audittrail_objects_proxy(object_proxy): return _old_values def check_rules(self, cr, uid, model, method): + """ + Checks if auditrails is installed for that db and then if one rule match + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID, + @param model: Object whose values are being changed + @param method: method to log: create, read, unlink,write,actions,workflow actions + @return: True or False + """ + pool = pooler.get_pool(cr.dbname) - # Check if auditrails is installed for that db and then if one rule match if 'audittrail.rule' in pool.models: model_ids = pool.get('ir.model').search(cr, 1, [('model', '=', model)]) model_id = model_ids and model_ids[0] or False if model_id: rule_ids = pool.get('audittrail.rule').search(cr, 1, [('object_id', '=', model_id), ('state', '=', 'subscribed')]) for rule in pool.get('audittrail.rule').read(cr, 1, rule_ids, ['user_id','log_read','log_write','log_create','log_unlink','log_action','log_workflow']): - if len(rule['user_id'])==0 or uid in rule['user_id']: + if len(rule['user_id']) == 0 or uid in rule['user_id']: if rule.get('log_'+method,0): return True elif method not in ('default_get','read','fields_view_get','fields_get','search','search_count','name_search','name_get','get','request_get', 'get_sc', 'unlink', 'write', 'create'): From 48bd70a64a99239c59057e44ef263a9136de8091 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 17 Nov 2011 13:09:56 +0530 Subject: [PATCH 130/278] [imp] nivified category view bzr revid: nicolas.vanhoren@openerp.com-20111117073956-m0u6ehdd0lg9o71g --- addons/point_of_sale/static/src/js/pos.js | 52 +++++++++++------------ 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/addons/point_of_sale/static/src/js/pos.js b/addons/point_of_sale/static/src/js/pos.js index d9ed87f4ae9..609641fc913 100644 --- a/addons/point_of_sale/static/src/js/pos.js +++ b/addons/point_of_sale/static/src/js/pos.js @@ -719,25 +719,20 @@ openerp.point_of_sale = function(db) { /* "Products" step. */ - CategoryView = (function() { - __extends(CategoryView, Backbone.View); - function CategoryView() { - CategoryView.__super__.constructor.apply(this, arguments); - } - - CategoryView.prototype.events = { - 'click .oe-pos-categories-list a': 'changeCategory' - }; - - CategoryView.prototype.template = qweb_template('pos-category-template'); - CategoryView.prototype.render = function(ancestors, children) { + CategoryWidget = db.web.Widget.extend({ + start: function() { + this.$element.find(".oe-pos-categories-list a").click(_.bind(this.changeCategory, this)); + }, + template_fct: qweb_template('pos-category-template'), + render_element: function() { + var self = this; var c; - return $(this.el).html(this.template({ + this.$element.html(this.template_fct({ breadcrumb: (function() { var _i, _len, _results; _results = []; - for (_i = 0, _len = ancestors.length; _i < _len; _i++) { - c = ancestors[_i]; + for (_i = 0, _len = self.ancestors.length; _i < _len; _i++) { + c = self.ancestors[_i]; _results.push(pos.categories[c]); } return _results; @@ -745,20 +740,20 @@ openerp.point_of_sale = function(db) { categories: (function() { var _i, _len, _results; _results = []; - for (_i = 0, _len = children.length; _i < _len; _i++) { - c = children[_i]; + for (_i = 0, _len = self.children.length; _i < _len; _i++) { + c = self.children[_i]; _results.push(pos.categories[c]); } return _results; })() })); - }; - CategoryView.prototype.changeCategory = function(a) { + }, + changeCategory: function(a) { var id = $(a.target).data("category-id"); - this.trigger("changeCategory", id); - }; - return CategoryView; - })(); + this.on_change_category(id); + }, + on_change_category: function(id) {}, + }); ProductView = (function() { __extends(ProductView, Backbone.View); function ProductView() { @@ -1121,10 +1116,9 @@ openerp.point_of_sale = function(db) { shop: this.shop, el: $element }); - this.categoryView = new CategoryView; - this.categoryView.bind("changeCategory", this.category, this); + this.categoryView = new CategoryWidget(null, 'products-screen'); + this.categoryView.on_change_category.add_last(_.bind(this.category, this)); this.category(); - return this.categoryView; }; App.prototype.category = function(id) { var c, products; @@ -1132,8 +1126,10 @@ openerp.point_of_sale = function(db) { id = 0; } c = pos.categories[id]; - $('#products-screen').html(this.categoryView.render(c.ancestors, c.children)); - this.categoryView.delegateEvents(); + this.categoryView.ancestors = c.ancestors; + this.categoryView.children = c.children; + this.categoryView.render_element(); + this.categoryView.start(); products = pos.store.get('product.product').filter( function(p) { var _ref; return _ref = p.pos_categ_id[0], __indexOf.call(c.subtree, _ref) >= 0; From 9589ee8d348dab8d76dd1837695ce7a90005912d Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Thu, 17 Nov 2011 14:14:38 +0530 Subject: [PATCH 131/278] [FIX]:fix useless creat of log record for 'x2M' in read operation bzr revid: nch@tinyerp.com-20111117084438-fx63kcqx3my59sxa --- addons/audittrail/audittrail.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index 9c7ea06fad5..47a0122b035 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -258,8 +258,6 @@ class audittrail_objects_proxy(object_proxy): uid = 1 vals = { 'method': method, 'object_id': model.id,'user_id': user_id} for resource, fields in resource_data.iteritems(): - vals.update({'res_id': resource}) - log_id = pool.get('audittrail.log').create(cr, uid, vals) lines = [] for field_key, value in fields.iteritems(): if field_key in ('__last_update', 'id'):continue @@ -270,7 +268,10 @@ class audittrail_objects_proxy(object_proxy): key2: ret_val and ret_val or value } lines.append(line) - self.create_log_line(cr, uid, log_id, model, lines) + if lines: + vals.update({'res_id': resource}) + log_id = pool.get('audittrail.log').create(cr, uid, vals) + self.create_log_line(cr, uid, log_id, model, lines) return True def log_fct(self, cr, uid, model, method, fct_src, *args): From fa3998b7440cc8a3a17f85c6fb0de9e5102db9ba Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Thu, 17 Nov 2011 14:17:39 +0530 Subject: [PATCH 132/278] [IMP] Vieweditor :- improve edit field dialog box. bzr revid: ysa@tinyerp.com-20111117084739-lzj2jw8woj984054 --- addons/web/static/src/js/view_editor.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 8051aa8f7cd..e3f78968d86 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -702,16 +702,15 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ values.push(''); values.sort(); _PROPERTIES_ATTRIBUTES['widget']['selection'] = values; - _.each(properties, function(property) { - var type_widget = new (self.property.get_any([_PROPERTIES_ATTRIBUTES[property].type])) (self.edit_node_dialog, _PROPERTIES_ATTRIBUTES[property]); + var widgets = _.filter(_PROPERTIES_ATTRIBUTES, function(property){ return _.include(properties, property.name)}) + _.each(widgets, function(widget) { + var type_widget = new (self.property.get_any([widget.type])) (self.edit_node_dialog, widget); var value = _.detect(arch_val[0]['att_list'],function(res) { - if (res instanceof Array) { - return _.include(res, property); - } - return false; + if (res instanceof Array) return _.include(res, widget.name); + else return false; }); value = value instanceof Array ? value[1] : value; - self.edit_node_dialog.$element.find('table[id=rec_table]').append('' + _PROPERTIES_ATTRIBUTES[property].string + ':' + type_widget.render() + ''); + self.edit_node_dialog.$element.find('table[id=rec_table]').append('' + widget.string + ':' + type_widget.render() + ''); type_widget.start(); type_widget.set_value(value) self.edit_widget.push(type_widget); From fa079e79f5108dec64d30bd4dce52071874b0d48 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Thu, 17 Nov 2011 15:28:54 +0530 Subject: [PATCH 133/278] [FIX] bzr revid: ysa@tinyerp.com-20111117095854-w7ivkrucm32g5ug9 --- addons/web/static/src/js/view_editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index e3f78968d86..f4bb3b99f63 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -293,7 +293,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ expr_to_list.push(_.without($.trim(part.replace(/[^a-zA-Z 0-9 _]+/g,'!')).split("!"), "")); }); }else{ - var temp = _.str.reject(xpath_arch_object[0].child_id[0].att_list, function(list) { + var temp = _.reject(xpath_arch_object[0].child_id[0].att_list, function(list) { return _.include(list, "position") }); expr_to_list = [_.flatten(temp)]; From aa08bb9368d96e260e5416130be2b491e4546c04 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Thu, 17 Nov 2011 15:43:16 +0530 Subject: [PATCH 134/278] [FIX] Vieweditor :- if type is tree then pass list view in action. bzr revid: ysa@tinyerp.com-20111117101316-9t8saf6t9wfgr9yz --- addons/web/static/src/js/view_editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index f4bb3b99f63..825b8f6f689 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -248,7 +248,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ this.dataset.read_ids([parseInt(self.main_view_id)], ['arch', 'type'], function(arch) { if (arch.length) { var arch_object = self.parse_xml(arch[0].arch, self.main_view_id); - self.main_view_type = arch[0].type + self.main_view_type = arch[0].type == 'tree'? 'list': arch[0].type; view_arch_list.push({"view_id": self.main_view_id, "arch": arch[0].arch}); self.dataset.read_slice([], {domain: [['inherit_id','=', parseInt(self.main_view_id)]]}, function(result) { _.each(result, function(res) { From 207933a632d36394c85de225ec4aea80a1c5808e Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 17 Nov 2011 17:04:10 +0530 Subject: [PATCH 135/278] [imp] nivified product view bzr revid: nicolas.vanhoren@openerp.com-20111117113410-c8coka92ujkrqufv --- addons/point_of_sale/static/src/js/pos.js | 50 +++++++++++------------ 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/addons/point_of_sale/static/src/js/pos.js b/addons/point_of_sale/static/src/js/pos.js index 609641fc913..d4fbfc6f6ed 100644 --- a/addons/point_of_sale/static/src/js/pos.js +++ b/addons/point_of_sale/static/src/js/pos.js @@ -162,11 +162,11 @@ openerp.point_of_sale = function(db) { /* global variable */ var pos; - var App, CashRegister, CashRegisterCollection, Category, CategoryCollection, CategoryView, + var App, CashRegister, CashRegisterCollection, Category, CategoryCollection, CategoryWidget, NumpadState, NumpadWidget, Order, OrderButtonView, OrderCollection, OrderWidget, Orderline, OrderlineCollection, OrderlineWidget, PaymentButtonWidget, PaymentView, Paymentline, PaymentlineCollection, PaymentlineView, PaypadWidget, Product, ProductCollection, - ProductListView, ProductView, ReceiptLineView, ReceiptView, Shop, ShopView, StepsWidget; + ProductListView, ProductWidget, ReceiptLineView, ReceiptView, Shop, ShopView, StepsWidget; /* --- @@ -754,31 +754,28 @@ openerp.point_of_sale = function(db) { }, on_change_category: function(id) {}, }); - ProductView = (function() { - __extends(ProductView, Backbone.View); - function ProductView() { - ProductView.__super__.constructor.apply(this, arguments); - } - - ProductView.prototype.tagName = 'li'; - ProductView.prototype.className = 'product'; - ProductView.prototype.template = qweb_template('pos-product-template'); - ProductView.prototype.events = { - 'click a': 'addToOrder' - }; - ProductView.prototype.initialize = function(options) { - return this.shop = options.shop; - }; - ProductView.prototype.addToOrder = function(event) { + ProductWidget = db.web.Widget.extend({ + tag_name:'li', + template_fct: qweb_template('pos-product-template'), + init: function(parent, element_id, options) { + this._super(parent, element_id); + this.model = options.model; + this.shop = options.shop; + }, + start: function(options) { + $("a", this.$element).click(_.bind(this.addToOrder, this)); + }, + addToOrder: function(event) { /* Preserve the category URL */ event.preventDefault(); return (this.shop.get('selectedOrder')).addProduct(this.model); - }; - ProductView.prototype.render = function() { - return $(this.el).html(this.template(this.model.toJSON())); - }; - return ProductView; - })(); + }, + render_element: function() { + this.$element.addClass("product"); + this.$element.html(this.template_fct(this.model.toJSON())); + return this; + }, + }); ProductListView = (function() { __extends(ProductListView, Backbone.View); function ProductListView() { @@ -794,10 +791,11 @@ openerp.point_of_sale = function(db) { ProductListView.prototype.render = function() { $(this.el).empty(); (this.shop.get('products')).each(__bind( function(product) { - return $(this.el).append((new ProductView({ + var p = new ProductWidget(null, null, { model: product, shop: this.shop - })).render()); + }); + p.appendTo($(this.el)); }, this)); return $('#products-screen').append(this.el); }; From 379c9fab24836c91b42e216afa7371f2533785e3 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Fri, 18 Nov 2011 11:29:03 +0530 Subject: [PATCH 136/278] [IMP]code refactor. bzr revid: vme@tinyerp.com-20111118055903-llouzhuhdw5j64mh --- addons/web/static/src/js/view_editor.js | 74 ++++++++++++++++++------- 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 8ebd617e0c2..af73b3c31fa 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -10,6 +10,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ this.model = dataset.model; this.xml_element_id = 0; this.property = openerp.web.ViewEditor.property_widget; + this.one_object; }, start: function() { this.init_view_editor(); @@ -402,6 +403,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ this.edit_xml_dialog.$element.find("tr[id^='viewedit-']").click(function() { self.edit_xml_dialog.$element.find("tr[id^='viewedit-']").removeClass('ui-selected'); $(this).addClass('ui-selected'); + console.log(self); }); this.edit_xml_dialog.$element.find("img[id^='parentimg-']").click(function() { if ($(this).attr('src') == '/web/static/src/img/collapse.gif') { @@ -414,6 +416,11 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }); this.edit_xml_dialog.$element.find("img[id^='side-']").click(function() { + + }); + }, + what_to_do: function(){ + var self = this; var side = $(this).closest("tr[id^='viewedit-']"); var clicked_tr_id = parseInt((side.attr('id')).split('-')[1]); var img = side.find("img[id='parentimg-" + clicked_tr_id + "']").attr('src'); @@ -468,6 +475,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ break; case "side-remove": if (confirm(_t("Do you really want to remove this node?"))) { + self.do_save_update_arch (one_object, view_id, view_xml_id, clicked_tr_id, clicked_tr_level, "remove_node"); } @@ -478,6 +486,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ return _.includes(tr, res); }); var properties = _PROPERTIES[tag]; + console.log("properties",properties); self.on_edit_node(properties, clicked_tr_id, one_object, view_id, view_xml_id, clicked_tr_level); break; case "side-up": @@ -508,7 +517,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ _.each(tr_to_move, function(rec) { $(last_tr).before(rec); }); - self.do_save_update_arch(one_object, view_id, view_xml_id, clicked_tr_id, clicked_tr_level, "up"); + self.do_save_update_arch + (one_object, view_id, view_xml_id, clicked_tr_id, clicked_tr_level, "up"); } break; case "side-down": @@ -551,8 +561,9 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } break; } - }); - }, + } + + do_save_update_arch: function(one_object, view_id, view_xml_id, clicked_tr_id, clicked_tr_level, move_direct, update_values) { var self = this; var arch = _.detect(one_object['arch'], function(element) {return element.view_id == view_id;}); @@ -625,7 +636,16 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ child_list.splice(index, 1, new_obj); var parent = $(arch1).parents(); }else if(move_direct == "add_node"){ - switch (update_values[1]) { + //not working + var clone = self.edit_xml_dialog.$element.find("tr[id='viewedit-"+id+"']").clone(); + self.edit_xml_dialog.$element.find("tr[id='viewedit-"+id+"']").after(clone); + clone.find("img[id^='side-']").click(function(){ + console.log("this",this); + }); + clone.bind("click", function(){ + console.log("thissss",this); + }); + switch (update_values[1]) { case "After": $(arch1).after(update_values[0]); break; @@ -639,6 +659,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var parent = $(arch1).parents(); }else if(move_direct == "remove_node"){ var parent = $(arch1).parents(); + console.log("vidhin",obj); if(parent.length == 0 || (parent[0].tagName.toLowerCase() == "data")){ id = id -1; level = level - 1; @@ -665,10 +686,11 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); } if(move_direct == "add_node"){ - self.add_node_dialog.close(); - self.edit_xml_dialog.close(); - self.xml_element_id = 0; - self.get_arch();} + //self.add_node_dialog.close(); + //self.edit_xml_dialog.close(); + //self.xml_element_id = 0; + //self.get_arch(id); + } } if (obj.level <= level) { _.each(list_obj_xml, function(child_node) { @@ -793,14 +815,14 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var render_list = []; var render_list =[{'name': 'node_type','selection': _.keys(_CHILDREN).sort(), 'value': 'field', 'string': 'Node Type'}, - {'name': 'position','selection': positions, 'value': false, 'string': 'Position'}, - {'name': 'field_value','selection': fields, 'value': false, 'string': ''}]; + {'name': 'field_value','selection': fields, 'value': false, 'string': ''}, + {'name': 'position','selection': positions, 'value': false, 'string': 'Position'}]; this.add_widget = []; this.add_node_dialog = new openerp.web.Dialog(this,{ modal: true, title: 'Properties', - width: 500, - height: 300, + width: 430, + height: 190, buttons: { "Update": function(){ var check_add_node = true; @@ -828,17 +850,27 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }).start().open(); this.add_node_dialog.$element. - append('
    '); - var table_selector = self.add_node_dialog.$element.find('table[id=rec_table]'); + append('
    '); + var table_selector = self.add_node_dialog.$element.find('table[id=rec_table] tbody'); _.each(render_list,function(node){ type_widget = new openerp.web.ViewEditor.FieldSelect (self.add_node_dialog, node.name); type_widget.selection = node.selection; - table_selector.append('' + node.string + ':' + type_widget.render() + ''); + if(node.name == "position"){ + table_selector.append + ('' + node.string + ':' + type_widget.render() + ''); + }else{ + table_selector.append + ('' + node.string + '' + type_widget.render()); + if(node.name == "field_value"){ + table_selector.append + (' '); + } + } type_widget.start(); type_widget.set_value(node.value); self.add_widget.push(type_widget); }); - table_selector.append(' '); + table_selector.find("td").attr("width","100px"); self.add_node_dialog.$element.find('#new_field').click(function() { model_data = new openerp.web.DataSetSearch(self,'ir.model', null, null); model_data.read_slice([], {domain: [['model','=', self.model]]}, function(result) { @@ -953,9 +985,13 @@ openerp.web.ViewEditor.FieldSelect = openerp.web.ViewEditor.Field.extend({ this.$element.find("select[id=" + this.name + "]").css('width', '100%').change(function() { self.on_ui_change(); if(self.name == "node_type"){ - (self.get_value() == "field")? - self.$element.find("select[id=field_value]").show(): - self.$element.find("select[id=field_value]").hide(); + if(self.get_value() == "field"){ + self.$element.find('#new_field').show(); + self.$element.find("select[id=field_value]").show(); + }else{ + self.$element.find('#new_field').hide(); + self.$element.find("select[id=field_value]").hide(); + } } }); From b6a3215579fb924fbe24d064c7fec6328a3e7a1b Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Fri, 18 Nov 2011 11:41:40 +0530 Subject: [PATCH 137/278] [FIX] sale : pooled the objects in starting of method _create_pickings_and_procurements and then used in the function lp bug: https://launchpad.net/bugs/891596 fixed bzr revid: bde@tinyerp.com-20111118061140-whiqz9e03xyjle6q --- addons/sale/sale.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 62f979cb9c9..01c8277144b 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -757,6 +757,10 @@ class sale_order(osv.osv): will be added. A new picking will be created if ommitted. :return: True """ + move_obj = self.pool.get('stock.move') + picking_obj = self.pool.get('stock.picking') + procurement_order_obj = self.pool.get('procurement.order') + proc_ids = [] for line in order_lines: if line.state == 'done': @@ -768,13 +772,13 @@ class sale_order(osv.osv): if line.product_id: if line.product_id.product_tmpl_id.type in ('product', 'consu'): if not picking_id: - picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, *args)) - move_id = self.pool.get('stock.move').create(cr, uid, self._prepare_order_line_move(cr, uid, order, line, picking_id, date_planned, *args)) + picking_id = picking_obj.create(cr, uid, self._prepare_order_picking(cr, uid, order, *args)) + move_id = move_obj.create(cr, uid, self._prepare_order_line_move(cr, uid, order, line, picking_id, date_planned, *args)) else: # a service has no stock move move_id = False - proc_id = self.pool.get('procurement.order').create(cr, uid, self._prepare_order_line_procurement(cr, uid, order, line, move_id, date_planned, *args)) + proc_id = procurement_order_obj.create(cr, uid, self._prepare_order_line_procurement(cr, uid, order, line, move_id, date_planned, *args)) proc_ids.append(proc_id) line.write({'procurement_id': proc_id}) @@ -784,12 +788,12 @@ class sale_order(osv.osv): for pick in order.picking_ids: for move in pick.move_lines: if move.state == 'cancel': - mov_ids = self.pool.get('stock.move').search(cr, uid, [('state', '=', 'cancel'),('sale_line_id', '=', line.id),('picking_id', '=', pick.id)]) + mov_ids = move_obj.search(cr, uid, [('state', '=', 'cancel'),('sale_line_id', '=', line.id),('picking_id', '=', pick.id)]) if mov_ids: for mov in move_obj.browse(cr, uid, mov_ids): # FIXME: the following seems broken: what if move_id doesn't exist? What if there are several mov_ids? Shouldn't that be a sum? - self.pool.get('stock.move').write(cr, uid, [move_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty}) - self.pool.get('procurement.order').write(cr, uid, [proc_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty}) + move_obj.write(cr, uid, [move_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty}) + procurement_order_obj.write(cr, uid, [proc_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty}) wf_service = netsvc.LocalService("workflow") if picking_id: From 0aca8061fabf4dc02cfb3354f4ae1a4c38f25337 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Fri, 18 Nov 2011 15:29:05 +0530 Subject: [PATCH 138/278] [FIX] correct selection fields help. False not display in help text. lp bug: https://launchpad.net/bugs/890558 fixed bzr revid: ysa@tinyerp.com-20111118095905-guzif5hgr4m0nk2j --- addons/web/static/src/xml/base.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index fb7ccdf7d8e..0e06d202171 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -837,7 +837,7 @@
  • Selection:
      -
    • +
    • [] - From bd94429713543aee08abe8203d1740f6e5d378ff Mon Sep 17 00:00:00 2001 From: "Bharat (OpenERP)" Date: Fri, 18 Nov 2011 17:14:53 +0530 Subject: [PATCH 139/278] [FIX] hr : modified the workflow inorder to keep separate functionality between hr_expense and supplier_invoice bzr revid: bde@tinyerp.com-20111118114453-bd7vc3urjbepo3rt --- addons/hr_expense/hr_expense.py | 7 ++---- addons/hr_expense/hr_expense_view.xml | 1 - addons/hr_expense/hr_expense_workflow.xml | 27 ----------------------- 3 files changed, 2 insertions(+), 33 deletions(-) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index 650a58a16a1..478b8120935 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -82,7 +82,6 @@ class hr_expense_expense(osv.osv): ('accepted', 'Approved'), ('invoiced', 'Invoiced'), ('paid', 'Reimbursed'), - ('invoice_except', 'Invoice Exception'), ('cancelled', 'Refused')], 'State', readonly=True, help='When the expense request is created the state is \'Draft\'.\n It is confirmed by the user and request is sent to admin, the state is \'Waiting Confirmation\'.\ \nIf the admin accepts it, the state is \'Accepted\'.\n If an invoice is made for the expense request, the state is \'Invoiced\'.\n If the expense is paid to user, the state is \'Reimbursed\'.'), @@ -138,8 +137,9 @@ class hr_expense_expense(osv.osv): inv_ids.append(self.browse(cr, uid, id).invoice_id.id) return { 'name': _('Supplier Invoices'), + 'view_type': 'form', 'view_mode': 'form', - 'view_id': [res[1] if res else False], + 'view_id': [res and res[1] or False], 'res_model': 'account.invoice', 'context': "{'type':'out_invoice', 'journal_type': 'purchase'}", 'type': 'ir.actions.act_window', @@ -223,9 +223,6 @@ class hr_expense_expense(osv.osv): res = inv_id return res - def action_invoice_cancel(self, cr, uid, ids, context=None): - return self.write(cr, uid, ids, {'state': 'invoice_except'}, context=context) - hr_expense_expense() class product_product(osv.osv): diff --git a/addons/hr_expense/hr_expense_view.xml b/addons/hr_expense/hr_expense_view.xml index a832191bb90..786dc6beee2 100644 --- a/addons/hr_expense/hr_expense_view.xml +++ b/addons/hr_expense/hr_expense_view.xml @@ -106,7 +106,6 @@ '); - } - } + table_selector.append('' + node.string + ':' + type_widget.render() + ''); type_widget.start(); type_widget.set_value(node.value); self.add_widget.push(type_widget); }); - table_selector.find("td").attr("width","100px"); + table_selector.append(' '); self.add_node_dialog.$element.find('#new_field').click(function() { model_data = new openerp.web.DataSetSearch(self,'ir.model', null, null); model_data.read_slice([], {domain: [['model','=', self.model]]}, function(result) { @@ -985,13 +1012,9 @@ openerp.web.ViewEditor.FieldSelect = openerp.web.ViewEditor.Field.extend({ this.$element.find("select[id=" + this.name + "]").css('width', '100%').change(function() { self.on_ui_change(); if(self.name == "node_type"){ - if(self.get_value() == "field"){ - self.$element.find('#new_field').show(); - self.$element.find("select[id=field_value]").show(); - }else{ - self.$element.find('#new_field').hide(); - self.$element.find("select[id=field_value]").hide(); - } + (self.get_value() == "field")? + self.$element.find("select[id=field_value]").show(): + self.$element.find("select[id=field_value]").hide(); } }); From d28d46e26fdb5374185a5956ff5bbf43a658e82b Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Fri, 18 Nov 2011 21:27:13 +0100 Subject: [PATCH 142/278] [REF] audittrail: code refactoring. still not totally working x_x bzr revid: qdp-launchpad@openerp.com-20111118202713-e5f1mtzx3gyovdok --- addons/audittrail/audittrail.py | 213 ++++++++++++++++++++++++++------ 1 file changed, 172 insertions(+), 41 deletions(-) diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py index 454f925c0f5..6946511045e 100644 --- a/addons/audittrail/audittrail.py +++ b/addons/audittrail/audittrail.py @@ -245,33 +245,35 @@ class audittrail_objects_proxy(object_proxy): Logging function: This function performs the logging operation for create/read/unlink operation :param cr: the current row, from the database cursor, :param user_id: the current user’s ID, - :param model: Object whose values are being changed + :param model: record of ir.model related to the object which values are being changed :param method: method to log: create, read, unlink :param resource_data: list of data modified for the model :param pool: current db's pooler object. :param resource_pool: pooler object of the model who's values are being changed. :return:True """ - key1 = '%s_value'%(method == 'create' and 'new' or 'old') - key2 = '%s_value_text'%(method == 'create' and 'new' or 'old') - vals = { 'method': method, 'object_id': model.id,'user_id': user_id} - for resource, fields in resource_data.iteritems(): - lines = [] - for field_key, value in fields.iteritems(): - if field_key in ('__last_update', 'id'):continue - ret_val = self.get_value_text(cr, 1, pool, resource_pool, method, field_key, value, method != 'read') - line = { - 'name': field_key, - key1: value, - key2: ret_val and ret_val or value - } - lines.append(line) - if lines: - vals.update({'res_id': resource}) - log_id = pool.get('audittrail.log').create(cr, 1, vals) - self.create_log_line(cr, uid, log_id, model, lines) + #checking if an audittrail rule apply in super admin mode + if self.check_rules(cr, 1, model.model, method): + key1 = '%s_value'%(method == 'create' and 'new' or 'old') + key2 = '%s_value_text'%(method == 'create' and 'new' or 'old') + vals = {'method': method, 'object_id': model.id,'user_id': user_id} + for resource, fields in resource_data.iteritems(): + lines = [] + for field_key, value in fields.iteritems(): + if field_key in ('__last_update', 'id'):continue + ret_val = self.get_value_text(cr, 1, pool, resource_pool, method, field_key, value, method != 'read') + line = { + 'name': field_key, + key1: value, + key2: ret_val and ret_val or value + } + lines.append(line) + if lines: + vals.update({'res_id': resource}) + log_id = pool.get('audittrail.log').create(cr, 1, vals) + self.create_log_line(cr, 1, log_id, model, lines) return True - + def log_fct(self, cr, uid, model, method, fct_src, *args): """ Logging function: This function is performing the logging operation @@ -292,21 +294,23 @@ class audittrail_objects_proxy(object_proxy): model = model_pool.browse(cr, uid, model_id) relational_table_log = True if (args and args[-1] == 'child_relation_log') else False + print model.model + print method + print ">>>>>>>" if method == 'create': resource_data = {} fields_to_read = [] if relational_table_log: - res_id = args[0] + res = args[0] else: - res_id = fct_src(cr, uid_orig, model.model, method, *args) + res = fct_src(cr, uid_orig, model.model, method, *args) fields_to_read = args[0].keys() - if res_id: - resource = resource_pool.read(cr, uid, res_id, fields_to_read) + if res: + resource = resource_pool.read(cr, uid, res, fields_to_read) if not isinstance(resource,list): resource = [resource] map(lambda x: resource_data.setdefault(x['id'], x), resource) self.start_log_process(cr, uid_orig, model, method, resource_data, pool, resource_pool) - return res_id elif method in('read', 'unlink'): res_ids = args[0] @@ -320,7 +324,6 @@ class audittrail_objects_proxy(object_proxy): self.start_log_process(cr, uid_orig, model, method, old_values, pool, resource_pool) if not relational_table_log and method == 'unlink': res = fct_src(cr, uid_orig, model.model, method, *args) - return res else: #method is write or workflow action res_ids = [] res = True @@ -334,18 +337,142 @@ class audittrail_objects_proxy(object_proxy): res_ids = [res_ids] if res_ids: #store the old values into a dictionary - old_values = self.process_data(cr, uid_orig, pool, res_ids, model, method, type='old') + old_values = self.get_data(cr, uid_orig, pool, res_ids, model, method) #process the original function or workflow trigger res = fct_src(cr, uid_orig, model.model, method, *args) if method == 'copy': res_ids = [res] if res_ids: - #check the new value and log the changes if any - self.process_data(cr, uid_orig, pool, res_ids, model, method, old_values) - return res + #check the new value and store them into a dictionary + new_values = self.get_data(cr, uid_orig, pool, res_ids, model, method) + self.process_data(cr, uid_orig, pool, res_ids, model, method, old_values, new_values) + return res + + def get_data(self, cr, uid_orig, pool, res_ids, model, method): + """ + This is specially created to log actions and workflow actions on an object recursively. + It processes and iterates recursively on old data (i.e before the method was executed ) + and stores it in a dict. Then this dict is used to compare with the new data + (i.e after the method execution) and log the changes. + + :param cr: the current row, from the database cursor, + :param uid_orig: the current user’s ID, + :param pool: current db's pooler object. + :param res_ids: Id's of resource to be logged/compared. + :param model: Object whose values are being changed + :param method: method to log: create, read, unlink,write,actions,workflow actions + :return: dict mapping a tuple (model_id, resource_id) with its value and textual value + { (model_id, resource_id): { 'value': ... + 'textual_value': ... + }, + } + """ + data = {} + # read all the field of the given resource in super admin mode + resource_pool = pool.get(model.model) + for resource in resource_pool.read(cr, 1, res_ids): + values_text = {} + values = {} + resource_id = resource['id'] + for field in resource: + if field in ('__last_update', 'id'): + continue + values[field] = resource[field] + ret_val = self.get_value_text(cr, 1, pool, resource_pool, method, field, resource[field], False) + values_text[field] = ret_val and ret_val or resource[field] + data[(model.id, resource_id)] = {'text':values_text, 'value': values} + field_obj = resource_pool._all_columns.get(field).column + if field_obj._type in ('one2many','many2many'): + #checking if an audittrail rule apply in super admin mode + if self.check_rules(cr, 1, field_obj._obj, method): + #checking if the model associated to a *2m field exists, in super admin mode + x2m_model_ids = pool.get('ir.model').search(cr, 1, [('model', '=', field_obj._obj)]) + x2m_model_id = x2m_model_ids and x2m_model_ids[0] or False + assert x2m_model_id, _("'%s' Model does not exist..." %(field_obj._obj)) + x2m_model = pool.get('ir.model').browse(cr, 1, x2m_model_id) + data.update(self.get_data(cr, 1, pool, resource[field], x2m_model, method)) + return data + + def prepare_audittrail_log_line(self, cr, uid, pool, model, resource, method, old_values, new_values): + lines = { + (model.id, resource['id']): [] + } + for field in resource: + if field in ('__last_update', 'id'): + continue + field_obj = (pool.get(model.model)._all_columns.get(field)).column + if field_obj._type in ('one2many','many2many'): + #checking if an audittrail rule apply in super admin mode + if self.check_rules(cr, 1, field_obj._obj, method): + #checking if the model associated to a *2m field exists, in super admin mode + x2m_model_ids = pool.get('ir.model').search(cr, 1, [('model', '=', field_obj._obj)]) + x2m_model_id = x2m_model_ids and x2m_model_ids[0] or False + assert x2m_model_id, _("'%s' Model does not exist..." %(field_obj._obj)) + x2m_model = pool.get('ir.model').browse(cr, 1, x2m_model_id) + if resource[field]: + for resource_id in resource[field]: + x2many_new_values = new_values[(x2m_model_id, resource_id)] + x2many_new_values.update({'id': resource['id']}) + x = self.prepare_audittrail_log_line(cr, 1, pool, x2m_model, x2many_new_values, method, old_values.get((x2m_model_id, resource_id),{}), x2many_new_values) + lines.update(x) + # if the value value is different than the old value: record the change + if old_values[(model.id, resource['id'])]['value'][field] != new_values[(model.id, resource['id'])]['value'][field]: + data = { + 'name': field, + 'new_value': resource[field], + 'old_value': (model.id, resource['id']) in old_values and old_values[(model.id, resource['id'])]['value'].get(field), + 'new_value_text': (model.id, resource['id']) in new_values and new_values[(model.id, resource['id'])]['text'].get(field), + 'old_value_text': (model.id, resource['id']) in old_values and old_values[(model.id, resource['id'])]['text'].get(field) + } + lines[(model.id, resource['id'])].append(data) + return lines + + def process_data(self, cr, uid, pool, res_ids, model, method, old_values={}, new_values={}): + """ + This is specially created to log actions and workflow actions on an object recursively. + It processes and iterates recursively on old data (i.e before the method was executed ) + and stores it in a dict. Then this dict is used to compare with the new data + (i.e after the method execution) and log the changes. + + :param cr: the current row, from the database cursor, + :param uid: the current user’s ID, + :param pool: current db's pooler object. + :param res_ids: Id's of resource to be logged/compared. + :param model: Object whose values are being changed + :param method: method to log: create, read, unlink,write,actions,workflow actions + :param original_values: dict of values of res_ids read before execution of the method only when type is 'new' + :param type: Either of 'new' or 'old' to know which data to process. + :return: dict of values + """ + # read all the field of the given resource in super admin mode + for resource in pool.get(model.model).read(cr, 1, res_ids): + lines = self.prepare_audittrail_log_line(cr, uid, pool, model, resource, method, old_values, new_values) + + # if at least one modification has been found + for model_id, resource_id in lines: + vals = { + 'method': method, + 'object_id': model_id, + 'user_id': uid, + 'res_id': resource_id, + } + if (model_id, resource_id) not in old_values and method !='copy': + # the resource was not existing so we are forcing the method to 'create' + # (because it could also come with the value 'write' if we are creating + # new record through a one2many field) + vals.update({'method': 'create'}) + if (model_id, resource_id) not in new_values and method !='copy': + # the resource is not existing anymore so we are forcing the method to 'unlink' + # (because it could also come with the value 'write' if we are deleting the + # record through a one2many field) + vals.update({'method': 'unlink'}) + # create the audittrail log in super admin mode + log_id = pool.get('audittrail.log').create(cr, 1, vals) + model = pool.get('ir.model').browse(cr, uid, model_id) + self.create_log_line(cr, 1, log_id, model, lines[(model_id, resource_id)]) return True - def process_data(self, cr, uid_orig, pool, res_ids, model, method, original_values={}, type='new'): + def process_data_old(self, cr, uid_orig, pool, res_ids, model, method, original_values={}, type='new'): """ This is specially created to log actions and workflow actions on an object recursively. It processes and iterates recursively on old data (i.e before the method was executed ) @@ -369,15 +496,7 @@ class audittrail_objects_proxy(object_proxy): _old_values_text = {} _old_value = {} resource_id = resource['id'] - if type == 'new': - vals = {'method': method,'object_id': model.id,'user_id': uid_orig } - vals.update({'res_id': resource_id}) - if resource_id not in original_values and method !='copy': - # the resource was not existing so we are forcing the method to 'create' - # (because it could also come with the value 'write' if we are creating - # new record through a one2many field) - vals.update({'method': 'create'}) - lines = [] + lines = [] for field in resource: if field in ('__last_update', 'id'):continue field_obj = (resource_pool._all_columns.get(field)).column @@ -406,6 +525,18 @@ class audittrail_objects_proxy(object_proxy): _old_values_text[field] = ret_val and ret_val or resource[field] if type == 'new': if lines: + vals = { + 'method': method, + 'object_id': model.id, + 'user_id': uid_orig, + 'res_id': resource_id, + } + if resource_id not in original_values and method !='copy': + # the resource was not existing so we are forcing the method to 'create' + # (because it could also come with the value 'write' if we are creating + # new record through a one2many field) + vals.update({'method': 'create'}) + # create the audittrail log in super admin mode log_id = pool.get('audittrail.log').create(cr, 1, vals) self.create_log_line(cr, 1, log_id, model, lines) else: @@ -417,7 +548,7 @@ class audittrail_objects_proxy(object_proxy): Checks if auditrails is installed for that db and then if one rule match @param cr: the current row, from the database cursor, @param uid: the current user’s ID, - @param model: Object whose values are being changed + @param model: value of _name of the object which values are being changed @param method: method to log: create, read, unlink,write,actions,workflow actions @return: True or False """ From 96212584c4a1e07aee66b5dfb0e64fa5fbafcaca Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Mon, 21 Nov 2011 15:43:26 +0530 Subject: [PATCH 143/278] [IMP]make sequence for add node and edit node dialog box. bzr revid: vme@tinyerp.com-20111121101326-xyhlum8idixqgkhr --- addons/web/static/src/js/view_editor.js | 139 +++++++++++++----------- addons/web/static/src/xml/base.xml | 2 +- 2 files changed, 77 insertions(+), 64 deletions(-) diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index 547b6e582f5..f578d9da006 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -432,6 +432,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ on_select_img: function(element_img){ var self = this; + console.log("kooooo",element_img); var side = $(element_img).closest("tr[id^='viewedit-']"); this.one_object.clicked_tr_id = parseInt((side.attr('id')).split('-')[1]); this.one_object.clicked_tr_level = parseInt(side.attr('level')); @@ -453,7 +454,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ (self.edit_xml_dialog.$element.find(view_find).find('a').text()).search("view_id") != -1 && parseInt(view_find.attr('level')) < min_level ) { view_id = parseInt(($(view_find).find('a').text()).replace(/[^0-9]+/g, '')); - view_xml_id = (view_find.attr('id')).split('-')[1]; + view_xml_id = parseInt((view_find.attr('id')).split('-')[1]); break; } if(view_find.attr('level') < min_level){ @@ -468,8 +469,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ break; case "side-remove": if (confirm(_t("Do you really want to remove this node?"))) { - self.do_save_update_arch - (one_object, view_id, view_xml_id, clicked_tr_id, clicked_tr_level, "remove_node"); + self.do_save_update_arch("remove_node"); } break; case "side-edit": @@ -498,9 +498,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ return _.includes(element, res); })); }); - console.log(property_to_check,fields); - //self.on_add_node(property_to_check, fields , - // clicked_tr_id, one_object, view_id, view_xml_id, clicked_tr_level); + self.on_add_node(property_to_check, fields); }); }, do_node_edit: function(side){ @@ -510,8 +508,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ return _.includes(tr, res); }); var properties = _PROPERTIES[tag]; - console.log(properties); - //self.on_edit_node(properties, clicked_tr_id, one_object, view_id, view_xml_id, clicked_tr_level); + self.on_edit_node(properties); }, do_node_down: function(cur_tr, img){ var self = this; @@ -553,7 +550,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ _.each(tr_to_move, function(rec) { $(last_tr).after(rec); }); - // self.do_save_update_arch(one_object, view_id, view_xml_id, clicked_tr_id, clicked_tr_level, "down"); + self.do_save_update_arch("down"); } }, do_node_up: function(cur_tr, img){ @@ -588,13 +585,14 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ _.each(tr_to_move, function(rec) { $(last_tr).before(rec); }); - //self.do_save_update_arch(one_object, view_id, view_xml_id, clicked_tr_id, clicked_tr_level, "up"); + self.do_save_update_arch("up"); } }, - do_save_update_arch: function(one_object, view_id, view_xml_id, clicked_tr_id, clicked_tr_level, move_direct, update_values) { + do_save_update_arch: function(move_direct, update_values) { var self = this; - var arch = _.detect(one_object['arch'], function(element) {return element.view_id == view_id;}); - var obj = self.get_object_by_id(view_xml_id, one_object['main_object'], []); + var arch = _.detect(self.one_object['arch'], function(element) + {return element.view_id == self.one_object.clicked_tr_view[0]}); + var obj = self.get_object_by_id(this.one_object.clicked_tr_view[1],this.one_object['main_object'], []); //for finding xpath tag from inherit view var xml_arch = QWeb.load_xml(arch.arch); if (xml_arch.childNodes[0].tagName == "data") { @@ -612,44 +610,63 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ return child.nodeType == 1; }); - return self.do_save_xml(arch_to_pass[0], obj[0].child_id[0], - parseInt(clicked_tr_id), [], parseInt(clicked_tr_level), - parseInt(view_id), arch, move_direct, update_values); + return self.do_save_xml(arch_to_pass[0], obj[0].child_id[0],[], move_direct, update_values,arch); }, - get_object_by_id: function(view_xml_id, one_object, result) { + get_object_by_id: function(id ,one_object, result) { var self = this; if (result.length == 0 ) { var check = _.detect(one_object , function(obj) { - return view_xml_id == obj.id; + return self.one_object.clicked_tr_view[1] == obj.id; }); if (check) {result.push(check);}; _.each(one_object, function(obj) { - self.get_object_by_id(view_xml_id, obj.child_id, result); + self.get_object_by_id(id,obj.child_id, result); }); } return result; }, - do_save_xml: function(arch1, obj, id, child_list, level, view_id, arch, move_direct, update_values){ + create_clone: function(clone, new_node_obj){ + var self = this; + clone.find('a').text(new_node_obj.name); + clone.attr("id","viewedit-" + new_node_obj.id); + clone.attr("level",new_node_obj.level); + clone.find("img[id^='parentimg-']").remove(); + clone.bind("click",function(){ + self.do_select_row(this.id.split('-')[1]); + }); + clone.find("img[id^='side-']").click(function() { + self.on_select_img(this); + }); + clone.find("img[id^='parentimg-']").click(function() { + self.do_parent_img_hide_show(this); + }); + return clone; + }, + do_save_xml: function(arch1, obj, child_list, move_direct, update_values, arch){ var self = this; var children_list = $(arch1).children(); var list_obj_xml = _.zip(children_list, obj.child_id); - if (id) { - if (obj.id == id) { - var id; + if (this.one_object.clicked_tr_id) { + if (obj.id == this.one_object.clicked_tr_id) { + var parent; var index = _.indexOf(child_list, obj); if (move_direct == "down") { var next = $(arch1).next(); $(next).after(arch1); var re_insert_obj = child_list.splice(index, 1); child_list.splice(index+1, 0, re_insert_obj[0]); - var parent = $(arch1).parents(); + parent = $(arch1).parents(); + } else if (move_direct == "up") { + var prev = $(arch1).prev(); $(prev).before(arch1); var re_insert_obj = child_list.splice(index, 1); child_list.splice(index-1, 0, re_insert_obj[0]); - var parent = $(arch1).parents(); + parent = $(arch1).parents(); + } else if (move_direct == "update_node") { + _.each(update_values, function(val){ if(val[0] == "required"){ $(arch1).attr("required", "true"); @@ -659,45 +676,40 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); var new_obj = self.create_View_Node(arch1); new_obj.id = obj.id,new_obj.child_id = obj.child_id; - self.edit_xml_dialog.$element.find("tr[id='viewedit-"+id+"']").find('a').text(new_obj.name); + self.edit_xml_dialog.$element.find("tr[id='viewedit-"+self.one_object.clicked_tr_id+"']") + .find('a').text(new_obj.name); child_list.splice(index, 1, new_obj); - var parent = $(arch1).parents(); + parent = $(arch1).parents(); + }else if(move_direct == "add_node"){ var temp_xml = QWeb.load_xml(update_values[0]); var object_xml = self.create_View_Node(temp_xml.childNodes[0]); - var clone = self.edit_xml_dialog.$element.find("tr[id='viewedit-"+id+"']").clone(); - clone.find('a').text(object_xml.name); - clone.attr("id","viewedit-" + object_xml.id ); - clone.bind("click",function(){ - self.do_select_row(object_xml.id); - }); - clone.find("img[id^='side-']").click(function() { - self.on_select_img(this); - }); - clone.find("img[id^='parentimg-']").click(function() { - self.do_parent_img_hide_show(this); - }); + (update_values[1] == "Inside")? object_xml.level = obj.level + 1:object_xml.level = obj.level; + var clone = self.create_clone(self.edit_xml_dialog.$element. + find("tr[id='viewedit-"+self.one_object.clicked_tr_id+"']").clone(),object_xml); switch (update_values[1]) { case "After": - object_xml.level = obj.level; $(arch1).after(update_values[0]); child_list.splice(index + 1, 0, object_xml); break; case "Before": - object_xml.level = obj.level; $(arch1).before(update_values[0]); child_list.splice(index - 1, 0, object_xml); break; case "Inside": - object_xml.level = obj.level + 1; $(arch1).append(update_values[0]); obj.child_id.push(object_xml); break; } - self.edit_xml_dialog.$element.find("tr[id='viewedit-"+id+"']").after(clone); - var parent = $(arch1).parents(); + self.edit_xml_dialog.$element. + find("tr[id='viewedit-"+self.one_object.clicked_tr_id+"']").after(clone); + self.edit_xml_dialog.$element. + find("tr[id='viewedit-" + object_xml.id + "']").removeClass('ui-selected'); + parent = $(arch1).parents(); + }else if(move_direct == "remove_node"){ - var parent = $(arch1).parents(); + + parent = $(arch1).parents(); if(parent.length == 0 || (parent[0].tagName.toLowerCase() == "data")){ id = id -1; level = level - 1; @@ -705,33 +717,35 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } $(arch1).remove(); child_list.splice(index,1); - var cur_tr = self.edit_xml_dialog.$element.find("tr[id='viewedit-"+id +"']"); - _.each(self.get_list_tr(cur_tr,level), function(tr_element){ + var cur_tr = self.edit_xml_dialog.$element. + find("tr[id='viewedit-" + self.one_object.clicked_tr_id + "']"); + _.each(self.get_list_tr(cur_tr,self.one_object.clicked_tr_level), function(tr_element){ tr_element.remove(); }); cur_tr.remove(); } + var convert_to_utf = (parent.length != 0)?parent[parent.length-1]:arch1; - /*if(convert_to_utf != "remove_view"){ + if(convert_to_utf != "remove_view"){ convert_to_utf = QWeb.tools.xml_node_to_string(convert_to_utf); convert_to_utf = convert_to_utf.replace('xmlns="http://www.w3.org/1999/xhtml"', ""); convert_to_utf = '' + convert_to_utf; arch.arch = convert_to_utf; - this.dataset.write(parseInt(view_id),{"arch":convert_to_utf}, function(r) { - }); + /*this.dataset.write(this.one_object.clicked_tr_view[0] ,{"arch":convert_to_utf}, function(r) { + });*/ }else{ - this.dataset.unlink([parseInt(view_id)],function(res) { - }); + //this.dataset.unlink([this.one_object.clicked_tr_view[0]],function(res) { + //}); } if(move_direct == "add_node"){ self.add_node_dialog.close(); - self.edit_xml_dialog.close(); - self.xml_element_id = 0; - self.get_arch();}*/ + self.on_select_img(clone.find("img[id='side-edit']")[0]); + } } - if (obj.level <= level) { + if (obj.level <= this.one_object.clicked_tr_level) { _.each(list_obj_xml, function(child_node) { - self.do_save_xml(child_node[0], child_node[1], id, obj.child_id, level, view_id, arch, move_direct, update_values); + self.do_save_xml(child_node[0], child_node[1], obj.child_id, + move_direct, update_values, arch); }); } } @@ -765,7 +779,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ tr.show(); }); }, - on_edit_node:function(properties, clicked_tr_id, obj, view_id, view_xml_id, clicked_tr_level){ + on_edit_node:function(properties){ var self = this; this.edit_node_dialog = new openerp.web.Dialog(this,{ modal: true, @@ -780,7 +794,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ update_values.push([widget.name, widget.get_value()]); } }); - self.do_save_update_arch(obj, view_id, view_xml_id, clicked_tr_id, clicked_tr_level, "update_node", update_values); + self.do_save_update_arch("update_node", update_values); self.edit_node_dialog.close(); }, "Cancel": function(){ @@ -790,7 +804,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }); this.edit_node_dialog.start().open(); var widget = _.keys(self.property.map); - var arch_val = self.get_object_by_id(clicked_tr_id,obj['main_object'], []); + var arch_val = self.get_object_by_id(this.one_object.clicked_tr_id,this.one_object['main_object'], []); this.edit_node_dialog.$element.append('
      '); this.edit_widget = []; _.each(properties, function(property) { @@ -846,7 +860,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ }) return def.promise(); }, - on_add_node: function(properties,fields,clicked_tr_id, one_object, view_id, view_xml_id, clicked_tr_level){ + on_add_node: function(properties, fields){ var self = this; var positions = ['After','Before','Inside']; var render_list = []; @@ -877,8 +891,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var tag = (values.node_type == "field")? _.sprintf("<%s name='%s'> ",values.node_type,values.field_value,values.node_type): _.sprintf("<%s> ",values.node_type,values.node_type); - self.do_save_update_arch(one_object, view_id, view_xml_id, - clicked_tr_id, clicked_tr_level, "add_node", [tag, values.position]); + self.do_save_update_arch("add_node", [tag, values.position]); }else{alert("Can't Update View");} }, "Cancel": function(){ diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 9b1c5175571..25cfaee1232 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1692,4 +1692,4 @@
      - \ No newline at end of file + From 263ff95a19e236ba5707790ca1c8650a940abcb0 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 21 Nov 2011 17:06:17 +0530 Subject: [PATCH 144/278] [imp] nivified product list bzr revid: nicolas.vanhoren@openerp.com-20111121113617-75h2d5ka302rnf3c --- addons/point_of_sale/static/src/js/pos.js | 41 ++++++++++----------- addons/point_of_sale/static/src/xml/pos.xml | 5 ++- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/addons/point_of_sale/static/src/js/pos.js b/addons/point_of_sale/static/src/js/pos.js index d4fbfc6f6ed..2a66005af2c 100644 --- a/addons/point_of_sale/static/src/js/pos.js +++ b/addons/point_of_sale/static/src/js/pos.js @@ -166,7 +166,7 @@ openerp.point_of_sale = function(db) { NumpadState, NumpadWidget, Order, OrderButtonView, OrderCollection, OrderWidget, Orderline, OrderlineCollection, OrderlineWidget, PaymentButtonWidget, PaymentView, Paymentline, PaymentlineCollection, PaymentlineView, PaypadWidget, Product, ProductCollection, - ProductListView, ProductWidget, ReceiptLineView, ReceiptView, Shop, ShopView, StepsWidget; + ProductListWidget, ProductWidget, ReceiptLineView, ReceiptView, Shop, ShopView, StepsWidget; /* --- @@ -776,31 +776,24 @@ openerp.point_of_sale = function(db) { return this; }, }); - ProductListView = (function() { - __extends(ProductListView, Backbone.View); - function ProductListView() { - ProductListView.__super__.constructor.apply(this, arguments); - } - - ProductListView.prototype.tagName = 'ol'; - ProductListView.prototype.className = 'product-list'; - ProductListView.prototype.initialize = function(options) { + ProductListWidget = db.web.Widget.extend({ + init: function(parent, element_id, options) { + this._super(parent, element_id); this.shop = options.shop; - return (this.shop.get('products')).bind('reset', this.render, this); - }; - ProductListView.prototype.render = function() { - $(this.el).empty(); + this.shop.get('products').bind('reset', this.render_element, this); + }, + render_element: function() { + this.$element.empty(); (this.shop.get('products')).each(__bind( function(product) { var p = new ProductWidget(null, null, { model: product, shop: this.shop }); - p.appendTo($(this.el)); + p.appendTo(this.$element); }, this)); - return $('#products-screen').append(this.el); - }; - return ProductListView; - })(); + return this; + }, + }); /* "Payment" step. */ @@ -1053,9 +1046,11 @@ openerp.point_of_sale = function(db) { this.numpadState = new NumpadState({ shop: this.shop }); - this.productListView = new ProductListView({ + this.productListView = new ProductListWidget(null, "products-screen-ol", { shop: this.shop }); + this.productListView.render_element(); + this.productListView.start(); this.paypadView = new PaypadWidget(null, 'paypad', { shop: this.shop }); @@ -1080,10 +1075,14 @@ openerp.point_of_sale = function(db) { this.numpadView.start(); this.stepsView = new StepsWidget(null, 'steps'); this.stepsView.start(); + this.start(); }; ShopView.prototype.events = { 'click button#neworder-button': 'createNewOrder' }; + ShopView.prototype.start = function() { + this.productListView.start(); + }; ShopView.prototype.createNewOrder = function() { var newOrder; newOrder = new Order; @@ -1114,7 +1113,7 @@ openerp.point_of_sale = function(db) { shop: this.shop, el: $element }); - this.categoryView = new CategoryWidget(null, 'products-screen'); + this.categoryView = new CategoryWidget(null, 'products-screen-categories'); this.categoryView.on_change_category.add_last(_.bind(this.category, this)); this.category(); }; diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index b9148395cbe..feeec5bdc4c 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -88,7 +88,10 @@
      -
      +
      +
      +
        +