From c19999edf859b29c9d521ab58e701af5b74aa4ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Degrave?= Date: Wed, 29 Dec 2010 09:18:04 +0100 Subject: [PATCH 01/24] [IMP+FIX] HR access rights, product margin bzr revid: fde@openerp.com-20101229081804-ci2v2t9fhtmc1d3d --- addons/hr_contract/hr_contract_view.xml | 3 ++- addons/hr_contract/security/ir.model.access.csv | 1 - addons/hr_timesheet_sheet/security/ir.model.access.csv | 1 - addons/product_margin/product_margin_view.xml | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/hr_contract/hr_contract_view.xml b/addons/hr_contract/hr_contract_view.xml index 3fe9338bd69..35d375fea1d 100644 --- a/addons/hr_contract/hr_contract_view.xml +++ b/addons/hr_contract/hr_contract_view.xml @@ -275,7 +275,8 @@ id="act_hr_employee_2_hr_contract" name="Contracts" res_model="hr.contract" - src_model="hr.employee"/> + src_model="hr.employee" + groups="base.group_hr_manager"/> diff --git a/addons/hr_contract/security/ir.model.access.csv b/addons/hr_contract/security/ir.model.access.csv index 36456284856..202fcb3bdb4 100644 --- a/addons/hr_contract/security/ir.model.access.csv +++ b/addons/hr_contract/security/ir.model.access.csv @@ -1,7 +1,6 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" "access_hr_contract_wage_type_period_user","hr.contract.wage.type.period.user","model_hr_contract_wage_type_period","base.group_hr_user",1,1,1,1 "access_hr_contract_wage_type_user","hr.contract.wage.type.user","model_hr_contract_wage_type","base.group_hr_user",1,1,1,1 -"access_hr_contract_user","hr.contract.user","model_hr_contract","base.group_hr_user",1,1,1,1 "access_hr_resource_manager","hr.employee.resource.manager","resource.model_resource_resource","base.group_hr_manager",1,1,1,1 "access_hr_resource_calendar_user","hr.employee.resource.calendar.user","resource.model_resource_calendar","base.group_hr_user",1,1,1,1 "access_hr_contract_type_manager","hr.contract.type.manager","model_hr_contract_type","base.group_hr_manager",1,1,1,1 diff --git a/addons/hr_timesheet_sheet/security/ir.model.access.csv b/addons/hr_timesheet_sheet/security/ir.model.access.csv index f55ee0fb5e0..9d0159bbc1a 100644 --- a/addons/hr_timesheet_sheet/security/ir.model.access.csv +++ b/addons/hr_timesheet_sheet/security/ir.model.access.csv @@ -6,4 +6,3 @@ "access_hr_timesheet_report","hr.timesheet.report","model_hr_timesheet_report","base.group_hr_manager",1,1,1,1 "access_hr_analytic_timesheet_system_user","hr.analytic.timesheet.system.user","model_hr_analytic_timesheet","base.group_user",1,0,0,0 "access_hr_timesheet_sheet_sheet_day","hr.timesheet.sheet.sheet.day.user","model_hr_timesheet_sheet_sheet_day","base.group_user",1,0,0,0 -"access_timesheet_report_user","timesheet.report.user","model_timesheet_report","base.group_hr_manager",1,1,1,1 diff --git a/addons/product_margin/product_margin_view.xml b/addons/product_margin/product_margin_view.xml index 00ec98ab1e0..a6d6eff5238 100644 --- a/addons/product_margin/product_margin_view.xml +++ b/addons/product_margin/product_margin_view.xml @@ -84,7 +84,7 @@ - + From 20ab1d1df486811dd8ed0ae1700863c0e36e2b63 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Wed, 29 Dec 2010 14:27:16 +0530 Subject: [PATCH 02/24] [FIX] account: security bzr revid: hmo@tinyerp.com-20101229085716-y13ctpn3ptenrfl0 --- addons/account/security/ir.model.access.csv | 2 -- addons/hr_expense/security/ir.model.access.csv | 2 ++ addons/hr_timesheet/security/ir.model.access.csv | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/account/security/ir.model.access.csv b/addons/account/security/ir.model.access.csv index 68839c8f18c..fe98ef7a403 100644 --- a/addons/account/security/ir.model.access.csv +++ b/addons/account/security/ir.model.access.csv @@ -9,9 +9,7 @@ "access_account_account_user","account.account user","model_account_account","base.group_user",1,0,0,0 "access_account_account_partner_manager","account.account partner manager","model_account_account","base.group_partner_manager",1,0,0,0 "access_account_journal_view","account.journal.view","model_account_journal_view","account.group_account_user",1,0,0,0 -"access_account_journal_view_hruser","account.journal.view hruser","model_account_journal_view","base.group_hr_user",1,0,0,0 "access_account_journal_column","account.journal.column","model_account_journal_column","account.group_account_user",1,0,0,0 -"access_account_journal_column_hruser","account.journal.column hruser","model_account_journal_column","base.group_hr_user",1,0,0,0 "access_account_journal","account.journal","model_account_journal","account.group_account_user",1,0,0,0 "access_account_period","account.period","model_account_period","account.group_account_user",1,0,0,0 "access_account_journal_period_manager","account.journal.period manager","model_account_journal_period","account.group_account_manager",1,0,0,0 diff --git a/addons/hr_expense/security/ir.model.access.csv b/addons/hr_expense/security/ir.model.access.csv index 2b5b9ffb28c..47b7e32e8dd 100644 --- a/addons/hr_expense/security/ir.model.access.csv +++ b/addons/hr_expense/security/ir.model.access.csv @@ -17,3 +17,5 @@ "access_account_move_line_user","account.move.line.user","account.model_account_move_line","base.group_hr_user",1,1,1,1 "access_account_analytic_line_user","account.ianalytic.line.user","account.model_account_analytic_line","base.group_hr_user",1,1,1,1 "access_account_journal_period_manager","account.journal.period.manager","account.model_account_journal_period","base.group_hr_manager",1,1,1,1 +"hr.access_account_journal_view_hruser","account.journal.view hruser","account.model_account_journal_view","base.group_hr_user",1,0,0,0 +"hr.access_account_journal_column_hruser","account.journal.column hruser","account.model_account_journal_column","base.group_hr_user",1,0,0,0 diff --git a/addons/hr_timesheet/security/ir.model.access.csv b/addons/hr_timesheet/security/ir.model.access.csv index 40ac84200ef..50c71564f32 100644 --- a/addons/hr_timesheet/security/ir.model.access.csv +++ b/addons/hr_timesheet/security/ir.model.access.csv @@ -6,3 +6,5 @@ "access_product_template_hr_timesheet","product.template.hr.timesheet","product.model_product_template","base.group_hr_user",1,1,1,1 "access_product_uom_hr_timesheet","product.uom.hr.timesheet","product.model_product_uom","base.group_hr_user",1,1,1,1 "access_account_fiscalyear_hr_user","account.account.fiscalyear.user","account.model_account_fiscalyear","base.group_hr_user",1,1,1,1 +"hr.access_account_journal_view_hruser","account.journal.view hruser","account.model_account_journal_view","base.group_hr_user",1,0,0,0 +"hr.access_account_journal_column_hruser","account.journal.column hruser","account.model_account_journal_column","base.group_hr_user",1,0,0,0 From 3179f235f3fdd5626ccf579a06e8119243249dc3 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Wed, 29 Dec 2010 14:39:24 +0530 Subject: [PATCH 03/24] [FIX] product_manufacturer: security bzr revid: hmo@tinyerp.com-20101229090924-wzavbi0r8srtdlh5 --- addons/product_manufacturer/security/ir.model.access.csv | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/product_manufacturer/security/ir.model.access.csv b/addons/product_manufacturer/security/ir.model.access.csv index c12946db678..b00c562dd43 100644 --- a/addons/product_manufacturer/security/ir.model.access.csv +++ b/addons/product_manufacturer/security/ir.model.access.csv @@ -1,6 +1,5 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" "access_product_manufacturer_attribute","product.manufacturer.attribute","model_product_manufacturer_attribute",base.group_user,1,0,0,0 "access_product_manufacturer_attribute sale_manager","product.manufacturer.attribute","model_product_manufacturer_attribute","base.group_sale_manager",1,1,1,1 -"access_product_manufacturer_attribute_purchasemanager","product.manufacturer.attribute purchasemanager","model_product_manufacturer_attribute","purchase.group_purchase_manager",1,1,1,1 "access_product_manufacturer_attribute_stockmanager","product.manufacturer.attribute stockmanager","model_product_manufacturer_attribute","stock.group_stock_manager",1,1,1,1 -"access_product_manufacturer_attribute_mrpmanager","product.manufacturer.attribute mrpmanager","model_product_manufacturer_attribute","mrp.group_mrp_manager",1,1,1,1 + From 7e112b7fd253e242a23ce1bf20eeccb0cff020a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Degrave?= Date: Wed, 29 Dec 2010 10:25:06 +0100 Subject: [PATCH 04/24] [FIX] product_manufacturer access rights bzr revid: fde@openerp.com-20101229092506-j8anb9cxtzoj4n4c --- addons/product_manufacturer/security/ir.model.access.csv | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/product_manufacturer/security/ir.model.access.csv b/addons/product_manufacturer/security/ir.model.access.csv index b00c562dd43..b06d5d3ea96 100644 --- a/addons/product_manufacturer/security/ir.model.access.csv +++ b/addons/product_manufacturer/security/ir.model.access.csv @@ -1,5 +1,2 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" -"access_product_manufacturer_attribute","product.manufacturer.attribute","model_product_manufacturer_attribute",base.group_user,1,0,0,0 -"access_product_manufacturer_attribute sale_manager","product.manufacturer.attribute","model_product_manufacturer_attribute","base.group_sale_manager",1,1,1,1 -"access_product_manufacturer_attribute_stockmanager","product.manufacturer.attribute stockmanager","model_product_manufacturer_attribute","stock.group_stock_manager",1,1,1,1 - +"access_product_manufacturer_attribute","product.manufacturer.attribute","model_product_manufacturer_attribute",base.group_user,1,1,1,1 From cd3c1bcf121ec2a996400246bd1b8501f7ddceb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Degrave?= Date: Wed, 29 Dec 2010 10:30:25 +0100 Subject: [PATCH 05/24] [FIX] report_intrastat access rights bzr revid: fde@openerp.com-20101229093025-n4gjwyr0a9zjz74i --- addons/report_intrastat/security/ir.model.access.csv | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/report_intrastat/security/ir.model.access.csv b/addons/report_intrastat/security/ir.model.access.csv index f1a72c60072..f59d76ed536 100644 --- a/addons/report_intrastat/security/ir.model.access.csv +++ b/addons/report_intrastat/security/ir.model.access.csv @@ -4,4 +4,3 @@ "access_report_intrastat_code_sale_manager","report.intrastat.code sale manager","model_report_intrastat_code","base.group_sale_manager",1,1,1,1 "access_report_intrastat_code_purchase_manager","report.intrastat.code purchase manager","model_report_intrastat_code","purchase.group_purchase_manager",1,1,1,1 "access_report_intrastat_code_stock_manager","report.intrastat.code stock manager","model_report_intrastat_code","stock.group_stock_manager",1,1,1,1 -"access_report_intrastat_code_mrp_manager","report.intrastat.code mrp manager","model_report_intrastat_code","mrp.group_mrp_manager",1,1,1,1 From 0e00f5c5a6811d50110d99e325cfa0d1aff4c2a9 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 29 Dec 2010 10:47:54 +0100 Subject: [PATCH 06/24] [FIX] ir.ui.menu: typos introduced recently bzr revid: odo@openerp.com-20101229094754-c9od7rd0xlvk9h08 --- bin/addons/base/ir/ir_ui_menu.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/addons/base/ir/ir_ui_menu.py b/bin/addons/base/ir/ir_ui_menu.py index dff6823f6c6..8696df80311 100644 --- a/bin/addons/base/ir/ir_ui_menu.py +++ b/bin/addons/base/ir/ir_ui_menu.py @@ -286,10 +286,10 @@ class ir_ui_menu(osv.osv): string='Complete Name', type='char', size=128), 'icon': fields.selection(tools.icons, 'Icon', size=64), 'icon_pict': fields.function(_get_icon_pict, method=True, type='char', size=32), - 'web_icon': fields.char('Icon File', size=128), - 'web_icon_hover':fields.char('Icon Over File', size=128), - 'web_icon_data': fields.function(_get_image_icon, string='Web Icons', type='binary', method=True, readonly=True, store=True, multi='icon'), - 'web_icon_hover_data':fields.function(_get_image_icon, string='Web Icons Over', type='binary', method=True, readonly=True, store=True,multi='icon'), + 'web_icon': fields.char('Web Icon File', size=128), + 'web_icon_hover':fields.char('Web Icon File (hover)', size=128), + 'web_icon_data': fields.function(_get_image_icon, string='Web Icon Image', type='binary', method=True, readonly=True, store=True, multi='icon'), + 'web_icon_hover_data':fields.function(_get_image_icon, string='Web Icon Image (hover)', type='binary', method=True, readonly=True, store=True, multi='icon'), 'action': fields.function(_action, fnct_inv=_action_inv, method=True, type='reference', string='Action', selection=[ From 5a15a0a41a3c23783db7d33cd01905ed2aff6a4d Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Wed, 29 Dec 2010 15:46:28 +0530 Subject: [PATCH 07/24] [FIX] knowledge: security bzr revid: hmo@tinyerp.com-20101229101628-1vzbn5dytou46dlw --- addons/document/security/ir.model.access.csv | 1 + addons/knowledge/security/ir.model.access.csv | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/document/security/ir.model.access.csv b/addons/document/security/ir.model.access.csv index d7aba7cbde7..0422edba24e 100644 --- a/addons/document/security/ir.model.access.csv +++ b/addons/document/security/ir.model.access.csv @@ -25,3 +25,4 @@ "access_report_document_file_group_system","report.document.file group system","model_report_document_file","base.group_system",1,0,0,0 "access_report_document_wall_group_document_manager","report.document.wall document manager","model_report_document_wall","base.group_system",1,0,0,0 "access_report_document_wall_group_system","report.document.wall group system","model_report_document_wall","base.group_system",1,0,0,0 +"access_report_document_user_knowledgeuser","report.document.user knowledgeuser","document.model_report_document_user","base.group_document_user",1,0,0,0 diff --git a/addons/knowledge/security/ir.model.access.csv b/addons/knowledge/security/ir.model.access.csv index 474cdf101ab..7a057fcfcbe 100644 --- a/addons/knowledge/security/ir.model.access.csv +++ b/addons/knowledge/security/ir.model.access.csv @@ -1,4 +1,4 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" "access_ir_attachment_sale_manager","ir_attachment manager","base.model_ir_attachment","base.group_sale_manager",1,1,1,1 "access_ir_attachment_partner_manager","ir_attachment_partner manager","base.model_ir_attachment","base.group_partner_manager",1,1,1,1 -"access_report_document_user_knowledgeuser","report.document.user knowledgeuser","document.model_report_document_user","base.group_document_user",1,0,0,0 + From bcaa136fa35accf18f07eaaa70d160e6ece5a19b Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Wed, 29 Dec 2010 16:18:16 +0530 Subject: [PATCH 08/24] [FIX] sale, purchase: yml issue bzr revid: hmo@tinyerp.com-20101229104816-lv51d1nm4gu4mjhn --- addons/purchase/test/purchase_from_order.yml | 1 - addons/sale/test/advance_invoice.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/addons/purchase/test/purchase_from_order.yml b/addons/purchase/test/purchase_from_order.yml index 454580baaf4..ca089db7821 100644 --- a/addons/purchase/test/purchase_from_order.yml +++ b/addons/purchase/test/purchase_from_order.yml @@ -31,7 +31,6 @@ date_order: '2010-05-11' invoice_method: order location_id: stock.stock_location_stock - name: PO00003 order_line: - date_planned: '2010-05-13' name: iPod diff --git a/addons/sale/test/advance_invoice.yml b/addons/sale/test/advance_invoice.yml index b3c01599680..b4a985ec4e8 100644 --- a/addons/sale/test/advance_invoice.yml +++ b/addons/sale/test/advance_invoice.yml @@ -5,7 +5,6 @@ !record {model: sale.order, id: sale_order_so5}: date_order: '2010-07-17' invoice_quantity: order - name: SO004 order_line: - name: LG Viewty Smart price_unit: 170.0 From 761c638a54e601406fd4b01e8f37c44512f8ddcf Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 29 Dec 2010 11:50:04 +0100 Subject: [PATCH 09/24] [FIX] osv,tools: break some circular dependencies bzr revid: odo@openerp.com-20101229105004-ay1e69aujci1l32i --- bin/osv/orm.py | 8 +++----- bin/tools/convert.py | 8 +++++--- bin/tools/misc.py | 5 +++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 65e90922794..72500602669 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -59,8 +59,10 @@ from query import Query import tools from tools.safe_eval import safe_eval as eval -regex_order = re.compile('^(([a-z0-9_]+|"[a-z0-9_]+")( *desc| *asc)?( *, *|))+$', re.I) +# List of etree._Element subclasses that we choose to ignore when parsing XML. +from tools import SKIPPED_ELEMENT_TYPES +regex_order = re.compile('^(([a-z0-9_]+|"[a-z0-9_]+")( *desc| *asc)?( *, *|))+$', re.I) POSTGRES_CONFDELTYPES = { 'RESTRICT': 'r', @@ -70,10 +72,6 @@ POSTGRES_CONFDELTYPES = { 'SET DEFAULT': 'd', } -# List of etree._Element subclasses that we choose to ignore when parsing view architecture. -# We include the *Base ones just in case, currently they seem to be subclasses of the _* ones. -SKIPPED_ELEMENT_TYPES = (etree._Comment, etree._ProcessingInstruction, etree.CommentBase, etree.PIBase) - def last_day_of_current_month(): today = datetime.date.today() last_day = str(calendar.monthrange(today.year, today.month)[1]) diff --git a/bin/tools/convert.py b/bin/tools/convert.py index e46d37f688a..db8d71843ba 100644 --- a/bin/tools/convert.py +++ b/bin/tools/convert.py @@ -45,10 +45,12 @@ import netsvc import osv import pooler from config import config -from osv.orm import except_orm, SKIPPED_ELEMENT_TYPES from tools.translate import _ from yaml_import import convert_yaml_import +# List of etree._Element subclasses that we choose to ignore when parsing XML. +from tools import SKIPPED_ELEMENT_TYPES + # Import of XML records requires the unsafe eval as well, # almost everywhere, which is ok because it supposedly comes # from trusted data, but at least we make it obvious now. @@ -865,7 +867,7 @@ form: module.record_id""" % (xml_id,) self.__logger.error('Parse error in %s:%d: \n%s', rec.getroottree().docinfo.URL, rec.sourceline, - etree.tostring(rec).strip()) + etree.tostring(rec).strip(), exc_info=True) self.cr.rollback() raise return True @@ -945,7 +947,7 @@ def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init', result, rows, warning_msg, dummy = pool.get(model).import_data(cr, uid, fields, datas,mode, module, noupdate, filename=fname_partial) if result < 0: # Report failed import and abort module install - raise except_orm(_('Module loading failed'), _('Loading %s/%s failed:\n %s') % (module, fname, warning_msg)) + raise Exception(_('Module loading failed: file %s/%s could not be processed:\n %s') % (module, fname, warning_msg)) if config.get('import_partial'): data = pickle.load(file(config.get('import_partial'))) data[fname_partial] = 0 diff --git a/bin/tools/misc.py b/bin/tools/misc.py index 2515803f452..88f06749f90 100644 --- a/bin/tools/misc.py +++ b/bin/tools/misc.py @@ -44,6 +44,7 @@ from email.Header import Header from email.Utils import formatdate, COMMASPACE from email import Encoders from itertools import islice, izip +from lxml import etree from which import which if sys.version_info[:2] < (2, 4): from threadinglocal import local @@ -60,6 +61,10 @@ from lru import LRU _logger = logging.getLogger('tools') +# List of etree._Element subclasses that we choose to ignore when parsing XML. +# We include the *Base ones just in case, currently they seem to be subclasses of the _* ones. +SKIPPED_ELEMENT_TYPES = (etree._Comment, etree._ProcessingInstruction, etree.CommentBase, etree.PIBase) + # initialize a database with base/base.sql def init_db(cr): import addons From b6595ed6d5d86f06002a53e752bfacffddac7440 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Wed, 29 Dec 2010 16:46:31 +0530 Subject: [PATCH 10/24] [FIX] hr_payroll_account: if journal_id or bank_journal_id are not specified in pay slip, call super method which are declared in hr_payroll module. it fixed due to solve yml issue bzr revid: hmo@tinyerp.com-20101229111631-zam0fzc3iu11vsr5 --- addons/hr_payroll_account/hr_payroll_account.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/hr_payroll_account/hr_payroll_account.py b/addons/hr_payroll_account/hr_payroll_account.py index adf1fada169..35f638a3326 100644 --- a/addons/hr_payroll_account/hr_payroll_account.py +++ b/addons/hr_payroll_account/hr_payroll_account.py @@ -256,6 +256,10 @@ class hr_payslip(osv.osv): period_pool = self.pool.get('account.period') for slip in self.browse(cr, uid, ids, context=context): + if not slip.bank_journal_id or not slip.journal_id: + # Call super method to process sheet if journal_id or bank_journal_id are not specified. + super(hr_payslip, self).process_sheet(cr, uid, [slip.id], context=context) + continue line_ids = [] partner = False partner_id = False @@ -411,6 +415,10 @@ class hr_payslip(osv.osv): payslip_pool = self.pool.get('hr.payslip.line') for slip in self.browse(cr, uid, ids, context=context): + if not slip.journal_id: + # Call super method to verify sheet if journal_id is not specified. + super(hr_payslip, self).verify_sheet(cr, uid, [slip.id], context=context) + continue total_deduct = 0.0 line_ids = [] From 191f66c521500d5460f83e204717f81d86b502ea Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Wed, 29 Dec 2010 12:51:44 +0100 Subject: [PATCH 11/24] [FIX] Change the name of the NT Service bzr revid: stephane@openerp.com-20101229115144-xj2mhe2d8wy1m4iv --- win32/OpenERPServerService.py | 6 +++--- win32/start.bat | 4 ++-- win32/stop.bat | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/win32/OpenERPServerService.py b/win32/OpenERPServerService.py index e44a9d274a1..bdf371aca68 100644 --- a/win32/OpenERPServerService.py +++ b/win32/OpenERPServerService.py @@ -34,10 +34,10 @@ import thread class OpenERPServerService(win32serviceutil.ServiceFramework): # required info - _svc_name_ = "openerp-service" - _svc_display_name_ = "OpenERP Server" + _svc_name_ = "openerp-server-6.0" + _svc_display_name_ = "OpenERP Server 6.0" # optionnal info - _svc_description_ = "OpenERP Server service" + _svc_description_ = "OpenERP Server 6.0 service" def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) diff --git a/win32/start.bat b/win32/start.bat index 67e580e9fb9..c6b78835900 100644 --- a/win32/start.bat +++ b/win32/start.bat @@ -1,7 +1,7 @@ @PATH=%WINDIR%\system32;%WINDIR%;%WINDIR%\System32\Wbem;. -@net stop openerp-service +@net stop openerp-server-6.0 -@net start openerp-service +@net start openerp-server-6.0 cls diff --git a/win32/stop.bat b/win32/stop.bat index c7dd4b79dc1..7d6d41ecf87 100644 --- a/win32/stop.bat +++ b/win32/stop.bat @@ -1,5 +1,5 @@ @PATH=%WINDIR%\system32;%WINDIR%;%WINDIR%\System32\Wbem;. -@net stop openerp-service +@net stop openerp-server-6.0 cls From 086b9fd0286fc71f16974dc2ad173948b215fbbb Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Wed, 29 Dec 2010 12:52:33 +0100 Subject: [PATCH 12/24] [REF] Add the uuid library in the dependencies and remove the commented code bzr revid: stephane@openerp.com-20101229115233-rhr4ika4611kikue --- setup.py | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/setup.py b/setup.py index 894c7f7c11e..4a686ebfe15 100755 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ import glob from pprint import pprint as pp -from setuptools import setup as official_setup, find_packages +from setuptools import setup, find_packages from setuptools.command.install import install from distutils.sysconfig import get_python_lib @@ -169,21 +169,18 @@ options = { "optimize": 2, "dist_dir": 'dist', "packages": [ - "lxml", "lxml.builder", "lxml._elementpath", "lxml.etree", - "lxml.objectify", "decimal", "xml", "xml", "xml.dom", "xml.xpath", - "encodings", "dateutil", "wizard", "pychart", "PIL", "pyparsing", - "pydot", "asyncore","asynchat", "reportlab", "vobject", - "HTMLParser", "select", "mako", "poplib", - "imaplib", "smtplib", "email", "yaml", "DAV", - ], + "lxml", "lxml.builder", "lxml._elementpath", "lxml.etree", + "lxml.objectify", "decimal", "xml", "xml", "xml.dom", "xml.xpath", + "encodings", "dateutil", "wizard", "pychart", "PIL", "pyparsing", + "pydot", "asyncore","asynchat", "reportlab", "vobject", + "HTMLParser", "select", "mako", "poplib", + "imaplib", "smtplib", "email", "yaml", "DAV", + "uuid", + ], "excludes" : ["Tkconstants","Tkinter","tcl"], } } -def setup(**kwargs): - #pp(kwargs) - return official_setup(**kwargs) - setup(name = name, version = version, description = description, @@ -225,13 +222,8 @@ setup(name = name, 'reportlab', 'caldav', 'pyyaml', - #'django', 'pywebdav' - #'cx_Oracle', - #'mysqldb', 'feedparser', - #'bsddb3', - 'egenix-mx-base' ], extras_require={ 'SSL' : ['pyopenssl'], From 1bdf60d4e3a201680dfbd8b52d0f1331d3b4765c Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Wed, 29 Dec 2010 12:52:42 +0100 Subject: [PATCH 13/24] [REF] Detect if there is an installation of PostgreSQL and propose a screen for the configuration bzr revid: stephane@openerp.com-20101229115242-uwj3z0z01lz5o3vs --- setup.nsi | 657 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 391 insertions(+), 266 deletions(-) diff --git a/setup.nsi b/setup.nsi index 89d308723e9..0aa0687b3c0 100644 --- a/setup.nsi +++ b/setup.nsi @@ -1,266 +1,391 @@ -############################################################################## -# -# Copyright (c) 2004-2008 Tiny SPRL (http://tiny.be) All Rights Reserved. -# -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company -# -# This program is Free Software; you can redistribute it and/or -# modify it under the terms of the GNU 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -############################################################################### -!ifndef VERSION - !error "Do not forget to specify the version of OpenERP - /DVERSION=" -!endif - -!include "MUI.nsh" - -;-------------------------------- -;General - -;Name and file -Name "OpenERP Server" -OutFile "openerp-server-setup-${VERSION}.exe" -SetCompressor lzma -SetCompress auto - -;Default installation folder -InstallDir "$PROGRAMFILES\OpenERP Server" - -;Get installation folder from registry if available -InstallDirRegKey HKLM "Software\OpenERP Server" "" - -BrandingText "OpenERP Server ${VERSION}" - -;Vista redirects $SMPROGRAMS to all users without this -RequestExecutionLevel admin - -;-------------------------------- -;Variables - -Var MUI_TEMP -Var STARTMENU_FOLDER - -;-------------------------------- -;Interface Settings - -!define MUI_ABORTWARNING - -!define REGKEY "SOFTWARE\$(^Name)" -!define MUI_LANGDLL_REGISTRY_ROOT HKLM -!define MUI_LANGDLL_REGISTRY_KEY ${REGKEY} -!define MUI_LANGDLL_REGISTRY_VALUENAME InstallerLanguage - -!insertmacro MUI_RESERVEFILE_LANGDLL -;-------------------------------- -;Pages - -!define MUI_ICON ".\pixmaps\openerp-icon.ico" -!define MUI_WELCOMEFINISHPAGE_BITMAP ".\pixmaps\openerp-intro.bmp" -!define MUI_UNWELCOMEFINISHPAGE_BITMAP ".\pixmaps\openerp-intro.bmp" -!define MUI_HEADERIMAGE -!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH -!define MUI_HEADER_TRANSPARENT_TEXT "" -!define MUI_HEADERIMAGE_BITMAP ".\pixmaps\openerp-slogan.bmp" -!define MUI_LICENSEPAGE_TEXT_BOTTOM "$(LicenseText)" -!define MUI_LICENSEPAGE_BUTTON "$(LicenseNext)" - -!insertmacro MUI_PAGE_WELCOME -!insertmacro MUI_PAGE_LICENSE "doc\License.rtf" -!insertmacro MUI_PAGE_DIRECTORY - -;Start Menu Folder Page Configuration -!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM" -!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\OpenERP Server" -!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "OpenERP Server" - -!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER - -!insertmacro MUI_PAGE_INSTFILES - -!define MUI_FINISHPAGE_NOAUTOCLOSE -!define MUI_FINISHPAGE_RUN -!define MUI_FINISHPAGE_RUN_CHECKED -!define MUI_FINISHPAGE_RUN_TEXT "$(FinishPageText)" -!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink" -!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED -!define MUI_FINISHPAGE_SHOWREADME $INSTDIR\README.txt -!insertmacro MUI_PAGE_FINISH - - -!insertmacro MUI_UNPAGE_WELCOME -!insertmacro MUI_UNPAGE_CONFIRM -!insertmacro MUI_UNPAGE_INSTFILES - -;-------------------------------- -;Languages - -!insertmacro MUI_LANGUAGE "English" -!insertmacro MUI_LANGUAGE "French" - -!macro CreateInternetShortcut FILENAME URL - WriteINIStr "${FILENAME}.url" "InternetShortcut" "URL" "${URL}" -!macroend - -;-------------------------------- -;Installer Sections -Function .onInit -!ifndef ALLINONE - ;Language selection dialog - Push "" - Push ${LANG_ENGLISH} - Push English - Push ${LANG_FRENCH} - Push French - Push A ; A means auto count languages - ; for the auto count to work the first empty push (Push "") must remain - LangDLL::LangDialog "Installer Language" "Please select the language of the installer" - - Pop $LANGUAGE - StrCmp $LANGUAGE "cancel" 0 +2 - Abort -!endif - - ClearErrors - ReadRegStr $0 HKLM "Software\OpenERP Server" "" - IfErrors DoInstall 0 - MessageBox MB_OK "$(CannotInstallServerText)" - Quit - DoInstall: -FunctionEnd - -Section "OpenERP Server" SecOpenERPServer - nsExec::Exec "net stop openerp-service" - sleep 2 - - SetOutPath "$INSTDIR" - - ;ADD YOUR OWN FILES HERE... - File /r "dist\*" - - SetOutPath "$INSTDIR\service" - File /r "win32\dist\*" - File "win32\start.bat" - File "win32\stop.bat" - - ;Store installation folder - WriteRegStr HKLM "Software\OpenERP Server" "" $INSTDIR - -!ifndef ALLINONE - ;Create uninstaller - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenERP Server" "DisplayName" "OpenERP Server ${VERSION}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenERP Server" "UninstallString" "$INSTDIR\Uninstall.exe" -!else - WriteRegStr HKLM "Software\OpenERP AllInOne" "UninstallServer" "$INSTDIR\Uninstall.exe" -!endif - WriteUninstaller "$INSTDIR\Uninstall.exe" - - !insertmacro MUI_STARTMENU_WRITE_BEGIN Application - ;Create shortcuts - CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" - CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\OpenERP Server.lnk" "$INSTDIR\openerp-server.exe" - CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Start service.lnk" "$INSTDIR\service\start.bat" - CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Stop service.lnk" "$INSTDIR\service\stop.bat" - CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Edit config.lnk" "notepad.exe" "$INSTDIR\openerp-server.conf" - CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\View log.lnk" "notepad.exe" "$INSTDIR\openerp-server.log" -!ifndef ALLINONE - CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\uninstall.exe" -!endif - !insertmacro CreateInternetShortcut "$SMPROGRAMS\$STARTMENU_FOLDER\Forum" "http://www.openerp.com/forum" - !insertmacro CreateInternetShortcut "$SMPROGRAMS\$STARTMENU_FOLDER\Translation" "https://translations.launchpad.net/openobject" - !insertmacro MUI_STARTMENU_WRITE_END - - nsExec::Exec '"$INSTDIR\openerp-server.exe" --stop-after-init --logfile "$INSTDIR\openerp-server.log" -s' - nsExec::Exec '"$INSTDIR\service\OpenERPServerService.exe" -auto -install' - -SectionEnd - -;Descriptions - - -;-------------------------------- -;Uninstaller Section - -Section "Uninstall" - nsExec::Exec "net stop openerp-service" - sleep 2 - nsExec::Exec '"$INSTDIR\service\OpenERPServerService.exe" -remove' - sleep 2 - - RMDIR /r "$INSTDIR" - !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP - - Delete "$SMPROGRAMS\$MUI_TEMP\Forum.url" - Delete "$SMPROGRAMS\$MUI_TEMP\Translation.url" -!ifndef ALLINONE - Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" -!endif - Delete "$SMPROGRAMS\$MUI_TEMP\OpenERP Server.lnk" - Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" - Delete "$SMPROGRAMS\$MUI_TEMP\Start service.lnk" - Delete "$SMPROGRAMS\$MUI_TEMP\Stop service.lnk" - Delete "$SMPROGRAMS\$MUI_TEMP\Edit config.lnk" - Delete "$SMPROGRAMS\$MUI_TEMP\View log.lnk" - - ;Delete empty start menu parent diretories - StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" - - startMenuDeleteLoop: - ClearErrors - RMDir $MUI_TEMP - GetFullPathName $MUI_TEMP "$MUI_TEMP\.." - - IfErrors startMenuDeleteLoopDone - - StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop - - startMenuDeleteLoopDone: - -!ifndef ALLINONE - DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenERP Server" -!else - DeleteRegKey HKLM "Software\OpenERP AllInOne\UninstallServer" -!endif - DeleteRegKey /ifempty HKLM "Software\OpenERP Server" - -SectionEnd - -Function LaunchLink - nsExec::Exec "net start openerp-service" -FunctionEnd - -LangString LicenseText ${LANG_ENGLISH} "Usually, a proprietary license is provided with the software: limited number of users, limited in time usage, etc. This Open Source license is the opposite: it garantees you the right to use, copy, study, distribute and modify Open ERP for free." -LangString LicenseText ${LANG_FRENCH} "Normalement, une licence propriétaire est fournie avec le logiciel: limitation du nombre d'utilisateurs, limitation dans le temps, etc. Cette licence Open Source est l'opposé: Elle vous garantie le droit d'utiliser, de copier, d'étudier, de distribuer et de modifier Open ERP librement." - -LangString LicenseNext ${LANG_ENGLISH} "Next >" -LangString LicenseNext ${LANG_FRENCH} "Suivant >" - -LangString FinishPageText ${LANG_ENGLISH} "Start OpenERP Server" -LangString FinishPageText ${LANG_FRENCH} "Lancer le serveur OpenERP" - -;Language strings -LangString DESC_SecOpenERPServer ${LANG_ENGLISH} "OpenERP Server." -LangString DESC_SecOpenERPServer ${LANG_FRENCH} "Serveur OpenERP." - -LangString CannotInstallServerText ${LANG_ENGLISH} "Can not install the Open ERP Server because a previous installation already exists on this system. Please uninstall your current installation and relaunch this setup wizard." -LangString CannotInstallServerText ${LANG_FRENCH} "Ne peut pas installer le serveur Open ERP parce qu'une installation existe déjà  sur ce système. S'il vous plait, désinstallez votre installation actuelle et relancer l'installeur." - - -;Assign language strings to sections -!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN - !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenERPServer} $(DESC_SecOpenERPServer) -!insertmacro MUI_FUNCTION_DESCRIPTION_END +##################################################################################### +# +# Copyright (c) 2004-TODAY OpenERP S.A. (http://www.openerp.com) All Rights Reserved. +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +##################################################################################### + +!include 'MUI2.nsh' +!include 'FileFunc.nsh' +!include 'LogicLib.nsh' +!include 'Sections.nsh' + +!define PUBLISHER 'OpenERP S.A.' +!define MAJOR_VERSION '6.0' +!define MINOR_VERSION '0.0' +!define REVISION_VERSION 'RC2-test' +!ifndef REVISION_VERSION + !define VERSION "${MAJOR_VERSION}.${MINOR_VERSION}" +!else + !define VERSION "${MAJOR_VERSION}.${MINOR_VERSION}-${REVISION_VERSION}" +!endif +!define PRODUCT_NAME "OpenERP Server" +!define DISPLAY_NAME "${PRODUCT_NAME} ${MAJOR_VERSION}" + +!define UNINSTALL_REGISTRY_ROOT HKLM +!define UNINSTALL_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${DISPLAY_NAME}" + +!define REGISTRY_KEY "Software\${DISPLAY_NAME}" + +!define DEFAULT_POSTGRESQL_HOSTNAME 'localhost' +!define DEFAULT_POSTGRESQL_PORT 5432 +!define DEFAULT_POSTGRESQL_USERNAME 'openpg' +!define DEFAULT_POSTGRESQL_PASSWORD 'openpgpwd' + +Name '${DISPLAY_NAME}' +Caption "${PRODUCT_NAME} ${VERSION} Setup" +OutFile "openerp-server-setup-${VERSION}.exe" +SetCompressor /final /solid lzma +SetCompress auto +ShowInstDetails show + +XPStyle on + +InstallDir "$PROGRAMFILES\OpenERP ${MAJOR_VERSION}\Server" +InstallDirRegKey HKCU "${REGISTRY_KEY}" "" + +BrandingText '${PRODUCT_NAME} ${VERSION}' + +RequestExecutionLevel admin + +VIAddVersionKey "ProductName" "${PRODUCT_NAME}" +VIAddVersionKey "CompanyName" "${PUBLISHER}" +VIAddVersionKey "FileDescription" "Installer of ${DISPLAY_NAME}" +VIAddVersionKey "LegalCopyright" "${PUBLISHER}" +VIAddVersionKey "LegalTrademark" "OpenERP is a trademark of ${PUBLISHER}" +VIAddVersionKey "FileVersion" "${MAJOR_VERSION}" +VIProductVersion "${VERSION}" + +!insertmacro GetParameters +!insertmacro GetOptions + +Var Option_AllInOne +Var HasPostgreSQL +Var cmdLineParams + +Var TextPostgreSQLHostname +Var TextPostgreSQLPort +Var TextPostgreSQLUsername +Var TextPostgreSQLPassword + +Var HWNDPostgreSQLHostname +Var HWNDPostgreSQLPort +Var HWNDPostgreSQLUsername +Var HWNDPostgreSQLPassword + +Var MUI_TEMP +Var STARTMENU_FOLDER + +!define MUI_ABORTWARNING +!define MUI_ICON ".\pixmaps\openerp-icon.ico" + +!define MUI_WELCOMEFINISHPAGE_BITMAP ".\pixmaps\openerp-intro.bmp" +!define MUI_UNWELCOMEFINISHPAGE_BITMAP ".\pixmaps\openerp-intro.bmp" +!define MUI_HEADERIMAGE +!define MUI_HEADERIMAGE_BITMAP ".\pixmaps\openerp-slogan.bmp" +!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH +!define MUI_HEADER_TRANSPARENT_TEXT "" + +!insertmacro MUI_PAGE_WELCOME +!insertmacro MUI_PAGE_LICENSE "doc\License.rtf" +!define MUI_COMPONENTSPAGE_SMALLDESC +!insertmacro MUI_PAGE_DIRECTORY +Page Custom ShowPostgreSQL LeavePostgreSQL + +!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM" +!define MUI_STARTMENUPAGE_REGISTRY_KEY "${REGISTRY_KEY}" +!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${DISPLAY_NAME}" + +!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER +!insertmacro MUI_PAGE_INSTFILES + +!define MUI_FINISHPAGE_NOAUTOCLOSE +!define MUI_FINISHPAGE_LINK $(DESC_FinishPage_Link) +!define MUI_FINISHPAGE_LINK_LOCATION "http://www.openerp.com/contact" +!insertmacro MUI_PAGE_FINISH + +!insertmacro MUI_UNPAGE_WELCOME +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES +!insertmacro MUI_UNPAGE_FINISH + +!insertmacro MUI_LANGUAGE "English" +!insertmacro MUI_LANGUAGE "French" +!insertmacro MUI_RESERVEFILE_LANGDLL + +!macro CreateInternetShortcut FILENAME URL + WriteINIStr "${FILENAME}.url" "InternetShortcut" "URL" "${URL}" +!macroend + +; English +LangString DESC_FinishPage_Link ${LANG_ENGLISH} "Contact OpenERP for Partnership and/or Support" +LangString WARNING_HostNameIsEmpty ${LANG_ENGLISH} "The hostname for the connection to the PostgreSQL Server is empty" +LangString WARNING_UserNameIsEmpty ${LANG_ENGLISH} "The username for the connection to the PostgreSQL Server is empty" +LangString WARNING_PasswordIsEmpty ${LANG_ENGLISH} "The password for the connection to the PostgreSQL Server is empty" +LangString WARNING_PortIsWrong ${LANG_ENGLISH} "The port for the connexion to the PostgreSQL Server is wrong (default: 5432)" +LangString DESC_PostgreSQLPage ${LANG_ENGLISH} "Configure the information for the PostgreSQL connection" +LangString DESC_PostgreSQL_Hostname ${LANG_ENGLISH} "Hostname" +LangString DESC_PostgreSQL_Port ${LANG_ENGLISH} "Port" +LangString DESC_PostgreSQL_Username ${LANG_ENGLISH} "Username" +LangString DESC_PostgreSQL_Password ${LANG_ENGLISH} "Password" + + +; French +LangString DESC_FinishPage_Link ${LANG_FRENCH} "Contactez OpenERP pour un Partenariat et/ou du Support" +LangString WARNING_HostNameIsEmpty ${LANG_FRENCH} "L'adresse pour la connection au serveur PostgreSQL est vide" +LangString WARNING_UserNameIsEmpty ${LANG_FRENCH} "Le nom d'utilisateur pour la connection au serveur PostgreSQL est vide" +LangString WARNING_PasswordIsEmpty ${LANG_FRENCH} "Le mot de passe pour la connection au serveur PostgreSQL est vide" +LangString WARNING_PortIsWrong ${LANG_FRENCH} "Le port pour la connection au serveur PostgreSQL est erroné (défaut: 5432)" +LangString DESC_PostgreSQLPage ${LANG_FRENCH} "Configurez les informations de connection pour le serveur PostgreSQL" +LangString DESC_PostgreSQL_Hostname ${LANG_FRENCH} "Hôte" +LangString DESC_PostgreSQL_Port ${LANG_FRENCH} "Port" +LangString DESC_PostgreSQL_Username ${LANG_FRENCH} "Utilisateur" +LangString DESC_PostgreSQL_Password ${LANG_FRENCH} "Mot de passe" + +Section -StopService + nsExec::Exec "net stop openerp-server-6.0" + sleep 2 +SectionEnd + +Section OpenERP_Server SectionOpenERP_Server + SetOutPath '$INSTDIR' + + File /r "dist\*" + + SetOutPath "$INSTDIR\service" + File /r "win32\dist\*" + File "win32\start.bat" + File "win32\stop.bat" + + !insertmacro MUI_STARTMENU_WRITE_BEGIN Application + ;Create shortcuts + CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" + CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\OpenERP Server.lnk" "$INSTDIR\openerp-server.exe" + CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Start service.lnk" "$INSTDIR\service\start.bat" + CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Stop service.lnk" "$INSTDIR\service\stop.bat" + CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Edit config.lnk" "notepad.exe" "$INSTDIR\openerp-server.conf" + CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\View log.lnk" "notepad.exe" "$INSTDIR\openerp-server.log" + CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\uninstall.exe" + !insertmacro CreateInternetShortcut "$SMPROGRAMS\$STARTMENU_FOLDER\Forum" "http://www.openerp.com/forum" + !insertmacro CreateInternetShortcut "$SMPROGRAMS\$STARTMENU_FOLDER\Translation" "https://translations.launchpad.net/openobject" + !insertmacro MUI_STARTMENU_WRITE_END + + + FileOpen $9 '$INSTDIR\install.log' w + FileWrite $9 "Hostname $TextPostgreSQLHostname$\r$\n" + FileWrite $9 "Port $TextPostgreSQLPort$\r$\n" + FileWrite $9 "Username $TextPostgreSQLUsername$\r$\n" + FileWrite $9 "Password $TextPostgreSQLPassword$\r$\n" + FileClose $9 + +# If there is a previous install of the OpenERP Server, keep the login/password from the config file + WriteIniStr "$INSTDIR\openerp-server.conf" "options" "db_host" $TextPostgreSQLHostname + WriteIniStr "$INSTDIR\openerp-server.conf" "options" "db_user" $TextPostgreSQLUsername + WriteIniStr "$INSTDIR\openerp-server.conf" "options" "db_password" $TextPostgreSQLPassword + WriteIniStr "$INSTDIR\openerp-server.conf" "options" "db_port" $TextPostgreSQLPort + + nsExec::Exec '"$INSTDIR\openerp-server.exe" --stop-after-init --logfile "$INSTDIR\openerp-server.log" -s' + nsExec::Exec '"$INSTDIR\service\OpenERPServerService.exe" -auto -install' +SectionEnd + +Section -RestartServer + nsExec::Exec "net start openerp-server-6.0" + sleep 2 +SectionEnd + +Section -Post + WriteRegExpandStr HKLM "${UNINSTALL_REGISTRY_KEY}" "UninstallString" "$INSTDIR\Uninstall.exe" + WriteRegExpandStr HKLM "${UNINSTALL_REGISTRY_KEY}" "InstallLocation" "$INSTDIR" + WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "DisplayName" "${DISPLAY_NAME}" + WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "DisplayVersion" "${MAJOR_VERSION}" + WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "Publisher" "${PUBLISHER}" + WriteRegDWORD HKLM "${UNINSTALL_REGISTRY_KEY}" "Version" "${VERSION}" + WriteRegDWORD HKLM "${UNINSTALL_REGISTRY_KEY}" "VersionMajor" "${MAJOR_VERSION}" + WriteRegDWORD HKLM "${UNINSTALL_REGISTRY_KEY}" "VersionMinor" "${MINOR_VERSION}" + WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "HelpLink" "support@openerp.com" + WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "HelpTelephone" "+32.81.81.37.00" + WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "URLInfoAbout" "http://www.openerp.com" + WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "Contact" "sales@openerp.com" + WriteRegDWORD HKLM "${UNINSTALL_REGISTRY_KEY}" "NoModify" "1" + WriteRegDWORD HKLM "${UNINSTALL_REGISTRY_KEY}" "NoRepair" "1" + WriteUninstaller "$INSTDIR\Uninstall.exe" +SectionEnd + +Section "Uninstall" + ; Stop the NT Service + nsExec::Exec "net stop openerp-server-6.0" + sleep 2 + + ; Uninstall the OpenERP Service + nsExec::Exec '"$INSTDIR\service\OpenERPServerService.exe" -remove' + sleep 2 + + Rmdir /r "$INSTDIR" + + !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP + + Delete "$SMPROGRAMS\$MUI_TEMP\Forum.url" + Delete "$SMPROGRAMS\$MUI_TEMP\Translation.url" + Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" + Delete "$SMPROGRAMS\$MUI_TEMP\OpenERP Server.lnk" + Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" + Delete "$SMPROGRAMS\$MUI_TEMP\Start service.lnk" + Delete "$SMPROGRAMS\$MUI_TEMP\Stop service.lnk" + Delete "$SMPROGRAMS\$MUI_TEMP\Edit config.lnk" + Delete "$SMPROGRAMS\$MUI_TEMP\View log.lnk" + ; + ;Delete empty start menu parent diretories + StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" + + startMenuDeleteLoop: + ClearErrors + RMDir $MUI_TEMP + GetFullPathName $MUI_TEMP "$MUI_TEMP\.." + + IfErrors startMenuDeleteLoopDone + + StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop + + startMenuDeleteLoopDone: + + ; Clean the Registry + DeleteRegKey HKLM "${UNINSTALL_REGISTRY_KEY}" +SectionEnd + +Function .onInit + Push $R0 + + ${GetParameters} $cmdLineParams + ClearErrors + + Pop $R0 + + StrCpy $Option_AllInOne 0 + StrCpy $HasPostgreSQL 0 + + StrCpy $TextPostgreSQLHostname ${DEFAULT_POSTGRESQL_HOSTNAME} + StrCpy $TextPostgreSQLPort ${DEFAULT_POSTGRESQL_PORT} + StrCpy $TextPostgreSQLUsername ${DEFAULT_POSTGRESQL_USERNAME} + StrCpy $TextPostgreSQLPassword ${DEFAULT_POSTGRESQL_PASSWORD} + + Push $R0 + ${GetOptions} $cmdLineParams '/allinone' $R0 + IfErrors +2 0 + StrCpy $Option_AllInOne 1 + Pop $R0 + + StrCmp $Option_AllInOne 1 AllInOneMode + StrCmp $Option_AllInOne 0 NoAllInOneMode + + AllInOneMode: + MessageBox MB_OK|MB_ICONINFORMATION "All In One" + + NoAllInOneMode: + + !insertmacro MUI_LANGDLL_DISPLAY + + ClearErrors + EnumRegKey $0 HKLM "SOFTWARE\PostgreSQL" 0 + IfErrors DoInstallPostgreSQL 0 + StrCpy $HasPostgreSQL 1 + + DoInstallPostgreSQL: +FunctionEnd + +Function PostgreSQLOnBack +FunctionEnd + +Function ShowPostgreSQL + SectionGetFlags ${SectionOpenERP_Server} $0 + IntOp $0 $0 & ${SF_SELECTED} + IntCmp $0 ${SF_SELECTED} LaunchPostgreSQLConfiguration + Abort + LaunchPostgreSQLConfiguration: + + nsDialogs::Create /NOUNLOAD 1018 + Pop $0 + + ${If} $0 == error + Abort + ${EndIf} + + GetFunctionAddress $0 PostgreSQLOnBack + nsDialogs::OnBack $0 + + ${NSD_CreateLabel} 0 0 100% 10u $(DESC_PostgreSQLPage) + Pop $0 + + ${NSD_CreateLabel} 0 45 60u 12u $(DESC_PostgreSQL_Hostname) + Pop $0 + ${NSD_CreateText} 100 45 150u 12u $TextPostgreSQLHostname + Pop $HWNDPostgreSQLHostname + + ${NSD_CreateLabel} 0 75 60u 12u $(DESC_PostgreSQL_Port) + Pop $0 + ${NSD_CreateNumber} 100 75 150u 12u $TextPostgreSQLPort + Pop $HWNDPostgreSQLPort + ${NSD_CreateLabel} 0 105 60u 12u $(DESC_PostgreSQL_Username) + Pop $0 + ${NSD_CreateText} 100 105 150u 12u $TextPostgreSQLUsername + Pop $HWNDPostgreSQLUsername + ${NSD_CreateLabel} 0 135 60u 12u $(DESC_PostgreSQL_Password) + Pop $0 + ${NSD_CreateText} 100 135 150u 12u $TextPostgreSQLPassword + Pop $HWNDPostgreSQLPassword + + nsDialogs::Show +FunctionEnd + +Function LeavePostgreSQL + # Before to leave the PostgreSQL configuration screen, we check the values + # from the inputs, to be sure we have the right values + + ${NSD_GetText} $HWNDPostgreSQLHostname $TextPostgreSQLHostname + ${NSD_GetText} $HWNDPostgreSQLPort $TextPostgreSQLPort + ${NSD_GetText} $HWNDPostgreSQLUsername $TextPostgreSQLUsername + ${NSD_GetText} $HWNDPostgreSQLPassword $TextPostgreSQLPassword + + StrLen $1 $TextPostgreSQLHostname + ${If} $1 == 0 + MessageBox MB_ICONEXCLAMATION|MB_OK $(WARNING_HostNameIsEmpty) + Abort + ${EndIf} + + ${If} $TextPostgreSQLPort <= 0 + ${OrIf} $TextPostgreSQLPort > 65535 + MessageBox MB_ICONEXCLAMATION|MB_OK $(WARNING_PortIsWrong) + Abort + ${EndIf} + + StrLen $1 $TextPostgreSQLUsername + ${If} $1 == 0 + MessageBox MB_ICONEXCLAMATION|MB_OK $(WARNING_UserNameIsEmpty) + Abort + ${EndIf} + + StrLen $1 $TextPostgreSQLPassword + ${If} $1 == 0 + MessageBox MB_ICONEXCLAMATION|MB_OK $(WARNING_PasswordIsEmpty) + Abort + ${EndIf} +FunctionEnd + From 1034c64f794a4b26d4a57a7af8620d0a4c695089 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 29 Dec 2010 12:54:14 +0100 Subject: [PATCH 14/24] [IMP] pad: changed button style bzr revid: fme@openerp.com-20101229115414-okrqk9n4j54zeglk --- addons/pad/web/editors.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/pad/web/editors.py b/addons/pad/web/editors.py index 689ec48ed1a..b954967497c 100644 --- a/addons/pad/web/editors.py +++ b/addons/pad/web/editors.py @@ -13,9 +13,8 @@ class SidebarTemplateEditor(openobject.templating.TemplateEditor): '\n', output.index(self.ADD_ATTACHMENT_BUTTON)) + 1 output = output[:form_opener_insertion] + \ - '''${_("Pad")}\n''' + \ + '''${_(" Add pad")}\n''' + \ output[form_opener_insertion:] return output From 97f03cf5c25a40cec423077c8ab0ffb189afb9c6 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Wed, 29 Dec 2010 17:35:59 +0530 Subject: [PATCH 15/24] [FIX] mrp,sale_mrp,stock_location: security bzr revid: hmo@tinyerp.com-20101229120559-z1wxdm5r2nakfivg --- addons/mrp/security/ir.model.access.csv | 2 -- addons/sale_mrp/security/ir.model.access.csv | 2 ++ addons/stock_location/security/ir.model.access.csv | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/addons/mrp/security/ir.model.access.csv b/addons/mrp/security/ir.model.access.csv index b001c722fef..21897629117 100644 --- a/addons/mrp/security/ir.model.access.csv +++ b/addons/mrp/security/ir.model.access.csv @@ -92,5 +92,3 @@ "access_account_account_mrp_manager","account.account mrp manager","account.model_account_account","mrp.group_mrp_manager",1,0,0,0 "access_account_journal_mrp_manager","account.journal mrp manager","account.model_account_journal","mrp.group_mrp_manager",1,0,0,0 "access_stock_location_mrp_manager","stock.location product mrp manager","stock.model_stock_location","mrp.group_mrp_manager",1,0,0,0 -"access_sale_order_manufacturing_user","sale.order manufacturing.user","sale.model_sale_order","mrp.group_mrp_user",1,1,0,0 -"access_sale_order_line_manufacturing_user","sale.order.line manufacturing.user","sale.model_sale_order_line","mrp.group_mrp_user",1,1,0,0 diff --git a/addons/sale_mrp/security/ir.model.access.csv b/addons/sale_mrp/security/ir.model.access.csv index 90ff5ac06e2..a504c9a9e5a 100644 --- a/addons/sale_mrp/security/ir.model.access.csv +++ b/addons/sale_mrp/security/ir.model.access.csv @@ -1,3 +1,5 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" "access_mrp_bom_user","mrp.bom","mrp.model_mrp_bom","base.group_sale_salesman",1,0,0,0 "access_mrp_bom_manager","mrp.bom","mrp.model_mrp_bom","base.group_sale_manager",1,0,0,0 +"access_sale_order_manufacturing_user","sale.order manufacturing.user","sale.model_sale_order","mrp.group_mrp_user",1,1,0,0 +"access_sale_order_line_manufacturing_user","sale.order.line manufacturing.user","sale.model_sale_order_line","mrp.group_mrp_user",1,1,0,0 diff --git a/addons/stock_location/security/ir.model.access.csv b/addons/stock_location/security/ir.model.access.csv index a50f18a493c..09773a66893 100644 --- a/addons/stock_location/security/ir.model.access.csv +++ b/addons/stock_location/security/ir.model.access.csv @@ -2,16 +2,12 @@ "access_product_pulled_flow_user","product_pulled_flow user","model_product_pulled_flow","stock.group_stock_user",1,0,0,0 "access_product_pulled_flow_manager","product_pulled_flow manager","model_product_pulled_flow","stock.group_stock_manager",1,1,1,1 "access_product_pulled_flow_salemanager","product_pulled_flow salemanager","model_product_pulled_flow","base.group_sale_manager",1,1,1,1 -"access_product_pulled_flow_purchase_manager","product_pulled_flow purchase manager","model_product_pulled_flow","purchase.group_purchase_manager",1,1,1,1 "access_product_pulled_flow_stock_manager","product_pulled_flow stock manager","model_product_pulled_flow","stock.group_stock_manager",1,1,1,1 -"access_product_pulled_flow_mrp_manager","product_pulled_flow mrp manager","model_product_pulled_flow","mrp.group_mrp_manager",1,1,1,1 "access_stock_location_path_user","stock location path user","model_stock_location_path","stock.group_stock_user",1,0,0,0 "access_stock_location_path_internal_user","stock location path internal user","model_stock_location_path","base.group_user",1,0,0,0 "access_stock_location_path_manager","stock location path manager","model_stock_location_path","stock.group_stock_manager",1,1,1,1 "access_stock_location_path_sale_manager","stock.location.path partner salemanager","model_stock_location_path","base.group_sale_manager",1,1,1,1 -"access_stock_location_path_purchase_manager","stock.location.path purchase manager","model_stock_location_path","purchase.group_purchase_manager",1,1,1,1 "access_stock_location_path_stock_manager","stock.location.path stock manager","model_stock_location_path","stock.group_stock_manager",1,1,1,1 -"access_stock_location_path_mrp_manager","stock.location.path mrp manager","model_stock_location_path","mrp.group_mrp_manager",1,1,1,1 "access_stock_location_path_stock_user","stock.location.path stock user","model_stock_location_path","stock.group_stock_user",1,1,1,1 "access_stock_location_path","stock.location.path","model_stock_location_path","base.group_sale_salesman",1,0,0,0 "access_product_pulled_flow","product.pulled.flow","model_product_pulled_flow","base.group_sale_salesman",1,0,0,0 From b2270b1a27d2a979e4e1b0129055b9c7c7d0c49e Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 29 Dec 2010 13:09:26 +0100 Subject: [PATCH 16/24] [FIX] orm: corrected RST for docstring of import_data() bzr revid: odo@openerp.com-20101229120926-0czisx49e30fjijh --- bin/osv/orm.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 72500602669..c312d12fe41 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -685,8 +685,10 @@ class orm_template(object): :param filename: optional file to store partial import state for recovery :rtype: tuple - This method is used when importing data via client menu - Example of fields to import for a sale.order + This method is used when importing data via client menu. + + Example of fields to import for a sale.order:: + .id, (=database_id) partner_id, (=name_search) order_line/.id, (=database_id) From b05d9cfe2577aa8fb7984aab73be71aadfc35e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Degrave?= Date: Wed, 29 Dec 2010 13:39:00 +0100 Subject: [PATCH 17/24] [FIX] HR sign in/sign out bzr revid: fde@openerp.com-20101229123900-mxl4umxn1tqjjpar --- addons/hr_attendance/hr_attendance.py | 4 ++-- .../hr_contract/security/ir.model.access.csv | 1 + .../hr_timesheet_sheet/hr_timesheet_sheet.py | 22 ++++++++----------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/addons/hr_attendance/hr_attendance.py b/addons/hr_attendance/hr_attendance.py index 584340d6c1d..07ef528a7c9 100644 --- a/addons/hr_attendance/hr_attendance.py +++ b/addons/hr_attendance/hr_attendance.py @@ -137,7 +137,7 @@ class hr_employee(osv.osv): res = {'action': type, 'employee_id': emp['id']} if dt: - res['name'] = dt + res['name'] = dt id = obj_attendance.create(cr, uid, res, context=context) if type != 'action': @@ -146,4 +146,4 @@ class hr_employee(osv.osv): hr_employee() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_contract/security/ir.model.access.csv b/addons/hr_contract/security/ir.model.access.csv index 202fcb3bdb4..7c87e3c36b3 100644 --- a/addons/hr_contract/security/ir.model.access.csv +++ b/addons/hr_contract/security/ir.model.access.csv @@ -4,3 +4,4 @@ "access_hr_resource_manager","hr.employee.resource.manager","resource.model_resource_resource","base.group_hr_manager",1,1,1,1 "access_hr_resource_calendar_user","hr.employee.resource.calendar.user","resource.model_resource_calendar","base.group_hr_user",1,1,1,1 "access_hr_contract_type_manager","hr.contract.type.manager","model_hr_contract_type","base.group_hr_manager",1,1,1,1 +"access_hr_contract_manager","hr.contract.manager","model_hr_contract","base.group_hr_manager",1,1,1,1 diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 6c7c5618311..986a4a734c3 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -237,27 +237,23 @@ class hr_timesheet_sheet(osv.osv): self.write(cr, uid, [sheet.id], {'date_current': sheet.date_to,}, context=context) return True - def sign_in(self, cr, uid, ids, context=None): + def sign(self, cr, uid, ids, typ, context=None): emp_obj = self.pool.get('hr.employee') + sheet = self.browse(cr, uid, ids, context=context)[0] if context is None: context = {} - if not self.browse(cr, uid, ids, context=context)[0].date_current == time.strftime('%Y-%m-%d'): + if not sheet.date_current == time.strftime('%Y-%m-%d'): raise osv.except_osv(_('Error !'), _('You can not sign in from an other date than today')) - emp_ids = emp_obj.search(cr, uid, [('user_id', '=', uid)], context=context) + emp_id = sheet.employee_id.id context['sheet_id']=ids[0] - emp_obj.attendance_action_change(cr, uid, emp_ids, type='sign_in', context=context,) + emp_obj.attendance_action_change(cr, uid, [emp_id], type=typ, context=context,) return True + def sign_in(self, cr, uid, ids, context=None): + return self.sign(cr,uid,ids,'sign_in',context=None) + def sign_out(self, cr, uid, ids, context=None): - emp_obj = self.pool.get('hr.employee') - if context is None: - context = {} - if not self.browse(cr, uid, ids, context=context)[0].date_current == time.strftime('%Y-%m-%d'): - raise osv.except_osv(_('Error !'), _('You can not sign out from an other date than today')) - emp_ids = emp_obj.search(cr, uid, [('user_id', '=', uid)]) - context['sheet_id']=ids[0] - emp_obj.attendance_action_change(cr, uid, emp_ids, type='sign_out', context=context,) - return True + return self.sign(cr,uid,ids,'sign_out',context=None) _columns = { 'name': fields.char('Description', size=64, select=1, From 0a7c9c6ee211fa57a5106cce74e256d4bb50bc1e Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Wed, 29 Dec 2010 13:41:23 +0100 Subject: [PATCH 18/24] [FIX] complete rewrite for clean up of hr_holidays bzr revid: fp@tinyerp.com-20101229124123-7tt4ttk3jmkispw7 --- addons/account/account_menuitem.xml | 1 - addons/account/account_view.xml | 12 +- addons/crm/crm_meeting_view.xml | 2 +- addons/hr_holidays/hr_holidays.py | 361 +++++------------- addons/hr_holidays/hr_holidays_view.xml | 74 ++-- addons/hr_holidays/hr_holidays_workflow.xml | 38 +- .../1.5/post-00-change-requests-signs.py | 25 -- .../post-01-convert-limits-into-requests.py | 35 -- addons/hr_holidays/test/test_hr_holiday.yml | 2 - addons/mrp/mrp_view.xml | 4 +- addons/procurement/procurement_view.xml | 2 +- addons/purchase/purchase_view.xml | 1 + addons/stock/stock_view.xml | 3 +- 13 files changed, 156 insertions(+), 404 deletions(-) delete mode 100644 addons/hr_holidays/migrations/1.5/post-00-change-requests-signs.py delete mode 100644 addons/hr_holidays/migrations/1.5/post-01-convert-limits-into-requests.py diff --git a/addons/account/account_menuitem.xml b/addons/account/account_menuitem.xml index 7b7e6b308b1..867aaeeba51 100644 --- a/addons/account/account_menuitem.xml +++ b/addons/account/account_menuitem.xml @@ -6,7 +6,6 @@ groups="group_account_user,group_account_manager,group_account_invoice" web_icon="images/accounting.png" web_icon_hover="images/accounting-hover.png"/> - - + + + diff --git a/addons/crm/crm_meeting_view.xml b/addons/crm/crm_meeting_view.xml index c27a50cf37b..2b3f610dabd 100644 --- a/addons/crm/crm_meeting_view.xml +++ b/addons/crm/crm_meeting_view.xml @@ -44,7 +44,7 @@ - + diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 8fe5da805b4..76eb2a76595 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -35,37 +35,11 @@ class hr_holidays_status(osv.osv): _name = "hr.holidays.status" _description = "Leave Type" - def get_days_cat(self, cr, uid, ids, category_id, return_false, context=None): - - cr.execute("""SELECT id, type, number_of_days, holiday_status_id FROM hr_holidays WHERE category_id = %s AND state='validate' AND holiday_status_id in %s""", - [category_id, tuple(ids)]) - result = sorted(cr.dictfetchall(), key=lambda x: x['holiday_status_id']) - - grouped_lines = dict((k, [v for v in itr]) for k, itr in groupby(result, itemgetter('holiday_status_id'))) - - res = {} - for record in self.browse(cr, uid, ids, context=context): - res[record.id] = {} - max_leaves = leaves_taken = 0 - if not return_false: - if record.id in grouped_lines: - leaves_taken = -sum([item['number_of_days'] for item in grouped_lines[record.id] if item['type'] == 'remove']) - max_leaves = sum([item['number_of_days'] for item in grouped_lines[record.id] if item['type'] == 'add']) - - res[record.id]['max_leaves'] = max_leaves - res[record.id]['leaves_taken'] = leaves_taken - res[record.id]['remaining_leaves'] = max_leaves - leaves_taken - - return res - def get_days(self, cr, uid, ids, employee_id, return_false, context=None): - cr.execute("""SELECT id, type, number_of_days, holiday_status_id FROM hr_holidays WHERE employee_id = %s AND state='validate' AND holiday_status_id in %s""", [employee_id, tuple(ids)]) result = sorted(cr.dictfetchall(), key=lambda x: x['holiday_status_id']) - grouped_lines = dict((k, [v for v in itr]) for k, itr in groupby(result, itemgetter('holiday_status_id'))) - res = {} for record in self.browse(cr, uid, ids, context=context): res[record.id] = {} @@ -74,18 +48,15 @@ class hr_holidays_status(osv.osv): if record.id in grouped_lines: leaves_taken = -sum([item['number_of_days'] for item in grouped_lines[record.id] if item['type'] == 'remove']) max_leaves = sum([item['number_of_days'] for item in grouped_lines[record.id] if item['type'] == 'add']) - res[record.id]['max_leaves'] = max_leaves res[record.id]['leaves_taken'] = leaves_taken res[record.id]['remaining_leaves'] = max_leaves - leaves_taken - return res def _user_left_days(self, cr, uid, ids, name, args, context=None): return_false = False employee_id = False res = {} - if context and context.has_key('employee_id'): if not context['employee_id']: return_false = True @@ -102,10 +73,9 @@ class hr_holidays_status(osv.osv): res = dict.fromkeys(ids, {'leaves_taken': 0, 'remaining_leaves': 0, 'max_leaves': 0}) return res - # To do: we can add remaining_leaves_category field to display remaining leaves for particular type _columns = { 'name': fields.char('Leave Type', size=64, required=True, translate=True), - 'categ_id': fields.many2one('crm.case.categ', 'Meeting Category', domain="[('object_id.model', '=', 'crm.meeting')]", help='If you link this type of leave with a category in the CRM, it will synchronize each leave asked with a case in this category, to display it in the company shared calendar for example.'), + 'categ_id': fields.many2one('crm.case.categ', 'Meeting', domain="[('object_id.model', '=', 'crm.meeting')]", help='If you set a meeting type, OpenERP will create a meeting in the calendar once a leave is validated.'), 'color_name': fields.selection([('red', 'Red'),('blue','Blue'), ('lightgreen', 'Light Green'), ('lightblue','Light Blue'), ('lightyellow', 'Light Yellow'), ('magenta', 'Magenta'),('lightcyan', 'Light Cyan'),('black', 'Black'),('lightpink', 'Light Pink'),('brown', 'Brown'),('violet', 'Violet'),('lightcoral', 'Light Coral'),('lightsalmon', 'Light Salmon'),('lavender', 'Lavender'),('wheat', 'Wheat'),('ivory', 'Ivory')],'Color in Report', required=True, help='This color will be used in the leaves summary located in Reporting\Leaves by Departement'), 'limit': fields.boolean('Allow to Override Limit', help='If you tick this checkbox, the system will allow, for this section, the employees to take more leaves than the available ones.'), 'active': fields.boolean('Active', help="If the active field is set to false, it will allow you to hide the leave type without removing it."), @@ -118,7 +88,6 @@ class hr_holidays_status(osv.osv): 'color_name': 'red', 'active': True, } - hr_holidays_status() class hr_holidays(osv.osv): @@ -132,12 +101,23 @@ class hr_holidays(osv.osv): return ids[0] return False + def _compute_number_of_days(self, cr, uid, ids, name, args, context=None): + result = {} + for hol in self.browse(cr, uid, ids, context=context): + if hol.type=='remove': + result[hol.id] = -hol.number_of_days_temp + else: + result[hol.id] = hol.number_of_days_temp + return result + _columns = { 'name': fields.char('Description', required=True, size=64), - 'state': fields.selection([('draft', 'Draft'), ('confirm', 'Waiting Approval'), ('refuse', 'Refused'), ('validate1', 'Waiting Second Approval'), ('validate', 'Approved'), ('cancel', 'Cancelled')], 'State', readonly=True, help='When the holiday request is created the state is \'Draft\'.\n It is confirmed by the user and request is sent to admin, the state is \'Waiting Approval\'.\ + 'state': fields.selection([('draft', 'Draft'), ('confirm', 'Waiting Approval'), ('refuse', 'Refused'), + ('validate1', 'Waiting Second Approval'), ('validate', 'Approved'), ('cancel', 'Cancelled')], + 'State', readonly=True, help='When the holiday request is created the state is \'Draft\'.\n It is confirmed by the user and request is sent to admin, the state is \'Waiting Approval\'.\ If the admin accepts it, the state is \'Approved\'. If it is refused, the state is \'Refused\'.'), + 'user_id':fields.related('employee_id', 'user_id', type='many2one', relation='res.users', string='User', store=True), 'date_from': fields.datetime('Start Date', readonly=True, states={'draft':[('readonly',False)]}), - 'user_id':fields.many2one('res.users', 'User', states={'draft':[('readonly',False)]}, select=True, readonly=True), 'date_to': fields.datetime('End Date', readonly=True, states={'draft':[('readonly',False)]}), 'holiday_status_id': fields.many2one("hr.holidays.status", "Leave Type", required=True,readonly=True, states={'draft':[('readonly',False)]}), 'employee_id': fields.many2one('hr.employee', "Employee", select=True, invisible=False, readonly=True, states={'draft':[('readonly',False)]}, help='Leave Manager can let this field empty if this leave request/allocation is for every employee'), @@ -145,27 +125,29 @@ class hr_holidays(osv.osv): #'notes': fields.text('Notes',readonly=True, states={'draft':[('readonly',False)]}), 'manager_id': fields.many2one('hr.employee', 'First Approval', invisible=False, readonly=True, help='This area is automaticly filled by the user who validate the leave'), 'notes': fields.text('Reasons',readonly=True, states={'draft':[('readonly',False)]}), - 'number_of_days': fields.float('Number of Days', readonly=True, states={'draft':[('readonly',False)]}), 'number_of_days_temp': fields.float('Number of Days', readonly=True, states={'draft':[('readonly',False)]}), - 'case_id': fields.many2one('crm.meeting', 'Case'), + 'number_of_days': fields.function(_compute_number_of_days, method=True, string='Number of Days', store=True), + 'case_id': fields.many2one('crm.meeting', 'Meeting'), 'type': fields.selection([('remove','Leave Request'),('add','Allocation Request')], 'Request Type', required=True, readonly=True, states={'draft':[('readonly',False)]}, help="Choose 'Leave Request' if someone wants to take an off-day. \nChoose 'Allocation Request' if you want to increase the number of leaves available for someone"), - 'allocation_type': fields.selection([('employee','Employee Request'),('company','Company Allocation')], 'Allocation Type', required=True, readonly=True, states={'draft':[('readonly',False)]}, help='This field is only for informative purposes, to depict if the leave request/allocation comes from an employee or from the company'), 'parent_id': fields.many2one('hr.holidays', 'Parent'), 'linked_request_ids': fields.one2many('hr.holidays', 'parent_id', 'Linked Requests',), 'department_id':fields.related('employee_id', 'department_id', string='Department', type='many2one', relation='hr.department', readonly=True, store=True), - 'category_id': fields.many2one('hr.employee.category', "Category", help='Category Of employee'), + 'category_id': fields.many2one('hr.employee.category', "Category", help='Category of Employee'), 'holiday_type': fields.selection([('employee','By Employee'),('category','By Employee Category')], 'Allocation Type', help='By Employee: Allocation/Request for individual Employee, By Employee Category: Allocation/Request for group of employees in category', required=True), 'manager_id2': fields.many2one('hr.employee', 'Second Approval', readonly=True, help='This area is automaticly filled by the user who validate the leave with second level (If Leave type need second validation)') } - _defaults = { 'employee_id': _employee_get, 'state': 'draft', 'type': 'remove', - 'allocation_type': 'employee', 'user_id': lambda obj, cr, uid, context: uid, 'holiday_type': 'employee' } + _sql_constraints = [ + ('type_value', "CHECK( (holiday_type='employee' AND employee_id IS NOT NULL) or (holiday_type='category' AND category_id IS NOT NULL))", "You have to select an employee or a category"), + ('date_check', "CHECK ( number_of_days_temp > 0 )", "The number of days must be greater than 0 !"), + ('date_check2', "CHECK ( (type='add') OR (date_from < date_to))", "The start date must be before the end date !") + ] def _create_resource_leave(self, cr, uid, vals, context=None): '''This method will create entry in resource calendar leave object at the time of holidays validated ''' @@ -178,28 +160,6 @@ class hr_holidays(osv.osv): leave_ids = obj_res_leave.search(cr, uid, [('holiday_id', 'in', ids)], context=context) return obj_res_leave.unlink(cr, uid, leave_ids) - def create(self, cr, uid, vals, context=None): - if context is None: - context = {} - if 'holiday_type' in vals: - if vals['holiday_type'] == 'employee': - vals.update({'category_id': False}) - else: - vals.update({'employee_id': False}) - if context.has_key('type'): - vals['type'] = context['type'] - if context.has_key('allocation_type'): - vals['allocation_type'] = context['allocation_type'] - return super(hr_holidays, self).create(cr, uid, vals, context=context) - - def write(self, cr, uid, ids, vals, context=None): - if 'holiday_type' in vals: - if vals['holiday_type'] == 'employee': - vals.update({'category_id': False}) - else: - vals.update({'employee_id': False}) - return super(hr_holidays, self).write(cr, uid, ids, vals, context=context) - def onchange_type(self, cr, uid, ids, holiday_type): result = {} if holiday_type == 'employee': @@ -207,9 +167,10 @@ class hr_holidays(osv.osv): if ids_employee: result['value'] = { 'employee_id': ids_employee[0] - } + } return result + # TODO: can be improved using resource calendar method def _get_number_of_days(self, date_from, date_to): """Returns a float equals to the timedelta between two dates given as string.""" @@ -220,35 +181,10 @@ class hr_holidays(osv.osv): diff_day = timedelta.days + float(timedelta.seconds) / 86400 return diff_day - def _update_user_holidays(self, cr, uid, ids): - obj_crm_meeting = self.pool.get('crm.meeting') - for record in self.browse(cr, uid, ids): - if record.state=='validate': - if record.case_id: - obj_crm_meeting.unlink(cr, uid, [record.case_id.id]) - if record.linked_request_ids: - list_ids = [ lr.id for lr in record.linked_request_ids] - self.holidays_cancel(cr, uid, list_ids) - self.unlink(cr, uid, list_ids) - return True - - def _check_date(self, cr, uid, ids, context=None): - for rec in self.read(cr, uid, ids, ['number_of_days_temp', 'date_from','date_to', 'type']): - if rec['number_of_days_temp'] < 0: - return False - if rec['type'] == 'add': - continue - date_from = time.strptime(rec['date_from'], '%Y-%m-%d %H:%M:%S') - date_to = time.strptime(rec['date_to'], '%Y-%m-%d %H:%M:%S') - if date_from > date_to: - return False - return True - - _constraints = [(_check_date, 'Start date should not be larger than end date!\nNumber of Days should be greater than 1!', ['number_of_days_temp'])] - def unlink(self, cr, uid, ids, context=None): - self._update_user_holidays(cr, uid, ids) - self._remove_resouce_leave(cr, uid, ids, context=context) + for rec in self.browse(cr, uid, ids, context=context): + if rec.state<>'draft': + raise osv.except_osv(_('Warning!'),_('You cannot delete a leave which is not in draft state !')) return super(hr_holidays, self).unlink(cr, uid, ids, context) def onchange_date_from(self, cr, uid, ids, date_to, date_from): @@ -264,209 +200,115 @@ class hr_holidays(osv.osv): } return result - def onchange_date_to(self, cr, uid, ids, date_from, date_to): - return self.onchange_date_from(cr, uid, ids, date_to, date_from) - def onchange_sec_id(self, cr, uid, ids, status, context=None): warning = {} if status: - brows_obj = self.pool.get('hr.holidays.status').browse(cr, uid, [status], context=context)[0] + brows_obj = self.pool.get('hr.holidays.status').browse(cr, uid, status, context=context) if brows_obj.categ_id and brows_obj.categ_id.section_id and not brows_obj.categ_id.section_id.allow_unlink: warning = { 'title': "Warning for ", 'message': "You won\'t be able to cancel this leave request because the CRM Sales Team of the leave type disallows." - } + } return {'warning': warning} def set_to_draft(self, cr, uid, ids, *args): - wf_service = netsvc.LocalService("workflow") self.write(cr, uid, ids, { 'state': 'draft', 'manager_id': False, - 'number_of_days': 0, }) + wf_service = netsvc.LocalService("workflow") for id in ids: wf_service.trg_create(uid, 'hr.holidays', id, cr) return True - def holidays_validate2(self, cr, uid, ids, *args): - obj_emp = self.pool.get('hr.employee') - wf_service = netsvc.LocalService("workflow") - vals = {'state':'validate1'} - self.check_holidays(cr, uid, ids) - ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)]) - if ids2: - vals['manager_id'] = ids2[0] - else: - raise osv.except_osv(_('Warning !'),_('No user related to the selected employee.')) - # Second Time Validate all the leave requests of the category - for leave_id in self._get_category_leave_ids(cr, uid, ids): - wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'second_validate', cr) - return self.write(cr, uid, ids, vals) - def holidays_validate(self, cr, uid, ids, *args): - obj_emp = self.pool.get('hr.employee') - wf_service = netsvc.LocalService("workflow") - data_holiday = self.browse(cr, uid, ids) self.check_holidays(cr, uid, ids) - vals = {'state':'validate'} + obj_emp = self.pool.get('hr.employee') ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)]) - if ids2: - if data_holiday[0].state == 'validate1': - vals['manager_id2'] = ids2[0] - else: - vals['manager_id'] = ids2[0] - else: - raise osv.except_osv(_('Warning !'), _('No user related to the selected employee.')) - self.write(cr, uid, ids, vals) + manager = ids2 and ids2[0] or False + return self.write(cr, uid, ids, {'state':'validate1', 'manager_id': manager}) + + def holidays_validate2(self, cr, uid, ids, *args): + self.check_holidays(cr, uid, ids) + obj_emp = self.pool.get('hr.employee') + ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)]) + manager = ids2 and ids2[0] or False + self.write(cr, uid, ids, {'state':'validate', 'manager_id2': manager}) + data_holiday = self.browse(cr, uid, ids) for record in data_holiday: if record.holiday_type == 'employee' and record.type == 'remove': - vals = { - 'name': record.name, - 'date_from': record.date_from, - 'date_to': record.date_to, - 'calendar_id': record.employee_id.calendar_id.id, - 'company_id': record.employee_id.company_id.id, - 'resource_id': record.employee_id.resource_id.id, - 'holiday_id': record.id - } - self._create_resource_leave(cr, uid, vals) - elif record.holiday_type == 'category': - # Create leave/allocation request for employees in the category - emp_ids = obj_emp.search(cr, uid, [('category_ids', '=', record.category_id.id)]) - leave_ids = [] - for emp in obj_emp.browse(cr, uid, emp_ids): - vals = { - 'name': record.name, - 'type': record.type, - 'holiday_type': 'employee', - 'holiday_status_id': record.holiday_status_id.id, - 'date_from': record.date_from, - 'date_to': record.date_to, - 'notes': record.notes, - 'number_of_days_temp': record.number_of_days_temp, - 'parent_id': record.id, - 'employee_id': emp.id - } - leave_ids.append(self.create(cr, uid, vals, context=None)) - # Confirm and validate all the leave requests of the category - for leave_id in leave_ids: - wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'confirm', cr) - wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'validate', cr) - return True - - def holidays_confirm(self, cr, uid, ids, *args): - obj_hr_holiday_status = self.pool.get('hr.holidays.status') - for record in self.browse(cr, uid, ids): - user_id = False - leave_asked = record.number_of_days_temp - if record.holiday_type == 'employee' and record.type == 'remove': - if record.employee_id and not record.holiday_status_id.limit: - leaves_rest = obj_hr_holiday_status.get_days( cr, uid, [record.holiday_status_id.id], record.employee_id.id, False)[record.holiday_status_id.id]['remaining_leaves'] - if leaves_rest < leave_asked: - raise osv.except_osv(_('Warning!'),_('You cannot validate leaves for employee %s while there are too few remaining leave days.') % (record.employee_id.name)) - nb = -(record.number_of_days_temp) - elif record.holiday_type == 'category' and record.type == 'remove': - if record.category_id and not record.holiday_status_id.limit: - leaves_rest = obj_hr_holiday_status.get_days_cat( cr, uid, [record.holiday_status_id.id], record.category_id.id, False)[record.holiday_status_id.id]['remaining_leaves'] - if leaves_rest < leave_asked: - raise osv.except_osv(_('Warning!'),_('You cannot validate leaves for category %s while there are too few remaining leave days.') % (record.category_id.name)) - nb = -(record.number_of_days_temp) - else: - nb = record.number_of_days_temp - - if record.holiday_type == 'employee' and record.employee_id: - user_id = record.employee_id.user_id and record.employee_id.user_id.id or uid - - self.write(cr, uid, [record.id], {'state':'confirm', 'number_of_days': nb, 'user_id': user_id}) - return True - - def holidays_refuse(self, cr, uid, ids, *args): - obj_emp = self.pool.get('hr.employee') - wf_service = netsvc.LocalService("workflow") - vals = {'state': 'refuse'} - ids2 = obj_emp.search(cr, uid, [('user_id','=', uid)]) - if ids2: - vals['manager_id'] = ids2[0] - # Refuse all the leave requests of the category - for leave_id in self._get_category_leave_ids(cr, uid, ids): - wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'refuse', cr) - self.write(cr, uid, ids, vals) - return True - - def holidays_cancel(self, cr, uid, ids, *args): - self._update_user_holidays(cr, uid, ids) - self.write(cr, uid, ids, {'state': 'cancel'}) - self._remove_resouce_leave(cr, uid, ids) - return True - - def holidays_draft(self, cr, uid, ids, *args): - wf_service = netsvc.LocalService("workflow") - for leave_id in self._get_category_leave_ids(cr, uid, ids): - wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'draft', cr) - return self.write(cr, uid, ids, {'state': 'draft'}) - - def check_holidays(self, cr, uid, ids): - holi_status_obj = self.pool.get('hr.holidays.status') - emp_obj = self.pool.get('hr.employee') - meeting_obj = self.pool.get('crm.meeting') - for record in self.browse(cr, uid, ids): - if not record.number_of_days: - raise osv.except_osv(_('Warning!'), _('Wrong leave definition.')) - if record.holiday_type=='employee' and record.employee_id: - leave_asked = record.number_of_days - if leave_asked < 0.00: - if not record.holiday_status_id.limit: - leaves_rest = holi_status_obj.get_days(cr, uid, [record.holiday_status_id.id], record.employee_id.id, False)[record.holiday_status_id.id]['remaining_leaves'] - if leaves_rest < -(leave_asked): - raise osv.except_osv(_('Warning!'),_('You Cannot Validate leaves while available leaves are less than asked leaves.')) - elif record.holiday_type == 'category' and record.category_id: - leave_asked = record.number_of_days - if leave_asked < 0.00: - if not record.holiday_status_id.limit: - leaves_rest = holi_status_obj.get_days_cat(cr, uid, [record.holiday_status_id.id], record.category_id.id, False)[record.holiday_status_id.id]['remaining_leaves'] - if leaves_rest < -(leave_asked): - raise osv.except_osv(_('Warning!'),_('You Cannot Validate leaves while available leaves are less than asked leaves.')) - else:# This condition will never meet!! - holiday_ids = [] - vals = { - 'name': record.name, - 'holiday_status_id': record.holiday_status_id.id, - 'state': 'draft', - 'date_from': record.date_from, - 'date_to': record.date_to, - 'notes': record.notes, - 'number_of_days': record.number_of_days, - 'number_of_days_temp': record.number_of_days_temp, - 'type': record.type, - 'allocation_type': record.allocation_type, - 'parent_id': record.id, - } - employee_ids = emp_obj.search(cr, uid, []) - for employee in employee_ids: - vals['employee_id'] = employee - user_id = emp_obj.search(cr, uid, [('user_id','=',uid)]) - if user_id: - vals['user_id'] = user_id[0] - holiday_ids.append(self.create(cr, uid, vals, context=None)) - self.holidays_confirm(cr, uid, holiday_ids) - self.holidays_validate(cr, uid, holiday_ids) - - if record.holiday_status_id.categ_id and record.date_from and record.date_to and record.employee_id: - diff_day = self._get_number_of_days(record.date_from, record.date_to) + meeting_obj = self.pool.get('crm.meeting') vals = { 'name': record.name, 'categ_id': record.holiday_status_id.categ_id.id, - 'duration': (diff_day) * 8, + 'duration': record.number_of_days_temp * 8, 'note': record.notes, 'user_id': record.user_id.id, 'date': record.date_from, + 'end_date': record.date_to, + 'date_deadline': record.date_to, } case_id = meeting_obj.create(cr, uid, vals) self.write(cr, uid, ids, {'case_id': case_id}) + elif record.holiday_type == 'category': + emp_ids = obj_emp.search(cr, uid, [('category_ids', 'child_of', [record.category_id.id])]) + leave_ids = [] + for emp in obj_emp.browse(cr, uid, emp_ids): + vals = { + 'name': record.name, + 'type': record.type, + 'holiday_type': 'employee', + 'holiday_status_id': record.holiday_status_id.id, + 'date_from': record.date_from, + 'date_to': record.date_to, + 'notes': record.notes, + 'number_of_days_temp': record.number_of_days_temp, + 'parent_id': record.id, + 'employee_id': emp.id + } + leave_ids.append(self.create(cr, uid, vals, context=None)) + wf_service = netsvc.LocalService("workflow") + for leave_id in leave_ids: + wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'confirm', cr) + wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'validate', cr) + wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'second_validate', cr) + return True + + def holidays_confirm(self, cr, uid, ids, *args): + self.check_holidays(cr, uid, ids) + return self.write(cr, uid, ids, {'state':'confirm'}) + + def holidays_refuse(self, cr, uid, ids, *args): + obj_emp = self.pool.get('hr.employee') + ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)]) + manager = ids2 and ids2[0] or False + self.write(cr, uid, ids, {'state': 'refuse', 'manager_id2': manager}) + self.holidays_cancel(cr, uid, ids) + return True + + def holidays_cancel(self, cr, uid, ids, *args): + obj_crm_meeting = self.pool.get('crm.meeting') + for record in self.browse(cr, uid, ids): + # Delete the meeting + if record.case_id: + obj_crm_meeting.unlink(cr, uid, [record.case_id.id]) + + # If a category that created several holidays, cancel all related + wf_service = netsvc.LocalService("workflow") + for id in record.linked_request_ids or []: + wf_service.trg_validate(uid, 'hr.holidays', id, 'cancel', cr) return True + def check_holidays(self, cr, uid, ids): + holi_status_obj = self.pool.get('hr.holidays.status') + for record in self.browse(cr, uid, ids): + if record.holiday_type == 'employee' and record.type == 'remove': + if record.employee_id and not record.holiday_status_id.limit: + leaves_rest = holi_status_obj.get_days( cr, uid, [record.holiday_status_id.id], record.employee_id.id, False)[record.holiday_status_id.id]['remaining_leaves'] + if leaves_rest < record.number_of_days_temp: + raise osv.except_osv(_('Warning!'),_('You cannot validate leaves for employee %s: too few remaining days (%s).') % (record.employee_id.name, leaves_rest)) + return True hr_holidays() class resource_calendar_leaves(osv.osv): @@ -478,4 +320,3 @@ class resource_calendar_leaves(osv.osv): resource_calendar_leaves() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_holidays/hr_holidays_view.xml b/addons/hr_holidays/hr_holidays_view.xml index 0fddec73ee0..19c7a41c708 100644 --- a/addons/hr_holidays/hr_holidays_view.xml +++ b/addons/hr_holidays/hr_holidays_view.xml @@ -56,7 +56,7 @@ calendar - + @@ -71,7 +71,7 @@ - + @@ -83,7 +83,7 @@ - + @@ -93,12 +93,11 @@ -