From 052c5f8eeb92570db295bedec4162225835f86e0 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Mon, 4 Jun 2012 17:03:50 +0530 Subject: [PATCH 001/175] [FIX] account_asset: change the calculation of field depreciated_value lp bug: https://launchpad.net/bugs/997141 fixed bzr revid: cha@tinyerp.com-20120604113350-sdzv1lr0zcf5l5wr --- addons/account_asset/account_asset.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/account_asset/account_asset.py b/addons/account_asset/account_asset.py index 0799a59a423..362fcce1982 100644 --- a/addons/account_asset/account_asset.py +++ b/addons/account_asset/account_asset.py @@ -141,7 +141,6 @@ class account_asset_asset(osv.osv): old_depreciation_line_ids = depreciation_lin_obj.search(cr, uid, [('asset_id', '=', asset.id), ('move_id', '=', False)]) if old_depreciation_line_ids: depreciation_lin_obj.unlink(cr, uid, old_depreciation_line_ids, context=context) - amount_to_depr = residual_amount = asset.value_residual if asset.prorata: depreciation_date = datetime.strptime(self._get_last_depreciation_date(cr, uid, [asset.id], context)[asset.id], '%Y-%m-%d') @@ -159,13 +158,21 @@ class account_asset_asset(osv.osv): i = x + 1 amount = self._compute_board_amount(cr, uid, asset, i, residual_amount, amount_to_depr, undone_dotation_number, posted_depreciation_line_ids, total_days, depreciation_date, context=context) residual_amount -= amount + + if posted_depreciation_line_ids: + if x == range(len(posted_depreciation_line_ids), undone_dotation_number)[0] : + depreciated_value = depreciation_lin_obj.browse(cr, uid, posted_depreciation_line_ids[0], context=context).amount + else: + depreciated_value = depreciated_value + amount + else: + depreciated_value = (asset.purchase_value - asset.salvage_value) - (residual_amount + amount) vals = { 'amount': amount, 'asset_id': asset.id, 'sequence': i, 'name': str(asset.id) +'/' + str(i), 'remaining_value': residual_amount, - 'depreciated_value': (asset.purchase_value - asset.salvage_value) - (residual_amount + amount), + 'depreciated_value': depreciated_value, 'depreciation_date': depreciation_date.strftime('%Y-%m-%d'), } depreciation_lin_obj.create(cr, uid, vals, context=context) From 63702d6064d6dd457ccd82aa56ac44d375fe001c Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Tue, 14 Aug 2012 14:20:41 +0530 Subject: [PATCH 002/175] [IMP]minor fix to view editor. bzr revid: vme@tinyerp.com-20120814085041-s0lkqzcnyks0ukdn --- addons/web_view_editor/static/src/css/view_editor.css | 4 ++++ addons/web_view_editor/static/src/js/view_editor.js | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/web_view_editor/static/src/css/view_editor.css b/addons/web_view_editor/static/src/css/view_editor.css index e80e15a4c17..2f2b5860cf6 100644 --- a/addons/web_view_editor/static/src/css/view_editor.css +++ b/addons/web_view_editor/static/src/css/view_editor.css @@ -19,3 +19,7 @@ .openerp .oe_view_editor tr:hover { background-color: #ecebf2; } +.openerp .oe_view_editor_field a{ + font-size : 12px; + color : #404040; +} \ No newline at end of file diff --git a/addons/web_view_editor/static/src/js/view_editor.js b/addons/web_view_editor/static/src/js/view_editor.js index cfdd5d6bfea..770d32b2e56 100644 --- a/addons/web_view_editor/static/src/js/view_editor.js +++ b/addons/web_view_editor/static/src/js/view_editor.js @@ -73,8 +73,7 @@ instance.web_view_editor.ViewEditor = instance.web.OldWidget.extend({ $.when(this.action_manager.do_action(action)).then(function() { var viewmanager = self.action_manager.inner_widget, controller = viewmanager.views[viewmanager.active_view].controller; - self.action_manager.appendTo(self.view_edit_dialog.$element); - self.action_manager.renderElement(self.view_edit_dialog); + self.action_manager.$element.appendTo(self.view_edit_dialog.$element); controller.on_loaded.add_last(function(){ $(controller.groups).bind({ 'selected': function(e, ids, records) { From 987e362d7f9f507a00aabbedc24790580aa4b7a8 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Fri, 24 Aug 2012 10:47:06 +0530 Subject: [PATCH 003/175] [IMP] account_asset: revert old changes bzr revid: cha@tinyerp.com-20120824051706-16pn120zdtxfve49 --- addons/account_asset/account_asset.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/addons/account_asset/account_asset.py b/addons/account_asset/account_asset.py index 362fcce1982..c4c1db0dec2 100644 --- a/addons/account_asset/account_asset.py +++ b/addons/account_asset/account_asset.py @@ -141,6 +141,7 @@ class account_asset_asset(osv.osv): old_depreciation_line_ids = depreciation_lin_obj.search(cr, uid, [('asset_id', '=', asset.id), ('move_id', '=', False)]) if old_depreciation_line_ids: depreciation_lin_obj.unlink(cr, uid, old_depreciation_line_ids, context=context) + amount_to_depr = residual_amount = asset.value_residual if asset.prorata: depreciation_date = datetime.strptime(self._get_last_depreciation_date(cr, uid, [asset.id], context)[asset.id], '%Y-%m-%d') @@ -158,21 +159,13 @@ class account_asset_asset(osv.osv): i = x + 1 amount = self._compute_board_amount(cr, uid, asset, i, residual_amount, amount_to_depr, undone_dotation_number, posted_depreciation_line_ids, total_days, depreciation_date, context=context) residual_amount -= amount - - if posted_depreciation_line_ids: - if x == range(len(posted_depreciation_line_ids), undone_dotation_number)[0] : - depreciated_value = depreciation_lin_obj.browse(cr, uid, posted_depreciation_line_ids[0], context=context).amount - else: - depreciated_value = depreciated_value + amount - else: - depreciated_value = (asset.purchase_value - asset.salvage_value) - (residual_amount + amount) vals = { 'amount': amount, 'asset_id': asset.id, 'sequence': i, 'name': str(asset.id) +'/' + str(i), 'remaining_value': residual_amount, - 'depreciated_value': depreciated_value, + 'depreciated_value': (asset.purchase_value - asset.salvage_value) - (residual_amount + amount), 'depreciation_date': depreciation_date.strftime('%Y-%m-%d'), } depreciation_lin_obj.create(cr, uid, vals, context=context) From 87e7926a14aef3841ef401b7cd32ea45b5718642 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Fri, 24 Aug 2012 11:17:47 +0530 Subject: [PATCH 004/175] [IMP] account_asset: fixed depriciation board calculation problem bzr revid: cha@tinyerp.com-20120824054747-vgfv4e3xv7h7ao0r --- addons/account_asset/account_asset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account_asset/account_asset.py b/addons/account_asset/account_asset.py index 2dc95e832e6..bbad438f1db 100644 --- a/addons/account_asset/account_asset.py +++ b/addons/account_asset/account_asset.py @@ -141,7 +141,7 @@ class account_asset_asset(osv.osv): old_depreciation_line_ids = depreciation_lin_obj.search(cr, uid, [('asset_id', '=', asset.id), ('move_id', '=', False)]) if old_depreciation_line_ids: depreciation_lin_obj.unlink(cr, uid, old_depreciation_line_ids, context=context) - + amount_to_depr = residual_amount = asset.value_residual if asset.prorata: depreciation_date = datetime.strptime(self._get_last_depreciation_date(cr, uid, [asset.id], context)[asset.id], '%Y-%m-%d') @@ -189,7 +189,7 @@ class account_asset_asset(osv.osv): def _amount_residual(self, cr, uid, ids, name, args, context=None): cr.execute("""SELECT - l.asset_id as id, round(SUM(abs(l.debit-l.credit))) AS amount + l.asset_id as id, SUM(abs(l.debit-l.credit)) AS amount FROM account_move_line l WHERE From 151552cfdfe4af85ac2e6921a63738bdc5518a8b Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Tue, 28 Aug 2012 14:52:32 +0530 Subject: [PATCH 005/175] [IMP] account_asset: fix the issue of residual value bzr revid: cha@tinyerp.com-20120828092232-7a8t9ntuto0eubhb --- addons/account_asset/account_asset.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/account_asset/account_asset.py b/addons/account_asset/account_asset.py index bbad438f1db..3ea38ef9aa2 100644 --- a/addons/account_asset/account_asset.py +++ b/addons/account_asset/account_asset.py @@ -134,6 +134,7 @@ class account_asset_asset(osv.osv): def compute_depreciation_board(self, cr, uid, ids, context=None): depreciation_lin_obj = self.pool.get('account.asset.depreciation.line') + currency_obj = self.pool.get('res.currency') for asset in self.browse(cr, uid, ids, context=context): if asset.value_residual == 0.0: continue @@ -158,6 +159,9 @@ class account_asset_asset(osv.osv): for x in range(len(posted_depreciation_line_ids), undone_dotation_number): i = x + 1 amount = self._compute_board_amount(cr, uid, asset, i, residual_amount, amount_to_depr, undone_dotation_number, posted_depreciation_line_ids, total_days, depreciation_date, context=context) + company_currency = asset.company_id.currency_id.id + current_currency = asset.currency_id.id + amount = currency_obj.compute(cr, uid, current_currency, company_currency, amount, context=context) residual_amount -= amount vals = { 'amount': amount, @@ -347,8 +351,8 @@ class account_asset_depreciation_line(osv.osv): 'sequence': fields.integer('Sequence', required=True), 'asset_id': fields.many2one('account.asset.asset', 'Asset', required=True), 'parent_state': fields.related('asset_id', 'state', type='char', string='State of Asset'), - 'amount': fields.float('Depreciation Amount', required=True), - 'remaining_value': fields.float('Amount to Depreciate', required=True), + 'amount': fields.float('Depreciation Amount', digits_compute=dp.get_precision('Account'), required=True), + 'remaining_value': fields.float('Amount to Depreciate', digits_compute=dp.get_precision('Account'),required=True), 'depreciated_value': fields.float('Amount Already Depreciated', required=True), 'depreciation_date': fields.char('Depreciation Date', size=64, select=1), 'move_id': fields.many2one('account.move', 'Depreciation Entry'), From cfbb548717f23eb09e96f685085c412a6bd3b498 Mon Sep 17 00:00:00 2001 From: "Nimesh (Open ERP)" Date: Wed, 3 Oct 2012 15:57:18 +0530 Subject: [PATCH 006/175] [ADD] add suptype in task of the related project. bzr revid: nco@tinyerp.com-20121003102718-vycgkv7y4odup01q --- addons/project/project.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/addons/project/project.py b/addons/project/project.py index 6b02a018293..5d0a665deea 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1097,7 +1097,16 @@ class task(base_stage, osv.osv): def create(self, cr, uid, vals, context=None): task_id = super(task, self).create(cr, uid, vals, context=context) task_record = self.browse(cr, uid, task_id, context=context) + project_obj = self.pool.get("project.project") + subtype_obj = self.pool.get('mail.message.subtype') if task_record.project_id: + poject_id = self.browse(cr, uid, task_id, context=context).project_id.id + pro_subtype = project_obj.browse(cr, uid, poject_id, context=context).message_subtype_data + for key in pro_subtype: + subtype_ids = subtype_obj.search(cr, uid, [('res_model', '=', self._name), ('name', '=', key)], context=context) + if subtype_ids: + for subtype_id in subtype_ids: + subtype_obj.write(cr,uid, subtype_id, {'default': pro_subtype[key]['default']},context=context) project_follower_ids = [follower.id for follower in task_record.project_id.message_follower_ids] self.message_subscribe(cr, uid, [task_id], project_follower_ids, context=context) @@ -1110,9 +1119,17 @@ class task(base_stage, osv.osv): def write(self, cr, uid, ids, vals, context=None): if isinstance(ids, (int, long)): ids = [ids] + project_obj = self.pool.get("project.project") + subtype_obj = self.pool.get('mail.message.subtype') if vals.get('project_id'): project_id = self.pool.get('project.project').browse(cr, uid, vals.get('project_id'), context=context) vals['message_follower_ids'] = [(4, follower.id) for follower in project_id.message_follower_ids] + pro_subtype = project_obj.browse(cr, uid, project_id.id, context=context).message_subtype_data + for key in pro_subtype: + subtype_ids = subtype_obj.search(cr, uid, [('res_model', '=', self._name), ('name', '=', key)], context=context) + if subtype_ids: + for subtype_id in subtype_ids: + subtype_obj.write(cr,uid, subtype_id, {'default': pro_subtype[key]['default']},context=context) if vals and not 'kanban_state' in vals and 'stage_id' in vals: new_stage = vals.get('stage_id') vals_reset_kstate = dict(vals, kanban_state='normal') From 74cfb3db106da08342e2ce2449311659d0623ee7 Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Wed, 3 Oct 2012 23:34:17 +0530 Subject: [PATCH 007/175] [IMP]: Improve subtype state mapping in project bzr revid: atp@tinyerp.com-20121003180417-wi7jy1veyj5fxygl --- addons/project/project.py | 3 ++- addons/project_issue/project_issue.py | 25 ++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 587da5623e4..22d24660010 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1099,6 +1099,7 @@ class task(base_stage, osv.osv): task_record = self.browse(cr, uid, task_id, context=context) project_obj = self.pool.get("project.project") subtype_obj = self.pool.get('mail.message.subtype') + subtype_ids = [] if task_record.project_id: project_subtype = task_record.project_id.message_subtype_data for key in project_subtype: @@ -1106,7 +1107,7 @@ class task(base_stage, osv.osv): if subtype_ids: subtype_obj.write(cr,uid, subtype_ids, {'default': project_subtype[key]['default']},context=context) project_follower_ids = [follower.id for follower in task_record.project_id.message_follower_ids] - self.message_subscribe(cr, uid, [task_id], project_follower_ids, + self.message_subscribe(cr, uid, [task_id], project_follower_ids, subtype_ids = subtype_ids, context=context) self._store_history(cr, uid, [task_id], context=context) self.create_send_note(cr, uid, [task_id], context=context) diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index c3d5f647d8d..2c8d5f8c529 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -363,14 +363,18 @@ class project_issue(base_stage, osv.osv): #Update last action date every time the user change the stage, the state or send a new email logged_fields = ['stage_id', 'state', 'message_ids'] subtype_obj = self.pool.get('mail.message.subtype') + name = False if any([field in vals for field in logged_fields]): vals['date_action_last'] = time.strftime('%Y-%m-%d %H:%M:%S') if vals.get('project_id'): project_id = self.pool.get('project.project').browse(cr, uid, vals.get('project_id'), context=context) for key in project_id.message_subtype_data: - subtype_ids = subtype_obj.search(cr, uid, [('res_model', '=', self._name), ('name', '=', key)], context=context) - if subtype_ids: - subtype_obj.write(cr,uid, subtype_ids, {'default': project_id.message_subtype_data[key]['default']},context=context) + if key == 'New Task' and project_id.message_subtype_data[key]['default'] == True: + name = 'created' + if key == 'Task Closed' and project_id.message_subtype_data[key]['default'] == True: + name = 'closed' + subtype_ids = subtype_obj.search(cr, uid, [('res_model', '=', self._name), ('name', 'ilike', name)], context=context) + subtype_obj.write(cr,uid, subtype_ids, {'default': project_id.message_subtype_data[key]['default']},context=context) vals['message_follower_ids'] = [(4, follower.id) for follower in project_id.message_follower_ids] return super(project_issue, self).write(cr, uid, ids, vals, context) @@ -392,14 +396,17 @@ class project_issue(base_stage, osv.osv): subtype_obj = self.pool.get('mail.message.subtype') obj_id = super(project_issue, self).create(cr, uid, vals, context=context) project_id = self.browse(cr, uid, obj_id, context=context).project_id - project_subtype = project_id.message_subtype_data - for key in project_subtype: - subtype_ids = subtype_obj.search(cr, uid, [('res_model', '=', self._name), ('name', 'ilike', key)], context=context) - if subtype_ids: - subtype_obj.write(cr,uid, subtype_ids, {'default': project_subtype[key]['default']},context=context) + name = False if project_id: + for key in project_id.message_subtype_data: + if key == 'New Task' and project_id.message_subtype_data[key]['default'] == True: + name = 'created' + if key == 'Task Closed' and project_id.message_subtype_data[key]['default'] == True: + name = 'closed' + subtype_ids = subtype_obj.search(cr, uid, [('res_model', '=', self._name), ('name', 'ilike', name)], context=context) + subtype_obj.write(cr,uid, subtype_ids, {'default': project_id.message_subtype_data[key]['default']},context=context) followers = [follower.id for follower in project_id.message_follower_ids] - self.message_subscribe(cr, uid, [obj_id], followers, context=context) + self.message_subscribe(cr, uid, [obj_id], followers, subtype_ids= subtype_ids, context=context) self.create_send_note(cr, uid, [obj_id], context=context) return obj_id From 20d9f75193f197ea8ff2a5c1d16cfaac21a85891 Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Thu, 11 Oct 2012 12:31:28 +0530 Subject: [PATCH 008/175] [FIX] sale_stock : Traceback when paying invoice by percentage in SO, after installing sale_stock. bzr revid: mdi@tinyerp.com-20121011070128-z81rzss16d2no59i --- addons/sale_stock/sale_stock.py | 84 ++++++++++++++++++++++----------- 1 file changed, 57 insertions(+), 27 deletions(-) diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index ce6894318c4..e17ddba146b 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -635,34 +635,64 @@ class sale_order_line(osv.osv): class sale_advance_payment_inv(osv.osv_memory): _inherit = "sale.advance.payment.inv" - def _create_invoices(self, cr, uid, inv_values, sale_id, context=None): - result = super(sale_advance_payment_inv, self)._create_invoices(cr, uid, inv_values, sale_id, context=context) + def create_invoices(self, cr, uid, ids, context=None): + """ create invoices for the active sale orders """ sale_obj = self.pool.get('sale.order') - sale_line_obj = self.pool.get('sale.order.line') + act_window = self.pool.get('ir.actions.act_window') wizard = self.browse(cr, uid, ids[0], context) - sale = sale_obj.browse(cr, uid, sale_id, context=context) - if sale.order_policy == 'postpaid': - raise osv.except_osv( - _('Error!'), - _("You cannot make an advance on a sales order \ - that is defined as 'Automatic Invoice after delivery'.")) + sale_ids = context.get('active_ids', []) + if wizard.advance_payment_method == 'all': + # create the final invoices of the active sale orders + res = sale_obj.manual_invoice(cr, uid, sale_ids, context) + if context.get('open_invoices', False): + return res + return {'type': 'ir.actions.act_window_close'} - # If invoice on picking: add the cost on the SO - # If not, the advance will be deduced when generating the final invoice - line_name = inv_values.get('invoice_line') and inv_values.get('invoice_line')[2].get('name') or '' - line_tax = inv_values.get('invoice_line') and inv_values.get('invoice_line')[2].get('invoice_line_tax_id') or False - if sale.order_policy == 'picking': - vals = { - 'order_id': sale.id, - 'name': line_name, - 'price_unit': -inv_amount, - 'product_uom_qty': wizard.qtty or 1.0, - 'product_uos_qty': wizard.qtty or 1.0, - 'product_uos': res.get('uos_id', False), - 'product_uom': res.get('uom_id', False), - 'product_id': wizard.product_id.id or False, - 'discount': False, - 'tax_id': line_tax, + if wizard.advance_payment_method == 'lines': + # open the list view of sale order lines to invoice + res = act_window.for_xml_id(cr, uid, 'sale', 'action_order_line_tree2', context) + res['context'] = { + 'search_default_uninvoiced': 1, + 'search_default_order_id': sale_ids and sale_ids[0] or False, } - sale_line_obj.create(cr, uid, vals, context=context) - return result + return res + assert wizard.advance_payment_method in ('fixed', 'percentage') + + inv_ids = [] + for sale_id, inv_values in self._prepare_advance_invoice_vals(cr, uid, ids, context=context): + + sale_obj = self.pool.get('sale.order') + sale_line_obj = self.pool.get('sale.order.line') + sale = sale_obj.browse(cr, uid, sale_id, context=context) + if sale.order_policy == 'postpaid': + raise osv.except_osv( + _('Error!'), + _("You cannot make an advance on a sales order \ + that is defined as 'Automatic Invoice after delivery'.")) + + # If invoice on picking: add the cost on the SO + # If not, the advance will be deduced when generating the final invoice + line_name = inv_values.get('invoice_line') and inv_values.get('invoice_line')[0][2].get('name') or '' + line_tax = inv_values.get('invoice_line') and inv_values.get('invoice_line')[0][2].get('invoice_line_tax_id') or False + if sale.order_policy == 'picking': + vals = { + 'order_id': sale.id, + 'name': line_name, + 'price_unit': -inv_amount, + 'product_uom_qty': wizard.qtty or 1.0, + 'product_uos_qty': wizard.qtty or 1.0, + 'product_uos': res.get('uos_id', False), + 'product_uom': res.get('uom_id', False), + 'product_id': wizard.product_id.id or False, + 'discount': False, + 'tax_id': line_tax, + } + sale_line_obj.create(cr, uid, vals, context=context) + + inv_ids.append(self._create_invoices(cr, uid, inv_values, sale_id, context=context)) + + if context.get('open_invoices', False): + return self.open_invoices( cr, uid, ids, inv_ids, context=context) + return {'type': 'ir.actions.act_window_close'} + res = super(sale_advance_payment_inv, self).create_invoices(self, cr, uid, ids, context=context) + return res \ No newline at end of file From 607cbf63cf91f94d8796af4d05f63c26ca10ccb0 Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Thu, 11 Oct 2012 15:06:46 +0530 Subject: [PATCH 009/175] [IMP]survey : Improve warning message, set align of Professional Development Objectives separator and fix the trace back of create New Survey -> edit survey or -> test survey bzr revid: mma@tinyerp.com-20121011093646-b8lg30yc7d4xzvdo --- addons/survey/survey.py | 38 ++++++++++++++++++++++----- addons/survey/survey_view.xml | 4 +-- addons/survey/wizard/survey_answer.py | 1 + 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/addons/survey/survey.py b/addons/survey/survey.py index d01140092d4..57ff9c84559 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -163,10 +163,14 @@ class survey(osv.osv): 'context': context } def test_survey(self, cr, uid, ids, context=None): - sur_obj = self.read(cr, uid, ids,['title'], context=context) + sur_obj = self.read(cr, uid, ids,['title','page_ids'], context=context) for sur in sur_obj: name = sur['title'] - context.update({'active':True,'survey_id': ids[0]}) + pages = sur['page_ids'] + if not pages: + raise osv.except_osv(_('Warning!'), _('This survey has no question defined. Please define the questions and answers first.')) + else: + context.update({'active':False,'survey_id': ids[0]}) return { 'view_type': 'form', 'view_mode': 'form', @@ -176,6 +180,26 @@ class survey(osv.osv): 'name': name, 'context': context } + + def edit_survey(self, cr, uid, ids, context=None): + sur_obj = self.read(cr, uid, ids,['title','page_ids'], context=context) + for sur in sur_obj: + name = sur['title'] + pages = sur['page_ids'] + if not pages: + raise osv.except_osv(_('Warning!'), _('This survey has no question defined. Please define the questions and answers first.')) + else: + context.update({'survey_id': ids[0]}) + return { + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'survey.question.wiz', + 'type': 'ir.actions.act_window', + 'target': 'new', + 'name': name, + 'context': context + } + survey() class survey_history(osv.osv): @@ -383,7 +407,7 @@ class survey_question(osv.osv): def write(self, cr, uid, ids, vals, context=None): questions = self.read(cr,uid, ids, ['answer_choice_ids', 'type', 'required_type',\ - 'req_ans', 'minimum_req_ans', 'maximum_req_ans', 'column_heading_ids']) + 'req_ans', 'minimum_req_ans', 'maximum_req_ans', 'column_heading_ids', 'page_id', 'question']) for question in questions: col_len = len(question['column_heading_ids']) if vals.has_key('column_heading_ids'): @@ -401,7 +425,7 @@ class survey_question(osv.osv): if que_type in ['matrix_of_choices_only_one_ans', 'matrix_of_choices_only_multi_ans',\ 'matrix_of_drop_down_menus', 'rating_scale']: if not col_len: - raise osv.except_osv(_('Warning!'),_("You must enter one or more column headings.")) + raise osv.except_osv(_('Warning!'),_("You must enter one or more column headings for question %s of page %s.") % (question['question'], question['page_id'][1])) ans_len = len(question['answer_choice_ids']) if vals.has_key('answer_choice_ids'): @@ -413,7 +437,7 @@ class survey_question(osv.osv): if que_type not in ['descriptive_text', 'single_textbox', 'comment','table']: if not ans_len: - raise osv.except_osv(_('Warning!'),_("You must enter one or more Answers.")) + raise osv.except_osv(_('Warning!'),_("You must enter one or more Answers for question %s of page %s.") % (question['question'], question['page_id'][1])) req_type = "" if vals.has_key('required_type'): @@ -484,11 +508,11 @@ class survey_question(osv.osv): maximum_ans = 0 if vals.has_key('answer_choice_ids') and not len(vals['answer_choice_ids']): if vals.has_key('type') and vals['type'] not in ['descriptive_text', 'single_textbox', 'comment','table']: - raise osv.except_osv(_('Warning!'),_("You must enter one or more answers.")) + raise osv.except_osv(_('Warning!'),_("You must enter one or more answers for question %s.") % (vals['question'])) if vals.has_key('column_heading_ids') and not len(vals['column_heading_ids']): if vals.has_key('type') and vals['type'] in ['matrix_of_choices_only_one_ans', 'matrix_of_choices_only_multi_ans', 'matrix_of_drop_down_menus', 'rating_scale']: - raise osv.except_osv(_('Warning!'),_("You must enter one or more column heading.")) + raise osv.except_osv(_('Warning!'),_("You must enter one or more column heading for question %s.")% (vals['question'])) if vals['type'] in ['multiple_choice_multiple_ans','matrix_of_choices_only_one_ans', 'matrix_of_choices_only_multi_ans', 'matrix_of_drop_down_menus', 'rating_scale','multiple_textboxes','numerical_textboxes','date','date_and_time']: if vals.has_key('is_require_answer') and vals.has_key('required_type') and vals['required_type'] in ['at least', 'at most', 'exactly']: diff --git a/addons/survey/survey_view.xml b/addons/survey/survey_view.xml index 0247a205700..ce0e4bfdd91 100644 --- a/addons/survey/survey_view.xml +++ b/addons/survey/survey_view.xml @@ -31,8 +31,8 @@ From fd2deaa1ce99ef63fa343301456c011e160b41ea Mon Sep 17 00:00:00 2001 From: "Purnendu Singh (OpenERP)" Date: Mon, 22 Oct 2012 17:52:03 +0530 Subject: [PATCH 072/175] [IMP] sale_stock: improve the code bzr revid: psi@tinyerp.com-20121022122203-4hv479pf3bbq1kwz --- addons/sale_stock/sale_stock.py | 58 ++++++++++++++++----------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index 6d143245177..dc3f1bbfeaf 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -635,36 +635,34 @@ class sale_order_line(osv.osv): class sale_advance_payment_inv(osv.osv_memory): _inherit = "sale.advance.payment.inv" - def create_invoices(self, cr, uid, ids, context=None): - """ create invoices for the active sale orders """ + def _create_invoices(self, cr, uid, inv_values, sale_id, context=None): + result = super(sale_advance_payment_inv, self)._create_invoices(cr, uid, inv_values, sale_id, context=context) sale_obj = self.pool.get('sale.order') sale_line_obj = self.pool.get('sale.order.line') - wizard = self.browse(cr, uid, ids[0], context) + wizard = self.browse(cr, uid, [result], context) + sale = sale_obj.browse(cr, uid, sale_id, context=context) + if sale.order_policy == 'postpaid': + raise osv.except_osv( + _('Error!'), + _("You cannot make an advance on a sales order \ + that is defined as 'Automatic Invoice after delivery'.")) - for sale_id, inv_values in self._prepare_advance_invoice_vals(cr, uid, ids, context=context): - sale = sale_obj.browse(cr, uid, sale_id, context=context) - if sale.order_policy == 'postpaid': - raise osv.except_osv( - _('Error!'), - _("You cannot make an advance on a sales order \ - that is defined as 'Automatic Invoice after delivery'.")) - - # If invoice on picking: add the cost on the SO - # If not, the advance will be deduced when generating the final invoice - line_name = inv_values.get('invoice_line') and inv_values.get('invoice_line')[0][2].get('name') or '' - line_tax = inv_values.get('invoice_line') and inv_values.get('invoice_line')[0][2].get('invoice_line_tax_id') or False - if sale.order_policy == 'picking': - vals = { - 'order_id': sale.id, - 'name': line_name, - 'price_unit': -inv_amount, - 'product_uom_qty': wizard.qtty or 1.0, - 'product_uos_qty': wizard.qtty or 1.0, - 'product_uos': res.get('uos_id', False), - 'product_uom': res.get('uom_id', False), - 'product_id': wizard.product_id.id or False, - 'discount': False, - 'tax_id': line_tax, - } - sale_line_obj.create(cr, uid, vals, context=context) - return super(sale_advance_payment_inv, self).create_invoices(cr, uid, ids, context=context) + # If invoice on picking: add the cost on the SO + # If not, the advance will be deduced when generating the final invoice + line_name = inv_values.get('invoice_line') and inv_values.get('invoice_line')[0][2].get('name') or '' + line_tax = inv_values.get('invoice_line') and inv_values.get('invoice_line')[0][2].get('invoice_line_tax_id') or False + if sale.order_policy == 'picking': + vals = { + 'order_id': sale.id, + 'name': line_name, + 'price_unit': -inv_amount, + 'product_uom_qty': wizard.qtty or 1.0, + 'product_uos_qty': wizard.qtty or 1.0, + 'product_uos': res.get('uos_id', False), + 'product_uom': res.get('uom_id', False), + 'product_id': wizard.product_id.id or False, + 'discount': False, + 'tax_id': line_tax, + } + sale_line_obj.create(cr, uid, vals, context=context) + return result From 4d9907ada9b65d52eb038efc0629e23260298b58 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Mon, 22 Oct 2012 19:03:54 +0530 Subject: [PATCH 073/175] [IMP] remove graph view mode in bank statement & coda statement bzr revid: fka@tinyerp.com-20121022133354-03g0z7se5tv4ngb1 --- .../account_bank_statement_view.xml | 2 +- addons/l10n_be_coda/l10n_be_coda_view.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account_bank_statement_extensions/account_bank_statement_view.xml b/addons/account_bank_statement_extensions/account_bank_statement_view.xml index 9164c00373f..3d5560856a3 100644 --- a/addons/account_bank_statement_extensions/account_bank_statement_view.xml +++ b/addons/account_bank_statement_extensions/account_bank_statement_view.xml @@ -148,7 +148,7 @@ Bank Statement Lines account.bank.statement.line form - tree,graph,form + tree,form {'block_statement_line_delete' : 1} diff --git a/addons/l10n_be_coda/l10n_be_coda_view.xml b/addons/l10n_be_coda/l10n_be_coda_view.xml index 21db77466a0..d5067e7951a 100644 --- a/addons/l10n_be_coda/l10n_be_coda_view.xml +++ b/addons/l10n_be_coda/l10n_be_coda_view.xml @@ -473,7 +473,7 @@ CODA Statement Lines coda.bank.statement.line form - tree,graph,form + tree,form {'block_statement_line_delete' : 1} From 6239433a002dc17d72e2e9c9d0eae61507825027 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Tue, 23 Oct 2012 11:04:12 +0530 Subject: [PATCH 074/175] [IMP]improve code bzr revid: sgo@tinyerp.com-20121023053412-gpoxqj3jp55m65wu --- .../product_visible_discount/product_visible_discount.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/product_visible_discount/product_visible_discount.py b/addons/product_visible_discount/product_visible_discount.py index 48e3c4a8283..008c1f313a6 100644 --- a/addons/product_visible_discount/product_visible_discount.py +++ b/addons/product_visible_discount/product_visible_discount.py @@ -111,9 +111,11 @@ class account_invoice_line(osv.osv): if res_dict.get('item_id',False) and res_dict['item_id'].get(pricelist,False): item = res_dict['item_id'].get(pricelist,False) - item_base = item_obj.read(cr, uid, [item], ['base'])[0]['base'] - if item_base > 0: - field_name = price_type_obj.browse(cr, uid, item_base).field + item_read = item_obj.read(cr, uid, [item], ['base']) + if item_read: + item_base = item_read[0]['base'] + if item_base > 0: + field_name = price_type_obj.browse(cr, uid, item_base).field product = product_obj.browse(cr, uid, product_id, context) product_read = product_obj.read(cr, uid, product_id, [field_name], context=context) From 7f64cbd875e22d8feb1555cf886c00bb3163c072 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Tue, 23 Oct 2012 11:52:30 +0530 Subject: [PATCH 075/175] [IMP] remove date_start_date function field bzr revid: fka@tinyerp.com-20121023062230-l6941b0lt7qx4wzu --- addons/mrp_operations/mrp_operations.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/addons/mrp_operations/mrp_operations.py b/addons/mrp_operations/mrp_operations.py index 9f6671c3b2b..ffe0305d5f1 100644 --- a/addons/mrp_operations/mrp_operations.py +++ b/addons/mrp_operations/mrp_operations.py @@ -50,17 +50,6 @@ class stock_move(osv.osv): stock_move() class mrp_production_workcenter_line(osv.osv): - def _get_date_date(self, cr, uid, ids, field_name, arg, context=None): - """ Finds starting date. - @return: Dictionary of values. - """ - res={} - for op in self.browse(cr, uid, ids, context=context): - if op.date_start: - res[op.id] = op.date_start[:10] - else: - res[op.id]=False - return res def _get_date_end(self, cr, uid, ids, field_name, arg, context=None): """ Finds ending date. @@ -92,7 +81,6 @@ class mrp_production_workcenter_line(osv.osv): "* When work order is in running mode, during that time if user wants to stop or to make changes in order then can set in 'Pending' state.\n" \ "* When the user cancels the work order it will be set in 'Canceled' state.\n" \ "* When order is completely processed that time it is set in 'Finished' state."), - 'date_start_date': fields.function(_get_date_date, string='Start Date', type='date'), 'date_planned': fields.datetime('Scheduled Date', select=True), 'date_planned_end': fields.function(_get_date_end, string='End Date', type='datetime'), 'date_start': fields.datetime('Start Date'), From 1435e6faeb1fea4d5d973d5d06f4b78ec2622f0b Mon Sep 17 00:00:00 2001 From: Hardik Date: Tue, 23 Oct 2012 13:01:50 +0530 Subject: [PATCH 076/175] [IMP]Diagram view pager is working and display in header bzr revid: hsa@tinyerp.com-20121023073150-ozao4l0wca96cgmp --- addons/web_diagram/static/src/js/diagram.js | 75 ++++++++++++------- .../static/src/xml/base_diagram.xml | 13 ++-- 2 files changed, 55 insertions(+), 33 deletions(-) diff --git a/addons/web_diagram/static/src/js/diagram.js b/addons/web_diagram/static/src/js/diagram.js index d5a6e78f862..a85dff23032 100644 --- a/addons/web_diagram/static/src/js/diagram.js +++ b/addons/web_diagram/static/src/js/diagram.js @@ -22,6 +22,7 @@ instance.web.DiagramView = instance.web.View.extend({ this.context = {}; this.ids = this.dataset.ids; this.on('view_loaded', self, self.load_diagram); + this.on('pager_action_executed', self, self.pager_action_trigger); }, start: function() { var self = this; @@ -59,12 +60,7 @@ instance.web.DiagramView = instance.web.View.extend({ self.$el.find('.oe_diagram_header').append(html_label); }) - this.$el.find('div.oe_diagram_pager button[data-pager-action]').click(function() { - var action = $(this).data('pager-action'); - self.execute_pager_action(action); - }); - - this.do_update_pager(); + this.init_pager(); // New Node,Edge this.$el.find('#new_node.oe_diagram_button_new').click(function(){self.add_node();}); @@ -366,36 +362,61 @@ instance.web.DiagramView = instance.web.View.extend({ form_controller.fields[self.connectors.attrs.destination].dirty = true; }); }, - - execute_pager_action: function(action) { - switch (action) { - case 'first': - this.dataset.index = 0; - break; - case 'previous': - this.dataset.previous(); - break; - case 'next': - this.dataset.next(); - break; - case 'last': - this.dataset.index = this.dataset.ids.length - 1; - break; + do_hide: function () { + if (this.$pager) { + this.$pager.hide(); } + this._super(); + }, + init_pager: function() { + var self = this; + if (this.$pager) + this.$pager.remove(); + + this.$pager = $(QWeb.render("DiagramView.pager", {'widget':self})).hide(); + if (this.options.$pager) { + this.$pager.appendTo(this.options.$pager); + } else { + this.$el.find('.oe_diagram_pager').replaceWith(this.$pager); + } + this.$pager.on('click','a[data-pager-action]',function() { + var action = $(this).data('pager-action'); + self.execute_pager_action(action); + }); + this.do_update_pager(); + }, + pager_action_trigger: function(){ var loaded = this.dataset.read_index(_.keys(this.fields_view.fields)) .pipe(this.on_diagram_loaded); this.do_update_pager(); return loaded; }, + execute_pager_action: function(action) { + switch (action) { + case 'first': + this.dataset.index = 0; + break; + case 'previous': + this.dataset.previous(); + break; + case 'next': + this.dataset.next(); + break; + case 'last': + this.dataset.index = this.dataset.ids.length - 1; + break; + } + this.trigger('pager_action_executed'); + + }, do_update_pager: function(hide_index) { - var $pager = this.$el.find('div.oe_diagram_pager'); - var index = hide_index ? '-' : this.dataset.index + 1; - if(!this.dataset.count) { - this.dataset.count = this.dataset.ids.length; + this.$pager.toggle(this.dataset.ids.length > 1); + if (hide_index) { + $(".oe_diagram_pager_state", this.$pager).html(""); + } else { + $(".oe_diagram_pager_state", this.$pager).html(_.str.sprintf(_t("%d / %d"), this.dataset.index + 1, this.dataset.ids.length)); } - $pager.find('span.oe_pager_index').html(index); - $pager.find('span.oe_pager_count').html(this.dataset.count); }, do_show: function() { diff --git a/addons/web_diagram/static/src/xml/base_diagram.xml b/addons/web_diagram/static/src/xml/base_diagram.xml index 388092b3d23..54b06aafb27 100644 --- a/addons/web_diagram/static/src/xml/base_diagram.xml +++ b/addons/web_diagram/static/src/xml/base_diagram.xml @@ -1,18 +1,19 @@