mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
update 80 account_move_line_search_extension
This commit is contained in:
@@ -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 <info@noviat.com>
|
||||
|
||||
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.
|
||||
|
||||
@@ -21,4 +21,5 @@
|
||||
##############################################################################
|
||||
|
||||
from . import account
|
||||
from . import res_partner
|
||||
from . import ir_actions
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
{
|
||||
'name': 'Journal Items Search Extension',
|
||||
'version': '0.4',
|
||||
'version': '0.5',
|
||||
'license': 'AGPL-3',
|
||||
'author': 'Noviat',
|
||||
'category': 'Accounting & Finance',
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
##############################################################################
|
||||
|
||||
from openerp import models
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ir_actions_act_window(models.Model):
|
||||
|
||||
41
account_move_line_search_extension/res_partner.py
Normal file
41
account_move_line_search_extension/res_partner.py
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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)
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user