[IMP] impromve sql view for model, remove method for nothing to reconcile button
bzr revid: rgaopenerp-20120808135747-vdi2wztvi9qprsus
This commit is contained in:
parent
7b26f82778
commit
fbddeaa021
|
@ -66,8 +66,8 @@ financial year and for preparation of vouchers there is a module named account_v
|
|||
'wizard/account_period_close_view.xml',
|
||||
'wizard/account_reconcile_view.xml',
|
||||
'wizard/account_unreconcile_view.xml',
|
||||
'account_view.xml',
|
||||
'account_move_reconciliation.xml',
|
||||
'account_view.xml',
|
||||
'account_report.xml',
|
||||
'account_financial_report_data.xml',
|
||||
'wizard/account_report_common_view.xml',
|
||||
|
|
|
@ -22,12 +22,9 @@
|
|||
import tools
|
||||
from osv import fields,osv
|
||||
|
||||
class res_partner(osv.osv):
|
||||
_inherit = 'res.partner'
|
||||
_columns = {
|
||||
'partner_move_count': fields.integer('Partner move line count')
|
||||
}
|
||||
res_partner()
|
||||
#1. Remove field from res.partner
|
||||
|
||||
#4 remove get_unreconcile_entry method mange it with domain
|
||||
|
||||
class account_move_line(osv.osv):
|
||||
_inherit = "account.move.line"
|
||||
|
@ -49,53 +46,37 @@ class account_move_reconciliation(osv.osv):
|
|||
_auto = False
|
||||
|
||||
def _rec_progress(self, cr, uid, ids, prop, unknow_none, context=None):
|
||||
active_ids = context.get('active_ids', [])
|
||||
res = 0
|
||||
cr.execute("""SELECT partner_id, reconcile_id
|
||||
FROM account_move_line WHERE state <> 'draft'
|
||||
GROUP BY partner_id, reconcile_id""")
|
||||
result = cr.fetchall()
|
||||
partner_total = len(result)
|
||||
partner_reconcile = len([ (x,y) for x, y in result if y == None ])
|
||||
if partner_total:
|
||||
res = float(partner_total- partner_reconcile)/partner_total * 100
|
||||
|
||||
if active_ids:
|
||||
total_records = self.search(cr, uid, [('id','in',active_ids)])
|
||||
total_reconcile = 0
|
||||
for record in self.read(cr, uid, total_records, ['reconcile_count'], context=context):
|
||||
if record['reconcile_count'] > 0:
|
||||
total_reconcile += 1
|
||||
res = float(total_reconcile)/len(total_records) * 100
|
||||
res_all = {}
|
||||
for id in ids:
|
||||
res_all[id] = res
|
||||
return res_all
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
|
||||
ids = super(account_move_reconciliation, self).search(cr, uid, args, offset, limit, order, context, count)
|
||||
res = []
|
||||
for l in self.browse(cr, uid, ids, context=context):
|
||||
if (not l.partner_move_count) or (l.move_lines_count >l.partner_move_count):
|
||||
res.append(l.id)
|
||||
return res
|
||||
|
||||
|
||||
_columns = {
|
||||
'partner_id':fields.many2one('res.partner', 'Partner'),
|
||||
'last_reconciliation_date':fields.datetime('Last Reconciliation'),
|
||||
'last_reconciliation_date':fields.related('partner_id', 'last_reconciliation_date' ,type='datetime', relation='res.partner', string='Last Reconciliation'),
|
||||
'latest_date' :fields.date('Latest Entry'),
|
||||
'reconciliation_progress': fields.function(_rec_progress, string='Progress (%)', type='float'),
|
||||
'move_lines_count':fields.integer('Move Count'),
|
||||
'partner_move_count':fields.integer('Partner move line count'),
|
||||
'reconcile_count':fields.integer('Reconcile Count'),
|
||||
}
|
||||
def skip_partner(self, cr, uid, ids, context):
|
||||
res_partner = self.pool.get('res.partner')
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
res_partner.write(cr, uid, [line.id] ,{'partner_move_count':line.move_lines_count})
|
||||
|
||||
def init(self, cr):
|
||||
tools.drop_view_if_exists(cr, 'account_move_reconciliation')
|
||||
cr.execute("""
|
||||
CREATE or REPLACE VIEW account_move_reconciliation as (
|
||||
SELECT p.id, p.id as partner_id,
|
||||
MAX(p.last_reconciliation_date) as last_reconciliation_date,
|
||||
MAX(l.date) as latest_date,
|
||||
COUNT(l.id) as move_lines_count,
|
||||
MAX(p.partner_move_count) as partner_move_count
|
||||
FROM account_move_line as l INNER JOIN res_partner AS p ON (l.partner_id = p.id)
|
||||
GROUP by p.id
|
||||
SELECT move_line.partner_id as id, move_line.partner_id,
|
||||
MAX(move_line.date) as latest_date,
|
||||
(select count(reconcile.id) from account_move_line as reconcile where reconcile.reconcile_id is not null and reconcile.partner_id = move_line.partner_id) as reconcile_count
|
||||
FROM account_move_line as move_line where move_line.state <> 'draft'
|
||||
GROUP by move_line.partner_id
|
||||
)
|
||||
""")
|
||||
account_move_reconciliation()
|
||||
|
|
|
@ -1582,16 +1582,6 @@
|
|||
<field name="act_window_id" ref="action_move_line_search"/>
|
||||
</record>
|
||||
|
||||
<record id="action_account_manual_reconcile" model="ir.actions.act_window">
|
||||
<field name="name">Entries To Reconcile</field>
|
||||
<field name="res_model">account.move.line</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_move_line_tree"/>
|
||||
<field eval="False" name="auto_search"/>
|
||||
<field name="context">{'view_mode':True}</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_receivable_manual_reconcile" model="ir.actions.act_window">
|
||||
<field name="name">Entries To Reconcile</field>
|
||||
<field name="res_model">account.move.line</field>
|
||||
|
@ -1599,7 +1589,7 @@
|
|||
<field name="view_mode">tree,form</field>
|
||||
<field eval="False" name="auto_search"/>
|
||||
<field name="domain">[('partner_id.customer','=',True)]</field>
|
||||
<field name="context" eval="{'view_mode':True, 'extended_form_view_id': ref('view_account_move_reconciliation_form_view')}"></field>
|
||||
<field name="context" eval="{'view_mode':True,'extended_form_view_id': ref('view_account_move_reconciliation_form_view')}"></field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_payable_manual_reconcile" model="ir.actions.act_window">
|
||||
|
@ -1609,7 +1599,7 @@
|
|||
<field name="view_mode">tree,form</field>
|
||||
<field eval="False" name="auto_search"/>
|
||||
<field name="domain">[('partner_id.supplier','=',True)]</field>
|
||||
<field name="context" eval="{'view_mode':True, 'extended_form_view_id': ref('view_account_move_reconciliation_form_view')}"></field>
|
||||
<field name="context" eval="{'view_mode':True,'extended_form_view_id': ref('view_account_move_reconciliation_form_view')}"></field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
|
|
|
@ -21,6 +21,7 @@ instance.account.extend_viewmanager = instance.web.ViewManagerAction.include({
|
|||
obj_from_view.template = 'ExtendedFormView'
|
||||
view_promise = obj_from_view.appendTo(this.$element.find('.oe_extended_form_view'))
|
||||
$.when(view_promise, this.dataset_loaded).then(function() {
|
||||
self.action.context.active_ids = self.dataset_form.ids;
|
||||
if (!_.isEmpty(self.dataset_form.ids)) {
|
||||
obj_from_view.on_pager_action('first')
|
||||
}
|
||||
|
@ -72,12 +73,10 @@ instance.account.extend_form_view = instance.web.FormView.extend({
|
|||
},
|
||||
|
||||
do_nothing_to_reconcile:function(event){
|
||||
self = this
|
||||
this.dataset.call(event.target.name, [[self.datarecord.id], self.dataset.context]).then(function() {
|
||||
self.dataset.read_slice().done(function(){
|
||||
self.on_pager_action();
|
||||
});
|
||||
})
|
||||
viewmanager = this.getParent();
|
||||
this.dataset.ids = _.without(this.dataset.ids, this.datarecord.id)
|
||||
viewmanager.action.context.active_ids = viewmanager.dataset_form.ids;
|
||||
this.on_pager_action();
|
||||
},
|
||||
|
||||
do_update_pager: function(hide_index) {
|
||||
|
|
Loading…
Reference in New Issue