[IMP] set default selected record when list view load
bzr revid: rgaopenerp-20120720062213-h78ahslrl7u2zoqr
This commit is contained in:
parent
b6f1b50b34
commit
5a4e4db518
|
@ -107,7 +107,15 @@ class account_move_line(osv.osv):
|
|||
|
||||
query += company_clause
|
||||
return query
|
||||
|
||||
|
||||
def get_selection_ids(self, cr, uid, ids, context=None):
|
||||
records = self.read(cr, uid, ids, ['reconcile_id'])
|
||||
res = []
|
||||
for record in records:
|
||||
if not record.get('reconcile_id'):
|
||||
res.append(record['id'])
|
||||
return res
|
||||
|
||||
def _amount_residual(self, cr, uid, ids, field_names, args, context=None):
|
||||
"""
|
||||
This function returns the residual amount on a receivable or payable account.move.line.
|
||||
|
|
|
@ -1023,7 +1023,7 @@
|
|||
<field name="type">tree</field>
|
||||
<field eval="4" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="red:state == 'draft';black:reconcile_id > 0" string="Journal Items" editable="top" on_write="on_create_write">
|
||||
<tree colors="red:state == 'draft';black:reconcile_id > 0" string="Journal Items" editable="top" on_write="on_create_write" default_selection="get_selection_ids">
|
||||
<field name="date"/>
|
||||
<field name="period_id" invisible="1"/>
|
||||
<field name="move_id"/>
|
||||
|
|
|
@ -140,6 +140,21 @@ instance.account.many2one_pager = instance.web.form.FieldMany2One.extend({
|
|||
},
|
||||
})
|
||||
instance.account.btn_extend = instance.web.form.WidgetButton.extend({
|
||||
on_click: function() {
|
||||
var self = this;
|
||||
this.force_disabled = true;
|
||||
this.check_disable();
|
||||
this.execute_action().always(function() {
|
||||
self.force_disabled = false;
|
||||
self.check_disable();
|
||||
self.reload_view();
|
||||
});
|
||||
|
||||
},
|
||||
reload_view :function(){
|
||||
viewmanager = this.view.getParent().getParent()
|
||||
viewmanager.inner_widget.list_view.controller.reload_content();
|
||||
},
|
||||
on_confirmed: function() {
|
||||
var self = this;
|
||||
|
||||
|
@ -193,19 +208,29 @@ instance.account.list_button = instance.web.form.WidgetButton.extend({
|
|||
});
|
||||
}
|
||||
})
|
||||
instance.account.set_selection = instance.web.ListView.List.include({
|
||||
render: function(){
|
||||
this._super()
|
||||
self = this
|
||||
// To Do: Create method on addons which give ids which have to default selected OR create tag like "colors" on tree
|
||||
if (this.options.action && this.options.action.extended_form_view_id){
|
||||
this.$current.find('th.oe_list_record_selector input')
|
||||
.closest('tr').each(function () {
|
||||
var record = self.records.get($(this).data('id'));
|
||||
if (!record.get('reconcile_id'))
|
||||
$(this).find('th.oe_list_record_selector input').prop('checked', true)
|
||||
})
|
||||
instance.account.set_selection = instance.web.ListView.include({
|
||||
default_selection: function(){
|
||||
var self = this
|
||||
selection_method = this.fields_view.arch.attrs.default_selection;
|
||||
if(selection_method){
|
||||
this.dataset.call(selection_method, [this.dataset.ids], this.context).then(_.bind(self.set_selection, self));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
set_selection : function(ids){
|
||||
this.$element.find('th.oe_list_record_selector input')
|
||||
.closest('tr').each(function () {
|
||||
if(_.include(ids, $(this).data('id'))){
|
||||
$(this).find('th.oe_list_record_selector input').prop('checked', true)
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
reload_content: function() {
|
||||
var reloaded =this._super()
|
||||
var self = this
|
||||
reloaded.done(_.bind(self.default_selection, self))
|
||||
},
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
@ -8,21 +8,15 @@
|
|||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Reconciliation" version="7.0">
|
||||
<header>
|
||||
<button string="Reconcile" name="trans_rec_reconcile_full" type="object" default_focus="1" attrs="{'invisible':[('writeoff','!=',0)]}" class="oe_highlight"/>
|
||||
<button string="Reconcile With Write-Off" name="trans_rec_addendum_writeoff" type="object" attrs="{'invisible':[('writeoff','==',0)]}" class="oe_highlight"/>
|
||||
<button string="Partial Reconcile" name="trans_rec_reconcile_partial_reconcile" type="object" attrs="{'invisible':[('writeoff','==',0)]}" class="oe_highlight"/>
|
||||
<button string="Cancel" class="oe_link" special="cancel"/>
|
||||
</header>
|
||||
<group col="2" string="Reconciliation Transactions">
|
||||
<field name="credit"/>
|
||||
<field name="debit"/>
|
||||
<field name="writeoff"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button string="Reconcile" name="trans_rec_reconcile_full" type="object" default_focus="1" attrs="{'invisible':[('writeoff','!=',0)]}" class="oe_highlight"/>
|
||||
<button string="Reconcile With Write-Off" name="trans_rec_addendum_writeoff" type="object" attrs="{'invisible':[('writeoff','==',0)]}" class="oe_highlight"/>
|
||||
<button string="Partial Reconcile" name="trans_rec_reconcile_partial_reconcile" type="object" attrs="{'invisible':[('writeoff','==',0)]}" class="oe_highlight"/>
|
||||
<button string="Reconcile" name="trans_rec_reconcile_full" type="object" widget="btn_extend" default_focus="1" attrs="{'invisible':[('writeoff','!=',0)]}" class="oe_highlight"/>
|
||||
<button string="Reconcile With Write-Off" name="trans_rec_addendum_writeoff" widget="btn_extend" type="object" attrs="{'invisible':[('writeoff','==',0)]}" class="oe_highlight"/>
|
||||
<button string="Partial Reconcile" name="trans_rec_reconcile_partial_reconcile" widget="btn_extend" type="object" attrs="{'invisible':[('writeoff','==',0)]}" class="oe_highlight"/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel"/>
|
||||
</footer>
|
||||
|
|
Loading…
Reference in New Issue