[IMP] Improved voucher_id field in bank statement lines.

bzr revid: vta@openerp.com-20121031140334-mqi6hcofjuk4zps0
This commit is contained in:
vta vta@openerp.com
2012-10-31 15:03:34 +01:00
parent 143d67a2b0
commit 8f29452027
5 changed files with 88 additions and 5 deletions
+2 -2
View File
@@ -650,7 +650,7 @@
<field name="ref"/>
<field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
<field name="type" on_change="onchange_type(partner_id, type)"/>
<field domain="[('journal_id','=',parent.journal_id), ('company_id', '=', parent.company_id)]" name="account_id"/>
<field name="account_id" domain="[('journal_id','=',parent.journal_id), ('company_id', '=', parent.company_id)]"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('company_id', '=', parent.company_id), ('type', '&lt;&gt;', 'view')]"/>
<field name="amount"/>
</tree>
@@ -661,7 +661,7 @@
<field name="ref"/>
<field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
<field name="type" on_change="onchange_type(partner_id, type)"/>
<field domain="[('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', 'view'), ('company_id', '=', parent.company_id)]" name="account_id"/>
<field name="account_id" domain="[('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', 'view'), ('company_id', '=', parent.company_id)]"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('company_id', '=', parent.company_id), ('type', '&lt;&gt;', 'view')]"/>
<field name="amount"/>
<field name="sequence" readonly="0"/>
+9
View File
@@ -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',
+1 -1
View File
@@ -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):
@@ -212,7 +212,7 @@
<field name="inherit_id" ref="account.view_bank_statement_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='statement_line_ids']/field[@name='line_ids']/tree/field[@name='amount']" position="after">
<field name="voucher_id" context="{'line_type': type, 'default_type': amount &lt; 0 and 'payment' or 'receipt', 'type': amount &lt; 0 and 'payment' or 'receipt', 'default_partner_id': partner_id, 'default_journal_id': parent.journal_id, 'default_amount': abs(amount), 'default_reference': ref, 'default_date': date, 'default_name': name}"/>
<field name="voucher_id" widget="account_voucher_field" context="{'line_type': type, 'default_type': amount &lt; 0 and 'payment' or 'receipt', 'type': amount &lt; 0 and 'payment' or 'receipt', 'default_partner_id': partner_id, 'default_journal_id': parent.journal_id, 'default_amount': abs(amount), 'default_reference': ref, 'default_date': date, 'default_name': name}"/>
</xpath>
</field>
</record>
@@ -223,7 +223,7 @@
<field name="inherit_id" ref="account.view_bank_statement_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='statement_line_ids']/field[@name='line_ids']/form/group/field[@name='sequence']" position="before">
<field name="voucher_id" context="{'line_type': type, 'default_type': amount &lt; 0 and 'payment' or 'receipt', 'type': amount &lt; 0 and 'payment' or 'receipt', 'default_partner_id': partner_id, 'default_journal_id': parent.journal_id, 'default_amount': abs(amount), 'default_reference': ref, 'default_date': date, 'default_name': name}"/>
<field name="voucher_id" widget="account_voucher_field" context="{'line_type': type, 'default_type': amount &lt; 0 and 'payment' or 'receipt', 'type': amount &lt; 0 and 'payment' or 'receipt', 'default_partner_id': partner_id, 'default_journal_id': parent.journal_id, 'default_amount': abs(amount), 'default_reference': ref, 'default_date': date, 'default_name': name}"/>
</xpath>
</field>
</record>
@@ -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});
},
});
};