[IMP] Account Payment: Bank statement button import invoice lines does not ask for confirmation now, and will be invisible when state is not draft
bzr revid: mra@mra-laptop-20100901111835-l6orwmx9rg1w08z2
This commit is contained in:
parent
70a109ad7e
commit
72383a9d08
|
@ -315,7 +315,7 @@
|
|||
<field name="inherit_id" ref="account.view_bank_statement_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="journal_id" position="after">
|
||||
<button name="%(action_account_populate_statement_confirm)d" string="Import payment lines" type="action" icon="gtk-execute"/>
|
||||
<button name="%(action_account_populate_statement_confirm)d" attrs="{'invisible':[('state','=','confirm')]}" string="Import payment lines" type="action" icon="gtk-execute"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
@ -30,44 +30,22 @@ class account_payment_populate_statement(osv.osv_memory):
|
|||
'lines': fields.many2many('payment.line', 'payment_line_rel_', 'payment_id', 'line_id', 'Payment Lines')
|
||||
}
|
||||
|
||||
def search_entries(self, cr, uid, ids, context=None):
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
line_obj = self.pool.get('payment.line')
|
||||
statement_obj = self.pool.get('account.bank.statement')
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
|
||||
data = self.read(cr, uid, ids, [], context=context)[0]
|
||||
statement = statement_obj.browse(cr, uid, context['active_id'], context=context)
|
||||
res = super(account_payment_populate_statement, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
|
||||
line_ids = line_obj.search(cr, uid, [
|
||||
('move_line_id.reconcile_id', '=', False),
|
||||
('bank_statement_line_id', '=', False),])
|
||||
# ('order_id.mode.journal.id', '=', statement.journal_id.id)])
|
||||
line_ids.extend(line_obj.search(cr, uid, [
|
||||
('move_line_id.reconcile_id', '=', False),
|
||||
('order_id.mode', '=', False)]))
|
||||
|
||||
context.update({'line_ids': line_ids})
|
||||
model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','account_payment_populate_statement_view')], context=context)
|
||||
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
|
||||
return {
|
||||
'name': ('Entrie Lines'),
|
||||
'context': context,
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'account.payment.populate.statement',
|
||||
'views': [(resource_id,'form')],
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
res = super(account_payment_populate_statement, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
|
||||
if context and 'line_ids' in context:
|
||||
view_obj = etree.XML(res['arch'])
|
||||
child = view_obj.getchildren()[0]
|
||||
domain = '[("id", "in", '+ str(context['line_ids'])+')]'
|
||||
field = etree.Element('field', attrib={'domain': domain, 'name':'lines', 'colspan':'4', 'height':'300', 'width':'800', 'nolabel':"1"})
|
||||
child.addprevious(field)
|
||||
res['arch'] = etree.tostring(view_obj)
|
||||
domain = '[("id", "in", '+ str(line_ids)+')]'
|
||||
doc = etree.XML(res['arch'])
|
||||
nodes = doc.xpath("//field[@name='lines']")
|
||||
for node in nodes:
|
||||
node.set('domain', domain)
|
||||
res['arch'] = etree.tostring(doc)
|
||||
return res
|
||||
|
||||
def populate_statement(self, cr, uid, ids, context=None):
|
||||
|
|
|
@ -2,29 +2,13 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="account_populate_statement_confirm_view" model="ir.ui.view">
|
||||
<field name="name">Payment Populate statement</field>
|
||||
<field name="model">account.payment.populate.statement</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Populate Statement:">
|
||||
<label string="Are your sure to import Payment Lines!"/>
|
||||
<group colspan="4" col="6">
|
||||
<separator colspan="6"/>
|
||||
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
|
||||
<button name="search_entries" string="Yes" type="object" icon="gtk-ok"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_populate_statement_confirm" model="ir.actions.act_window">
|
||||
<field name="name">Payment Populate statement</field>
|
||||
<field name="res_model">account.payment.populate.statement</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="account_populate_statement_confirm_view"/>
|
||||
<field name="view_id" ref="account_payment_populate_statement_view"/>
|
||||
<field name="context">{'record_id':active_id}</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
@ -36,6 +20,7 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Populate Statement:">
|
||||
<group colspan="4" col="6">
|
||||
<field name="lines" colspan="4" height="300" width="800" nolabel="1" />
|
||||
<separator colspan="6"/>
|
||||
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
|
||||
<button name="populate_statement" string="ADD" type="object" icon="gtk-ok"/>
|
||||
|
|
Loading…
Reference in New Issue