From c5f7f6ecdf710985f29cc73e310ea1f3852b468d Mon Sep 17 00:00:00 2001 From: hugo <> Date: Thu, 21 Jun 2012 14:40:01 +0530 Subject: [PATCH 01/24] [FIX] stock : Wrong quantity on invoice when invoice based on delivery and stock move has more than one line on picking lp bug: https://launchpad.net/bugs/1015697 fixed bzr revid: amp@tinyerp.com-20120621091001-of46b1016rqcpyvz --- addons/stock/stock.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 87cf9ade130..9b754deba7b 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2082,11 +2082,13 @@ class stock_move(osv.osv): done.append(move.id) pickings[move.picking_id.id] = 1 r = res.pop(0) - cr.execute('update stock_move set location_id=%s, product_qty=%s where id=%s', (r[1], r[0], move.id)) + product_uos_qty = self.pool.get('stock.move').onchange_quantity(cr, uid, ids, move.product_id.id, r[0], move.product_id.uom_id.id, move.product_id.uos_id.id)['value']['product_uos_qty'] + cr.execute('update stock_move set location_id=%s, product_qty=%s, product_uos_qty=%s where id=%s', (r[1], r[0], r[0], move.id)) while res: r = res.pop(0) - move_id = self.copy(cr, uid, move.id, {'product_qty': r[0], 'location_id': r[1]}) + product_uos_qty = self.pool.get('stock.move').onchange_quantity(cr, uid, ids, move.product_id.id, r[0], move.product_id.uom_id.id, move.product_id.uos_id.id)['value']['product_uos_qty'] + move_id = self.copy(cr, uid, move.id, {'product_uos_qty': product_uos_qty, 'product_qty': r[0], 'location_id': r[1]}) done.append(move_id) if done: count += len(done) From 03a4cdf6e88e212f0469a6185775c86a85e53ab4 Mon Sep 17 00:00:00 2001 From: Vijaykumar Baladaniya Date: Wed, 22 Aug 2012 11:58:23 +0530 Subject: [PATCH 02/24] Remove OpenERP Enterprise. bzr revid: vba@tinyerp.com-20120822062823-2vmecfbv22wyieoh --- openerp/addons/base/__init__.py | 1 - openerp/addons/base/__openerp__.py | 2 - .../base/publisher_warranty/__init__.py | 25 -- .../publisher_warranty/publisher_warranty.py | 354 ------------------ .../publisher_warranty_data.xml | 20 - .../publisher_warranty_view.xml | 121 ------ .../addons/base/security/ir.model.access.csv | 2 - 7 files changed, 525 deletions(-) delete mode 100644 openerp/addons/base/publisher_warranty/__init__.py delete mode 100644 openerp/addons/base/publisher_warranty/publisher_warranty.py delete mode 100644 openerp/addons/base/publisher_warranty/publisher_warranty_data.xml delete mode 100644 openerp/addons/base/publisher_warranty/publisher_warranty_view.xml diff --git a/openerp/addons/base/__init__.py b/openerp/addons/base/__init__.py index 16a61521fb4..d666a6abbf7 100644 --- a/openerp/addons/base/__init__.py +++ b/openerp/addons/base/__init__.py @@ -22,7 +22,6 @@ import ir import module import res -import publisher_warranty import report import test diff --git a/openerp/addons/base/__openerp__.py b/openerp/addons/base/__openerp__.py index 5b65bff4bd7..8f6356a6962 100644 --- a/openerp/addons/base/__openerp__.py +++ b/openerp/addons/base/__openerp__.py @@ -70,12 +70,10 @@ 'res/res_partner_data.xml', 'res/ir_property_view.xml', 'security/base_security.xml', - 'publisher_warranty/publisher_warranty_view.xml', 'security/ir.model.access.csv', 'security/ir.model.access-1.csv', # res.partner.address is deprecated; it is still there for backward compability only and will be removed in next version 'res/res_widget_view.xml', 'res/res_widget_data.xml', - 'publisher_warranty/publisher_warranty_data.xml', ], 'demo_xml': [ 'base_demo.xml', diff --git a/openerp/addons/base/publisher_warranty/__init__.py b/openerp/addons/base/publisher_warranty/__init__.py deleted file mode 100644 index 6b60ddf3ca1..00000000000 --- a/openerp/addons/base/publisher_warranty/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (). -# -# 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 . -# -############################################################################## - -import publisher_warranty - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/openerp/addons/base/publisher_warranty/publisher_warranty.py b/openerp/addons/base/publisher_warranty/publisher_warranty.py deleted file mode 100644 index 897210ce817..00000000000 --- a/openerp/addons/base/publisher_warranty/publisher_warranty.py +++ /dev/null @@ -1,354 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 OpenERP S.A. (). -# -# 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 . -# -############################################################################## -""" -Module to handle publisher warranty contracts as well as notifications from -OpenERP. -""" - -import datetime -import logging -import sys -import urllib -import urllib2 - -import pooler -import release -from osv import osv, fields -from tools.translate import _ -from tools.safe_eval import safe_eval -from tools.config import config -from tools import misc - -_logger = logging.getLogger(__name__) - -""" -Time interval that will be used to determine up to which date we will -check the logs to see if a message we just received was already logged. -@type: datetime.timedelta -""" -_PREVIOUS_LOG_CHECK = datetime.timedelta(days=365) - -class publisher_warranty_contract(osv.osv): - """ - Osv representing a publisher warranty contract. - """ - _name = "publisher_warranty.contract" - - def _get_valid_contracts(self, cr, uid): - """ - Return the list of the valid contracts encoded in the system. - - @return: A list of contracts - @rtype: list of publisher_warranty.contract browse records - """ - return [contract for contract in self.browse(cr, uid, self.search(cr, uid, [])) - if contract.state == 'valid'] - - def status(self, cr, uid): - """ Method called by the client to check availability of publisher warranty contract. """ - - contracts = self._get_valid_contracts(cr, uid) - return { - 'status': "full" if contracts else "none" , - 'uncovered_modules': list(), - } - - def send(self, cr, uid, tb, explanations, remarks=None, issue_name=None): - """ Method called by the client to send a problem to the publisher warranty server. """ - - if not remarks: - remarks = "" - - valid_contracts = self._get_valid_contracts(cr, uid) - valid_contract = valid_contracts[0] - - try: - origin = 'client' - dbuuid = self.pool.get('ir.config_parameter').get_param(cr, uid, 'database.uuid') - db_create_date = self.pool.get('ir.config_parameter').get_param(cr, uid, 'database.create_date') - user = self.pool.get("res.users").browse(cr, uid, uid) - user_name = user.name - email = user.email - - msg = {'contract_name': valid_contract.name, - 'tb': tb, - 'explanations': explanations, - 'remarks': remarks, - 'origin': origin, - 'dbname': cr.dbname, - 'dbuuid': dbuuid, - 'db_create_date': db_create_date, - 'issue_name': issue_name, - 'email': email, - 'user_name': user_name, - } - - - add_arg = {"timeout":30} if sys.version_info >= (2,6) else {} - uo = urllib2.urlopen(config.get("publisher_warranty_url"), - urllib.urlencode({'arg0': msg, "action": "send",}),**add_arg) - try: - submit_result = uo.read() - finally: - uo.close() - - result = safe_eval(submit_result) - - crm_case_id = result - - if not crm_case_id: - return False - - except osv.except_osv: - raise - except Exception: - _logger.warning("Error sending problem report", exc_info=1) - raise osv.except_osv(_("Error"), - _("Error during communication with the publisher warranty server.")) - - return True - - def check_validity(self, cr, uid, ids, context=None): - """ - Check the validity of a publisher warranty contract. This method just call get_logs() but checks - some more things, so it can be called from a user interface. - """ - contract_id = ids[0] - contract = self.browse(cr, uid, contract_id) - state = contract.state - validated = state != "unvalidated" - - self.get_logs(cr, uid, ids, cron_mode=False, context=context) - - contract = self.browse(cr, uid, contract_id) - validated2 = contract.state != "unvalidated" - if not validated and not validated2: - raise osv.except_osv(_("Contract validation error"), - _("Please verify your publisher warranty serial number and validity.")) - return True - - def get_logs(self, cr, uid, ids, cron_mode=True, context=None): - """ - Send a message to OpenERP's publisher warranty server to check the validity of - the contracts, get notifications, etc... - - @param cron_mode: If true, catch all exceptions (appropriate for usage in a cron). - @type cron_mode: boolean - """ - try: - try: - result = get_sys_logs(cr, uid) - except Exception: - if cron_mode: # we don't want to see any stack trace in cron - return False - _logger.debug("Exception while sending a get logs messages", exc_info=1) - raise osv.except_osv(_("Error"), _("Error during communication with the publisher warranty server.")) - - contracts = result["contracts"] - for contract in contracts: - c_id = self.search(cr, uid, [("name","=",contract)])[0] - # for backward compatibility - if type(contracts[contract]) == tuple: - self.write(cr, uid, c_id, { - "date_start": contracts[contract][0], - "date_stop": contracts[contract][1], - "state": contracts[contract][2], - "check_support": False, - "check_opw": False, - "kind": "", - }) - else: - self.write(cr, uid, c_id, { - "date_start": contracts[contract]["date_from"], - "date_stop": contracts[contract]["date_to"], - "state": contracts[contract]["state"], - "check_support": contracts[contract]["check_support"], - "check_opw": contracts[contract]["check_opw"], - "kind": contracts[contract]["kind"], - }) - - - limit_date = (datetime.datetime.now() - _PREVIOUS_LOG_CHECK).strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT) - - # old behavior based on res.log; now on mail.message, that is not necessarily installed - mail_message_obj = self.pool.get('mail.message') - if mail_message_obj: - for message in result["messages"]: - ids = mail_message_obj.search(cr, uid, [("model", "=", "publisher_warranty.contract"), - ("create_date", ">=", limit_date), - ("body_text", "=", message)]) - if ids: - continue - mail_message_obj.create(cr, uid, { - 'name': message, - 'model': "publisher_warranty.contract", - 'user_id': False, - }, context=context) - except Exception: - if cron_mode: - return False # we don't want to see any stack trace in cron - else: - raise - return True - - def get_last_user_messages(self, cr, uid, limit, context=None): - """ - Get the messages to be written in the web client. - @return: A list of html messages with ids, can be False or empty. - @rtype: list of tuples(int,string) - """ - if not self.pool.get('mail.message'): - return [] - ids = self.pool.get('mail.message').search(cr, uid, [("model", "=", "publisher_warranty.contract")] - , order="create_date desc", limit=limit, context=context) - if not ids: - return [] - messages = [(x.id, x.name) for x in self.pool.get('mail.message').browse(cr, uid, ids, context=context)] - return messages - - _columns = { - 'name' : fields.char('Serial Key', size=384, required=True, help="Your OpenERP Publisher's Warranty Contract unique key, also called serial number."), - 'date_start' : fields.date('Starting Date', readonly=True), - 'date_stop' : fields.date('Ending Date', readonly=True), - 'state' : fields.selection([('unvalidated', 'Unvalidated'), ('valid', 'Valid') - , ('terminated', 'Terminated'), ('canceled', 'Canceled')], string="State", readonly=True), - 'kind' : fields.char('Contract Category', size=64, readonly=True), - "check_support": fields.boolean("Support Level 1", readonly=True), - "check_opw": fields.boolean("OPW", readonly=True, help="Checked if this is an OpenERP Publisher's Warranty contract (versus older contract types"), - } - - _defaults = { - 'state': 'unvalidated', - } - - _sql_constraints = [ - ('uniq_name', 'unique(name)', "That contract is already registered in the system.") - ] - -publisher_warranty_contract() - -class maintenance_contract(osv.osv_memory): - """ Old osv we only keep for compatibility with the clients. """ - - _name = "maintenance.contract" - - def status(self, cr, uid): - return self.pool.get("publisher_warranty.contract").status(cr, uid) - - def send(self, cr, uid, tb, explanations, remarks=None, issue_name=None): - return self.pool.get("publisher_warranty.contract").send(cr, uid, tb, - explanations, remarks, issue_name) - -maintenance_contract() - -class publisher_warranty_contract_wizard(osv.osv_memory): - """ - A wizard osv to help people entering a publisher warranty contract. - """ - _name = 'publisher_warranty.contract.wizard' - _inherit = "ir.wizard.screen" - - _columns = { - 'name' : fields.char('Serial Key', size=256, required=True, help="Your OpenERP Publisher's Warranty Contract unique key, also called serial number."), - 'state' : fields.selection([("draft", "Draft"), ("finished", "Finished")]) - } - - _defaults = { - "state": "draft", - } - - def action_validate(self, cr, uid, ids, context=None): - if not ids: - return False - - wiz = self.browse(cr, uid, ids[0]) - c_name = wiz.name - - contract_osv = self.pool.get("publisher_warranty.contract") - contracts = contract_osv.search(cr, uid, [("name","=",c_name)]) - if contracts: - raise osv.except_osv(_("Error"), _("That contract is already registered in the system.")) - - contract_id = contract_osv.create(cr, uid, { - "name": c_name, - "state": "unvalidated", - }) - - contract_osv.check_validity(cr, uid, [contract_id]) - - self.write(cr, uid, ids, {"state": "finished"}) - - # We should return an action ? - return True - - -publisher_warranty_contract_wizard() - -def get_sys_logs(cr, uid): - """ - Utility method to send a publisher warranty get logs messages. - """ - pool = pooler.get_pool(cr.dbname) - - dbuuid = pool.get('ir.config_parameter').get_param(cr, uid, 'database.uuid') - db_create_date = pool.get('ir.config_parameter').get_param(cr, uid, 'database.create_date') - limit_date = datetime.datetime.now() - limit_date = limit_date - datetime.timedelta(15) - limit_date_str = limit_date.strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT) - nbr_users = pool.get("res.users").search(cr, uid, [], count=True) - nbr_active_users = pool.get("res.users").search(cr, uid, [("date", ">=", limit_date_str)], count=True) - nbr_share_users = False - nbr_active_share_users = False - if "share" in pool.get("res.users")._all_columns: - nbr_share_users = pool.get("res.users").search(cr, uid, [("share", "=", True)], count=True) - nbr_active_share_users = pool.get("res.users").search(cr, uid, [("share", "=", True), ("date", ">=", limit_date_str)], count=True) - contractosv = pool.get('publisher_warranty.contract') - contracts = contractosv.browse(cr, uid, contractosv.search(cr, uid, [])) - user = pool.get("res.users").browse(cr, uid, uid) - msg = { - "dbuuid": dbuuid, - "nbr_users": nbr_users, - "nbr_active_users": nbr_active_users, - "nbr_share_users": nbr_share_users, - "nbr_active_share_users": nbr_active_share_users, - "dbname": cr.dbname, - "db_create_date": db_create_date, - "version": release.version, - "contracts": [c.name for c in contracts], - "language": user.lang, - } - - add_arg = {"timeout":30} if sys.version_info >= (2,6) else {} - arguments = {'arg0': msg, "action": "update",} - arguments_raw = urllib.urlencode(arguments) - url = config.get("publisher_warranty_url") - uo = urllib2.urlopen(url, arguments_raw, **add_arg) - try: - submit_result = uo.read() - finally: - uo.close() - - result = safe_eval(submit_result) if submit_result else {} - - return result - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/openerp/addons/base/publisher_warranty/publisher_warranty_data.xml b/openerp/addons/base/publisher_warranty/publisher_warranty_data.xml deleted file mode 100644 index 68594e5d88f..00000000000 --- a/openerp/addons/base/publisher_warranty/publisher_warranty_data.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - Update System Logs - - - 1 - weeks - -1 - - - - - 1000 - - - - \ No newline at end of file diff --git a/openerp/addons/base/publisher_warranty/publisher_warranty_view.xml b/openerp/addons/base/publisher_warranty/publisher_warranty_view.xml deleted file mode 100644 index f4c196db672..00000000000 --- a/openerp/addons/base/publisher_warranty/publisher_warranty_view.xml +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - publisher_warranty.contract.tree - publisher_warranty.contract - - - - - - - - - - - - publisher_warranty.contract.form - publisher_warranty.contract - -
-
-
- - - - - - - - - - - - - - - - - -
-
-
- - - publisher_warranty.contract.search - publisher_warranty.contract - - - - - - - - - - - publisher_warranty.contract.calendar - publisher_warranty.contract - - - - - - - - - - Contracts - ir.actions.act_window - publisher_warranty.contract - form - tree,form,calendar - - - - - - - publisher_warranty.contract.add.wizard - publisher_warranty.contract.wizard - -
- - - - - - -
-
- -
-
- - - Register a Contract - ir.actions.act_window - publisher_warranty.contract.wizard - form - form - new - - - -
-
diff --git a/openerp/addons/base/security/ir.model.access.csv b/openerp/addons/base/security/ir.model.access.csv index d49aa18db8c..c5fb25ea604 100644 --- a/openerp/addons/base/security/ir.model.access.csv +++ b/openerp/addons/base/security/ir.model.access.csv @@ -106,8 +106,6 @@ "access_res_payterm_group_system","res_payterm_group_system","model_res_payterm","group_system",1,1,1,1 "access_res_bank_group_partner_manager","res_bank_group_partner_manager","model_res_bank","group_partner_manager",1,1,1,1 "access_res_bank_user","res_bank user","model_res_bank","group_user",1,0,0,0 -"access_publisher_warranty_group_user","publisher_warranty_contract group_user","model_publisher_warranty_contract","group_system",1,1,1,1 -"access_publisher_warranty_all","publisher_warranty_contract all","model_publisher_warranty_contract",,1,0,0,0 "access_multi_company_default user","multi_company_default all","model_multi_company_default",,1,0,0,0 "access_multi_company_default manager","multi_company_default Manager","model_multi_company_default","group_erp_manager",1,1,1,1 "access_ir_filter all","ir_filters all","model_ir_filters",,1,0,0,0 From b0bbf9522df336cf65712f5e6a48e7f3bd89f5eb Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Wed, 22 Aug 2012 14:02:28 +0530 Subject: [PATCH 03/24] Remove publisher_warranty.contract bzr revid: tta@openerp.com-20120822083228-yviw5v0bgcui9hpz --- addons/web/common/session.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/addons/web/common/session.py b/addons/web/common/session.py index 5906ee6314e..c203a1acb33 100644 --- a/addons/web/common/session.py +++ b/addons/web/common/session.py @@ -105,10 +105,8 @@ class OpenERPSession(object): return state def openerp_entreprise(self): - if not self._uid: - return False - else: - return self.model('publisher_warranty.contract').status()['status'] == 'full' + return False + def build_connection(self): conn = openerplib.Connection(self.config.connector, database=self._db, login=self._login, From dbb9833d689f1da94957e526fd99ab712f4b456e Mon Sep 17 00:00:00 2001 From: Minh Tran Date: Thu, 23 Aug 2012 11:45:32 +0200 Subject: [PATCH 04/24] fix jquery-ui widget border bzr revid: mit@openerp.com-20120823094532-bluw3pix6dwm1a6i --- addons/web/static/src/css/base.css | 12 +----------- addons/web/static/src/css/base.sass | 10 +--------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 9ea94ebdbb0..4f34c050f46 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -454,13 +454,6 @@ -webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.2); box-shadow: 0 0 1px rgba(0, 0, 0, 0.2); } -.openerp ul.oe_flatlist, .openerp ol.oe_flatlist { - margin: 0; - padding: 0; -} -.openerp ul.oe_flatlist li, .openerp ol.oe_flatlist li { - list-style-type: none; -} .openerp .oe_form_dirty .oe_highlight_on_dirty { color: white; background: #dc5f59; @@ -2753,6 +2746,7 @@ div.ui-widget-overlay { -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); margin-top: 4px; + border: 1px solid #afafb6; } .ui-menu .ui-menu-item { width: 100%; @@ -2778,7 +2772,3 @@ div.ui-widget-overlay { -webkit-border-radius: 3px; border-radius: 3px; } - -.ui-widget-content { - border: 1px solid #afafb6; -} diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index b5eae0d7213..4a26ea0d54e 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -391,12 +391,6 @@ $sheet-max-width: 860px //@include vertical-gradient(lighten(#dc5f59, 3%), lighten(#b33630, 3%)) @include box-shadow(0 0 1px rgba(0, 0, 0, 0.2)) - ul.oe_flatlist, ol.oe_flatlist - margin: 0 - padding: 0 - li - list-style-type: none - .oe_form_dirty .oe_highlight_on_dirty color: white @@ -2152,6 +2146,7 @@ div.ui-widget-overlay padding: 2px 0 @include box-shadow(0 1px 4px rgba(0,0,0,0.3)) margin-top: 4px + border: 1px solid $tag-border .ui-menu-item width: 100% padding: 0 @@ -2169,8 +2164,5 @@ div.ui-widget-overlay .ui-corner-all @include radius(3px) -.ui-widget-content - border: 1px solid $tag-border - // au BufWritePost,FileWritePost *.sass :!sass --style expanded --line-numbers > "%:p:r.css" // vim:tabstop=4:shiftwidth=4:softtabstop=4:fdm=marker: From 74ec2642d1a174fc60dd0f0562e9b481e8b0ec86 Mon Sep 17 00:00:00 2001 From: "Ravish Murari (OpenERP)" Date: Thu, 23 Aug 2012 18:09:22 +0530 Subject: [PATCH 05/24] [FIX] improved the code bzr revid: rmu@tinyerp.com-20120823123922-6scwgtt8ub2jnylu --- addons/stock/stock.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index cd08a07df33..af4cc0e9287 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2092,7 +2092,6 @@ class stock_move(osv.osv): while res: r = res.pop(0) - product_uos_qty = self.pool.get('stock.move').onchange_quantity(cr, uid, ids, move.product_id.id, r[0], move.product_id.uom_id.id, move.product_id.uos_id.id)['value']['product_uos_qty'] move_id = self.copy(cr, uid, move.id, {'product_uos_qty': product_uos_qty, 'product_qty': r[0], 'location_id': r[1]}) done.append(move_id) if done: From 324e0b72086a0d85eff44fd1a74a056c6c314884 Mon Sep 17 00:00:00 2001 From: "Ravish Murari (OpenERP)" Date: Thu, 23 Aug 2012 18:41:16 +0530 Subject: [PATCH 06/24] [FIX] improved the code bzr revid: rmu@tinyerp.com-20120823131116-q5qpegig5cs8x9z9 --- addons/stock/stock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index af4cc0e9287..7f0a744a62e 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2088,7 +2088,7 @@ class stock_move(osv.osv): pickings[move.picking_id.id] = 1 r = res.pop(0) product_uos_qty = self.pool.get('stock.move').onchange_quantity(cr, uid, ids, move.product_id.id, r[0], move.product_id.uom_id.id, move.product_id.uos_id.id)['value']['product_uos_qty'] - cr.execute('update stock_move set location_id=%s, product_qty=%s, product_uos_qty=%s where id=%s', (r[1], r[0], r[0], move.id)) + cr.execute('update stock_move set location_id=%s, product_qty=%s, product_uos_qty=%s where id=%s', (r[1], r[0],product_uos_qty, move.id)) while res: r = res.pop(0) From cd4a62996a72ab9997b912c12deda6a5dd0a5226 Mon Sep 17 00:00:00 2001 From: Thibault Date: Thu, 23 Aug 2012 17:32:03 +0200 Subject: [PATCH 07/24] [REF] mail_alias: moved _auto_init code from res_users and hr_recruitment to mail_alias, using a kewl call to migrate_to_alias. bzr revid: odo@openerp.com-20120823153203-8tm3lbqah6vwd7co --- addons/hr_recruitment/hr_recruitment.py | 44 +++----------------- addons/mail/mail_alias.py | 55 +++++++++++++++++++++++++ addons/mail/res_users.py | 36 +--------------- 3 files changed, 63 insertions(+), 72 deletions(-) diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 81a7ae6129e..6b4839b7b2b 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -19,18 +19,13 @@ # ############################################################################## -import logging import time -from datetime import datetime - import tools -from osv import fields, osv -from openerp.modules.registry import RegistryManager -from openerp import SUPERUSER_ID -from base_status.base_stage import base_stage -from tools.translate import _ -_logger = logging.getLogger(__name__) +from base_status.base_stage import base_stage +from datetime import datetime +from osv import fields, osv +from tools.translate import _ AVAILABLE_STATES = [ ('draft', 'New'), @@ -522,35 +517,8 @@ class hr_job(osv.osv): def _auto_init(self, cr, context=None): """Installation hook to create aliases for all jobs and avoid constraint errors.""" - - # disable the unique alias_id not null constraint, to avoid spurious warning during - # super.auto_init. We'll reinstall it afterwards. - self._columns['alias_id'].required = False - - super(hr_job,self)._auto_init(cr, context=context) - - registry = RegistryManager.get(cr.dbname) - mail_alias = registry.get('mail.alias') - hr_jobs = registry.get('hr.job') - jobs_no_alias = hr_jobs.search(cr, SUPERUSER_ID, [('alias_id', '=', False)]) - # Use read() not browse(), to avoid prefetching uninitialized inherited fields - for job_data in hr_jobs.read(cr, SUPERUSER_ID, jobs_no_alias, ['name']): - alias_id = mail_alias.create_unique_alias(cr, SUPERUSER_ID, {'alias_name': 'job+'+job_data['name'], - 'alias_defaults': {'job_id': job_data['id']}}, - model_name='hr.applicant') - hr_jobs.write(cr, SUPERUSER_ID, job_data['id'], {'alias_id': alias_id}) - _logger.info('Mail alias created for hr.job %s (uid %s)', job_data['name'], job_data['id']) - - # Finally attempt to reinstate the missing constraint - try: - cr.execute('ALTER TABLE hr_job ALTER COLUMN alias_id SET NOT NULL') - except Exception: - _logger.warning("Table '%s': unable to set a NOT NULL constraint on column '%s' !\n"\ - "If you want to have it, you should update the records and execute manually:\n"\ - "ALTER TABLE %s ALTER COLUMN %s SET NOT NULL", - self._table, 'alias_id', self._table, 'alias_id') - - self._columns['alias_id'].required = True + self.pool.get('mail.alias').migrate_to_alias(cr, self._name, self._table, super(hr_job,self)._auto_init, + self._columns['alias_id'], 'name', alias_prefix='job+', alias_defaults={'job_id': 'id'}, context=context) def create(self, cr, uid, vals, context=None): mail_alias = self.pool.get('mail.alias') diff --git a/addons/mail/mail_alias.py b/addons/mail/mail_alias.py index 82b20f39480..4ed9c5dc2ab 100644 --- a/addons/mail/mail_alias.py +++ b/addons/mail/mail_alias.py @@ -19,11 +19,16 @@ # ############################################################################## +import logging import re import unicodedata from openerp.osv import fields, osv from openerp.tools import ustr +from openerp.modules.registry import RegistryManager +from openerp import SUPERUSER_ID + +_logger = logging.getLogger(__name__) # Inspired by http://stackoverflow.com/questions/517923 def remove_accents(input_str): @@ -129,6 +134,56 @@ class mail_alias(osv.Model): sequence = (sequence + 1) if sequence else 2 return new_name + def migrate_to_alias(self, cr, child_model_name, child_table_name, child_model_auto_init_fct, + alias_id_column, alias_column, alias_prefix = '', alias_force_thread_id = '', alias_defaults = {}, context=None): + """ Installation hook to create aliases for all users and avoid constraint errors. + + :param child_model_name: model name of the child class (i.e. res.users) + :param child_table_name: table name of the child class (i.e. res_users) + :param child_model_auto_init_fct: pointer to the _auto_init function + (i.e. super(res_users,self)._auto_init(cr, context=context)) + :param alias_id_column: alias_id column (i.e. self._columns['alias_id']) + :param alias_column: column used for the unique name (i.e. 'login') + :param alias_prefix: prefix for the unique name (i.e. 'jobs' + ...) + :param alias_force_thread_id': name of the column for force_thread_id; + if empty string, not taken into account + :param alias_defaults: dict, keys = mail.alias columns, values = child + model column name used for default values (i.e. {'job_id': 'id'}) + """ + + # disable the unique alias_id not null constraint, to avoid spurious warning during + # super.auto_init. We'll reinstall it afterwards. + alias_id_column.required = False + + # call _auto_init + child_model_auto_init_fct(cr, context=context) + + registry = RegistryManager.get(cr.dbname) + mail_alias = registry.get('mail.alias') + child_class_model = registry.get(child_model_name) + no_alias_ids = child_class_model.search(cr, SUPERUSER_ID, [('alias_id', '=', False)]) + # Use read() not browse(), to avoid prefetching uninitialized inherited fields + for obj_data in child_class_model.read(cr, SUPERUSER_ID, no_alias_ids, [alias_column]): + alias_vals = {'alias_name': '%s%s' % (alias_prefix, obj_data[alias_column]) } + if alias_force_thread_id: + alias_vals['alias_force_thread_id'] = obj_data[alias_force_thread_id] + alias_vals['alias_defaults'] = dict( (k, obj_data[v]) for k, v in alias_defaults.iteritems()) + alias_id = mail_alias.create_unique_alias(cr, SUPERUSER_ID, alias_vals, model_name=child_model_name) + child_class_model.write(cr, SUPERUSER_ID, obj_data['id'], {'alias_id': alias_id}) + _logger.info('Mail alias created for %s %s (uid %s)', child_model_name, obj_data[alias_column], obj_data['id']) + + # Finally attempt to reinstate the missing constraint + try: + cr.execute('ALTER TABLE %s ALTER COLUMN alias_id SET NOT NULL' % (child_table_name)) + except Exception: + _logger.warning("Table '%s': unable to set a NOT NULL constraint on column '%s' !\n"\ + "If you want to have it, you should update the records and execute manually:\n"\ + "ALTER TABLE %s ALTER COLUMN %s SET NOT NULL", + child_table_name, 'alias_id', child_table_name, 'alias_id') + + # set back the unique alias_id constraint + alias_id_column.required = True + def create_unique_alias(self, cr, uid, vals, model_name=None, context=None): """Creates an email.alias record according to the values provided in ``vals``, with 2 alterations: the ``alias_name`` value may be suffixed in order to diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index f985ac4f88d..829ba739dd4 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -19,15 +19,10 @@ # ############################################################################## -import logging - from osv import osv, fields -from openerp.modules.registry import RegistryManager from openerp import SUPERUSER_ID from tools.translate import _ -_logger = logging.getLogger(__name__) - class res_users(osv.Model): """ Update of res.users class - add a preference about sending emails about notifications @@ -69,35 +64,8 @@ class res_users(osv.Model): def _auto_init(self, cr, context=None): """Installation hook to create aliases for all users and avoid constraint errors.""" - - # disable the unique alias_id not null constraint, to avoid spurious warning during - # super.auto_init. We'll reinstall it afterwards. - self._columns['alias_id'].required = False - - super(res_users,self)._auto_init(cr, context=context) - - registry = RegistryManager.get(cr.dbname) - mail_alias = registry.get('mail.alias') - res_users_model = registry.get('res.users') - users_no_alias = res_users_model.search(cr, SUPERUSER_ID, [('alias_id', '=', False)]) - # Use read() not browse(), to avoid prefetching uninitialized inherited fields - for user_data in res_users_model.read(cr, SUPERUSER_ID, users_no_alias, ['login']): - alias_id = mail_alias.create_unique_alias(cr, SUPERUSER_ID, {'alias_name': user_data['login'], - 'alias_force_id': user_data['id']}, - model_name=self._name) - res_users_model.write(cr, SUPERUSER_ID, user_data['id'], {'alias_id': alias_id}) - _logger.info('Mail alias created for user %s (uid %s)', user_data['login'], user_data['id']) - - # Finally attempt to reinstate the missing constraint - try: - cr.execute('ALTER TABLE res_users ALTER COLUMN alias_id SET NOT NULL') - except Exception: - _logger.warning("Table '%s': unable to set a NOT NULL constraint on column '%s' !\n"\ - "If you want to have it, you should update the records and execute manually:\n"\ - "ALTER TABLE %s ALTER COLUMN %s SET NOT NULL", - self._table, 'alias_id', self._table, 'alias_id') - - self._columns['alias_id'].required = True + self.pool.get('mail.alias').migrate_to_alias(cr, self._name, self._table, super(res_users,self)._auto_init, + self._columns['alias_id'], 'login', alias_force_thread_id='id', context=context) def create(self, cr, uid, data, context=None): # create default alias same as the login From decab66e70d67e197c406f307baa366327ec105b Mon Sep 17 00:00:00 2001 From: Minh Tran Date: Thu, 23 Aug 2012 18:19:53 +0200 Subject: [PATCH 08/24] added hover effect to menu counter bzr revid: mit@openerp.com-20120823161953-h5sc0npkpz5drgq1 --- addons/web/static/src/css/base.css | 7 +++++++ addons/web/static/src/css/base.sass | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 4f34c050f46..ff90d0050ec 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1206,6 +1206,13 @@ margin: 0px; padding: 1px 4px; } +.openerp .oe_secondary_submenu .oe_menu_counter:hover { + cursor: pointer; + border: 1px solid #c81010; + -moz-box-shadow: 0 0 2px #c81010; + -webkit-box-shadow: 0 0 2px #c81010; + box-shadow: 0 0 2px #c81010; +} .openerp .oe_secondary_submenu .oe_active { background: #7c7bad; border-top: 1px solid lightGray; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 4a26ea0d54e..2bcd5ac5be4 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -945,6 +945,10 @@ $sheet-max-width: 860px text-shadow: 0 1px 1px rgba(0,0,0,0.2) margin: 0px padding: 1px 4px + &:hover + cursor: pointer + border: 1px solid #C81010 + @include box-shadow(0 0 2px #C81010) .oe_active background: $link-color border-top: 1px solid lightGray From e28ec55117cfb6813e52caf571b71ba7a7ab92e5 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 24 Aug 2012 12:44:36 +0200 Subject: [PATCH 09/24] [IMP] added oe_semantic_html bzr revid: nicolas.vanhoren@openerp.com-20120824104436-er3w1zdijvcv9j04 --- addons/web/static/src/css/base.css | 21 +++++++++++---------- addons/web/static/src/css/base.sass | 9 +++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 30571da3a2a..47ab720b748 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1,4 +1,4 @@ -@charset "UTF-8"; +@charset "utf-8"; @font-face { font-family: "mnmliconsRegular"; src: url("/web/static/src/font/mnmliconsv21-webfont.eot") format("eot"); @@ -148,15 +148,6 @@ .openerp li { list-style-type: none; } - -.openerp .oe_form_field_html li { - list-style-type: disc; -} - - .openerp .oe_form_field_html h1,h2 { - line-height:26px; -} - .openerp input, .openerp textarea, .openerp select { padding: 2px 4px; border: 1px solid #cccccc; @@ -2734,6 +2725,16 @@ float: right; color: #333333; } +.openerp .oe_semantic_html li { + list-style-type: disc; + display: list-item; +} +.openerp .oe_semantic_html ul { + padding-left: 1em; +} +.openerp .oe_semantic_html p { + color: #4c4c4c !important; +} .kitten-mode-activated { background-image: url(http://placekitten.com/g/1365/769); diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 33b33d01701..9b541bdc625 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -2128,6 +2128,15 @@ $sheet-max-width: 860px float: right color: #333 // }}} + .oe_semantic_html // a style to use normal html + li + list-style-type: disc + display: list-item + ul + padding-left: 1em + p + color: #4C4C4C !important + // Kitten Mode {{{ .kitten-mode-activated background-image: url(http://placekitten.com/g/1365/769) From ee8b4c6c6440d002090d48efc3bc31261d58970b Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 24 Aug 2012 12:47:30 +0200 Subject: [PATCH 10/24] [IMP] web_linkedin: Added server domain and corrected html display bzr revid: nicolas.vanhoren@openerp.com-20120824104730-f7p8lqibovjzo3vz --- addons/web_linkedin/web_linkedin.py | 4 +++- addons/web_linkedin/web_linkedin_view.xml | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/web_linkedin/web_linkedin.py b/addons/web_linkedin/web_linkedin.py index 2a6ba24042e..c398ad17f3b 100644 --- a/addons/web_linkedin/web_linkedin.py +++ b/addons/web_linkedin/web_linkedin.py @@ -43,11 +43,13 @@ class web_linkedin_settings(osv.osv_memory): _inherit = 'res.config.settings' _columns = { 'api_key': fields.char(string="API Key", size=50), + 'server_domain': fields.char(size=100), } def get_default_linkedin(self, cr, uid, fields, context=None): key = self.pool.get("ir.config_parameter").get_param(cr, uid, "web.linkedin.apikey") or "" - return {'api_key': key} + dom = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url') + return {'api_key': key, 'server_domain': dom,} def set_linkedin(self, cr, uid, ids, context=None): key = self.browse(cr, uid, ids[0], context)["api_key"] or "" diff --git a/addons/web_linkedin/web_linkedin_view.xml b/addons/web_linkedin/web_linkedin_view.xml index a3b73ec94dc..d4af6f7916e 100644 --- a/addons/web_linkedin/web_linkedin_view.xml +++ b/addons/web_linkedin/web_linkedin_view.xml @@ -23,7 +23,7 @@ or