diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index d9e95f15079..bf3fe6aaafb 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -650,7 +650,7 @@ - + @@ -661,7 +661,7 @@ - + diff --git a/addons/account_voucher/__openerp__.py b/addons/account_voucher/__openerp__.py index c0011c8b3c5..ac80a7f32b0 100644 --- a/addons/account_voucher/__openerp__.py +++ b/addons/account_voucher/__openerp__.py @@ -60,6 +60,15 @@ This module manages: 'security/account_voucher_security.xml', 'account_voucher_data.xml', ], + 'js': [ + 'static/src/js/account_voucher_reconciliation.js', + ], + 'qweb' : [ + 'static/src/xml/account_voucher_reconciliation.xml', + ], + 'css': [ + #'static/src/css/account_voucher_reconciliation.css', + ], 'test' : [ 'test/account_voucher.yml', 'test/sales_receipt.yml', diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index e1caf190316..8774b717477 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -1565,7 +1565,7 @@ class account_bank_statement_line(osv.osv): _columns = { 'amount_reconciled': fields.function(_amount_reconciled, string='Amount reconciled', type='float'), - 'voucher_id': fields.many2one('account.voucher', 'Payment'), + 'voucher_id': fields.many2one('account.voucher', 'Reconciliation'), } def unlink(self, cr, uid, ids, context=None): diff --git a/addons/account_voucher/account_voucher_view.xml b/addons/account_voucher/account_voucher_view.xml index 4b02d697982..55a07c5fd99 100644 --- a/addons/account_voucher/account_voucher_view.xml +++ b/addons/account_voucher/account_voucher_view.xml @@ -212,7 +212,7 @@ - + @@ -223,7 +223,7 @@ - + diff --git a/addons/account_voucher/static/src/js/account_voucher_reconciliation.js b/addons/account_voucher/static/src/js/account_voucher_reconciliation.js new file mode 100644 index 00000000000..7a4d47403f6 --- /dev/null +++ b/addons/account_voucher/static/src/js/account_voucher_reconciliation.js @@ -0,0 +1,74 @@ +openerp.account_voucher = function (instance) { + var _t = instance.web._t, + _lt = instance.web._lt; + var QWeb = instance.web.qweb; + + instance.web.account_voucher = {}; + + instance.web.form.widgets.add('account_voucher_field', 'instance.web.account_voucher.AccountVoucherField'); + instance.web.account_voucher.AccountVoucherField = instance.web.form.AbstractField.extend({ + template: 'FieldAccountVoucher', + init: function(field_manager, node) { + this._super.apply(this, arguments); + var self = this; + this.set('value', false); + this.is_started = false; + }, + start: function() { + this._super.apply(this, arguments); + var self = this; + this.string = this.get('value') ? _t('Edit') : _t('Create'); + this.node.attrs.icon = this.get('value') ? '/web/static/src/img/icons/gtk-yes.png' : '/web/static/src/img/icons/gtk-no.png'; + this.$button = $(QWeb.render('WidgetButton', {'widget': this})); + this.$el.append(this.$button); + this.$button.on('click', self.on_click); + this.is_started = true; + }, + on_click: function(ev) { + var self = this; + ev.stopPropagation(); + var popup = new instance.web.form.FormOpenPopup(this); + popup.show_element( + this.field.relation, + this.get('value'), + this.build_context(), + {title: _t("Voucher: ") + this.string} + ); + popup.on('create_completed write_completed', self, function(r){ + self.set_value(r); + }); + }, + // render_value: function() {}, + set_value: function(value_) { + var self = this; + if (value_ instanceof Array) { + value_ = value_[0]; + } + value_ = value_ || false; + this.set('value', value_); + if (this.is_started) { + this.render_value(); + } + }, + // get_value: function() {}, + // set_input_id: function(id) {}, + // is_valid: function() {}, + // is_syntax_valid: function() {}, + // focus: function() {}, + // on_translate: function() {}, + + }); + + instance.web.list.columns.add('field.account_voucher_field', 'instance.web.list.AccountVoucherField'); + instance.web.list.AccountVoucherField = instance.web.list.Column.extend({ + format: function (row_data, options) { + if (row_data.voucher_id.value) { + this.icon = '/web/static/src/img/icons/gtk-yes.png'; + } else { + this.icon = '/web/static/src/img/icons/gtk-no.png'; + } + return QWeb.render('FieldAccountVoucher.cell', {'widget': this}); + }, + }); + +}; \ No newline at end of file