From 46d2c5a06c07671e4c0c10c004080ca1bb93a503 Mon Sep 17 00:00:00 2001 From: luc-demeyer Date: Tue, 28 Apr 2015 12:28:37 +0200 Subject: [PATCH] update 80 account_move_line_search_extension --- account_move_line_search_extension/README.rst | 24 +++++++++++ .../__init__.py | 1 + .../__openerp__.py | 2 +- account_move_line_search_extension/account.py | 6 +-- .../ir_actions.py | 2 - .../res_partner.py | 41 +++++++++++++++++++ .../js/account_move_line_search_extension.js | 34 +++++++-------- 7 files changed, 83 insertions(+), 27 deletions(-) create mode 100644 account_move_line_search_extension/res_partner.py diff --git a/account_move_line_search_extension/README.rst b/account_move_line_search_extension/README.rst index 1a3a2ee9c..de57bebfd 100644 --- a/account_move_line_search_extension/README.rst +++ b/account_move_line_search_extension/README.rst @@ -1,3 +1,6 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License + Journal Items Search Extension ============================== @@ -13,3 +16,24 @@ The drill down is facilitated further by opening the Form View when clicking on the sought-after entry. This allows an intuitive click-through to the related accounting documents such as the originating Bank Statement, Invoice, Asset, ... + +Credits +======= + +Author +------ +* Luc De Meyer, Noviat + +Maintainer +---------- +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/account_move_line_search_extension/__init__.py b/account_move_line_search_extension/__init__.py index d8798c3a5..edb26d42a 100644 --- a/account_move_line_search_extension/__init__.py +++ b/account_move_line_search_extension/__init__.py @@ -21,4 +21,5 @@ ############################################################################## from . import account +from . import res_partner from . import ir_actions diff --git a/account_move_line_search_extension/__openerp__.py b/account_move_line_search_extension/__openerp__.py index e09f0896b..89de8a22f 100644 --- a/account_move_line_search_extension/__openerp__.py +++ b/account_move_line_search_extension/__openerp__.py @@ -22,7 +22,7 @@ { 'name': 'Journal Items Search Extension', - 'version': '0.4', + 'version': '0.5', 'license': 'AGPL-3', 'author': 'Noviat', 'category': 'Accounting & Finance', diff --git a/account_move_line_search_extension/account.py b/account_move_line_search_extension/account.py index 58a638d72..a21db3b7e 100644 --- a/account_move_line_search_extension/account.py +++ b/account_move_line_search_extension/account.py @@ -20,13 +20,11 @@ # ############################################################################## -from openerp.osv import orm +from openerp import models from lxml import etree -import logging -_logger = logging.getLogger(__name__) -class account_move_line(orm.Model): +class account_move_line(models.Model): _inherit = 'account.move.line' def fields_view_get(self, cr, uid, view_id=None, view_type='form', diff --git a/account_move_line_search_extension/ir_actions.py b/account_move_line_search_extension/ir_actions.py index 7daa639d0..df2e04778 100644 --- a/account_move_line_search_extension/ir_actions.py +++ b/account_move_line_search_extension/ir_actions.py @@ -21,8 +21,6 @@ ############################################################################## from openerp import models -import logging -_logger = logging.getLogger(__name__) class ir_actions_act_window(models.Model): diff --git a/account_move_line_search_extension/res_partner.py b/account_move_line_search_extension/res_partner.py new file mode 100644 index 000000000..1746d2a4d --- /dev/null +++ b/account_move_line_search_extension/res_partner.py @@ -0,0 +1,41 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# +# Copyright (c) 2015 Noviat nv/sa (www.noviat.com). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models + + +class res_partner(models.Model): + _inherit = 'res.partner' + + def search(self, cr, uid, args, + offset=0, limit=None, order=None, context=None, count=False): + if context and 'account_move_line_search_extension' in context: + args.extend( + ['|', + ('parent_id', '=', False), + ('is_company', '=', True), + '|', + ('active', '=', False), + ('active', '=', True)]) + return super(res_partner, self).search( + cr, uid, args, offset=offset, limit=limit, order=order, + context=context, count=count) diff --git a/account_move_line_search_extension/static/src/js/account_move_line_search_extension.js b/account_move_line_search_extension/static/src/js/account_move_line_search_extension.js index 1e450c4c0..effa8b0ec 100644 --- a/account_move_line_search_extension/static/src/js/account_move_line_search_extension.js +++ b/account_move_line_search_extension/static/src/js/account_move_line_search_extension.js @@ -23,7 +23,12 @@ openerp.account_move_line_search_extension = function (instance) { var tmp = this._super.apply(this, arguments); var self = this; this.$el.parent().prepend(QWeb.render('AccountMoveLineSearchExtension', self.groups_dict)); + self.set_change_events(); + return tmp; + }, + set_change_events: function() { + var self = this; this.$el.parent().find('.oe_account_select_account').change(function() { self.current_account = this.value === '' ? null : this.value; self.do_search(self.last_domain, self.last_context, self.last_group_by); @@ -38,28 +43,12 @@ openerp.account_move_line_search_extension = function (instance) { }); this.$el.parent().find('.oe_account_select_journal').change(function() { self.current_journal = this.value === '' ? null : parseInt(this.value); - //console.log('start, oasj, self.current_journal=', self.current_journal, 'self.last_domain=', self.last_domain, 'self.last_context=', self.last_context, 'self.last_group_by=', self.last_group_by); self.do_search(self.last_domain, self.last_context, self.last_group_by); }); this.$el.parent().find('.oe_account_select_period').change(function() { self.current_period = this.value === '' ? null : this.value; self.do_search(self.last_domain, self.last_context, self.last_group_by); }); - this.on('edit:after', this, function () { - self.$el.parent().find('.oe_account_select_account').attr('disabled', 'disabled'); - self.$el.parent().find('.oe_account_select_analytic_account').attr('disabled', 'disabled'); - self.$el.parent().find('.oe_account_select_partner').attr('disabled', 'disabled'); - self.$el.parent().find('.oe_account_select_journal').attr('disabled', 'disabled'); - self.$el.parent().find('.oe_account_select_period').attr('disabled', 'disabled'); - }); - this.on('save:after cancel:after', this, function () { - self.$el.parent().find('.oe_account_select_account').removeAttr('disabled'); - self.$el.parent().find('.oe_account_select_analytic_account').removeAttr('disabled'); - self.$el.parent().find('.oe_account_select_partner').removeAttr('disabled'); - self.$el.parent().find('.oe_account_select_journal').removeAttr('disabled'); - self.$el.parent().find('.oe_account_select_period').removeAttr('disabled'); - }); - return tmp; }, set_user_groups: function() { @@ -67,7 +56,6 @@ openerp.account_move_line_search_extension = function (instance) { var result = {}; var action_context = this.dataset.get_context().__contexts[1]; _.each(action_context, function(v,k) { - //console.log('init, k=', k, 'v=', v); if (k[v] && (k.slice(0, 6) === "group_")) { result[k] = true; } @@ -102,15 +90,21 @@ openerp.account_move_line_search_extension = function (instance) { }); }, - search_by_selection: function() { + aml_search_domain: function() { var self = this; var domain = []; if (self.current_account) domain.push(['account_id.code', 'ilike', self.current_account]); if (self.current_analytic_account) domain.push(['analytic_account_id', 'in', self.current_analytic_account]); //cf. def search - if (self.current_partner) domain.push(['partner_id.name', 'ilike', self.current_partner],'|',['partner_id.parent_id','=',false],['partner_id.is_company','=',true]); + if (self.current_partner) domain.push(['partner_id.name', 'ilike', self.current_partner]); if (self.current_journal) domain.push(['journal_id', '=', self.current_journal]); if (self.current_period) domain.push('|',['period_id.code', 'ilike', self.current_period],['period_id.name', 'ilike', self.current_period]); - //_.each(domain, function(x) {console.log('search_by_journal_period, domain_part = ', x)}); + //_.each(domain, function(x) {console.log('amlse, aml_search_domain, domain_part = ', x)}); + return domain; + }, + + search_by_selection: function() { + var self = this; + var domain = self.aml_search_domain(); return self.old_search(new instance.web.CompoundDomain(self.last_domain, domain), self.last_context, self.last_group_by); },