mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[MRG] Fix logger + use of mail thread system
This commit is contained in:
@@ -43,7 +43,7 @@ class AccountStatementProfil(Model):
|
||||
help="Tic that box to automatically launch the completion "
|
||||
"on each imported file using this profile."),
|
||||
'last_import_date': fields.datetime("Last Import Date"),
|
||||
'rec_log': fields.text('log', readonly=True),
|
||||
'rec_log': fields.text('log', readonly=True, deprecated=True),
|
||||
'import_type': fields.selection(
|
||||
get_import_type_selection,
|
||||
'Type of import',
|
||||
@@ -55,29 +55,17 @@ class AccountStatementProfil(Model):
|
||||
|
||||
def write_logs_after_import(self, cr, uid, ids, statement_id, num_lines, context):
|
||||
"""
|
||||
Write the log in the logger + in the log field of the profile to report the user about
|
||||
what has been done.
|
||||
Write the log in the logger
|
||||
|
||||
:param int/long statement_id: ID of the concerned account.bank.statement
|
||||
:param int/long num_lines: Number of line that have been parsed
|
||||
:return: True
|
||||
"""
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
for id in ids:
|
||||
log = self.read(cr, uid, id, ['rec_log'], context=context)['rec_log']
|
||||
log_line = log and log.split("\n") or []
|
||||
import_date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
log_line[0:0] = [import_date + ' : '
|
||||
+ _("Bank Statement ID %s have been imported with %s lines ") % (statement_id, num_lines)]
|
||||
log = "\n".join(log_line)
|
||||
self.write(cr, uid, id, {'rec_log': log, 'last_import_date': import_date}, context=context)
|
||||
self.message_post(
|
||||
cr,
|
||||
uid,
|
||||
[statement_id],
|
||||
body=_('Statement ID %s have been imported with %s lines.') % (statement_id, num_lines),
|
||||
context=context)
|
||||
self.message_post(cr,
|
||||
uid,
|
||||
ids,
|
||||
body=_('Statement ID %s have been imported with %s lines.') % (statement_id, num_lines),
|
||||
context=context)
|
||||
return True
|
||||
|
||||
def prepare_global_commission_line_vals(
|
||||
|
||||
@@ -16,10 +16,12 @@
|
||||
<field name="import_type"/>
|
||||
<button name="%(account_statement_base_import.statement_importer_action)d"
|
||||
string="Import Bank Statement"
|
||||
type="action" icon="gtk-ok"
|
||||
type="action" icon="gtk-ok"
|
||||
colspan = "2"/>
|
||||
<separator colspan="4" string="Import Logs"/>
|
||||
<field name="rec_log" colspan="4" nolabel="1"/>
|
||||
<group attrs="{'invisible': [('rec_log', '=', False)]}">
|
||||
<separator colspan="4" string="Historical Import Logs"/>
|
||||
<field name="rec_log" colspan="4" nolabel="1" />
|
||||
</group>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@@ -39,6 +41,6 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -31,6 +31,8 @@ class AccountStatementProfil(Model):
|
||||
journal to use, the partner and commision account and so on.
|
||||
"""
|
||||
_name = "account.statement.profile"
|
||||
_inherit = ['mail.thread']
|
||||
|
||||
_description = "Statement Profil"
|
||||
|
||||
_columns = {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<field name="force_partner_on_bank"/>
|
||||
<field name="balance_check"/>
|
||||
<field name="bank_statement_prefix"/>
|
||||
<field name="message_ids" widget="mail_thread" placeholder="Share a note..." colspan="4"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
@@ -46,10 +47,10 @@
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem string="Bank Statements Profile" action="action_treasury_statement_profile_tree" id="menu_treasury_statement_profile_tree" parent="account.menu_configuration_misc" sequence="30"/>
|
||||
<menuitem string="Bank Statements Profile" action="action_treasury_statement_profile_tree" id="menu_treasury_statement_profile_tree" parent="account.menu_configuration_misc" sequence="30"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<record id="view_treasury_statement_search" model="ir.ui.view">
|
||||
<field name="name">account.bank.statement.search</field>
|
||||
<field name="model">account.bank.statement</field>
|
||||
@@ -87,7 +88,7 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<record id="view_treasury_statement_form" model="ir.ui.view">
|
||||
<field name="name">account.bank.statement.form</field>
|
||||
<field name="model">account.bank.statement</field>
|
||||
@@ -98,7 +99,7 @@
|
||||
<!-- Add before the group : profile and related infos -->
|
||||
<xpath expr="/form/sheet/group/group/field[@name='journal_id']" position="replace">
|
||||
</xpath>
|
||||
|
||||
|
||||
<xpath expr="/form/sheet/group" position="after">
|
||||
<group>
|
||||
<field name="profile_id" select="1" required="1" on_change="onchange_imp_config_id(profile_id)" widget="selection"/>
|
||||
@@ -109,7 +110,7 @@
|
||||
<field name="balance_check" invisible="1"/>
|
||||
</group>
|
||||
</xpath>
|
||||
|
||||
|
||||
# Make balance visible or not depending on profile
|
||||
<xpath expr="/form/sheet/group/group/field[@name='balance_start']" position="attributes">
|
||||
<attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
|
||||
@@ -120,11 +121,11 @@
|
||||
<xpath expr="/form/sheet/group/group/field[@name='balance_end_real']" position="after">
|
||||
<field name="balance_end" widget="monetary" options='{"currency_field" : "currency"}' attrs="{'invisible':[('balance_check','=',False)]}"/>
|
||||
</xpath>
|
||||
|
||||
|
||||
<xpath expr="/form/sheet/notebook/page/field/tree/field[@name='sequence']" position="after">
|
||||
<field name="id" readonly="1" />
|
||||
</xpath>
|
||||
|
||||
|
||||
<xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='date']" position="before">
|
||||
<field name="id" readonly="1" />
|
||||
</xpath>
|
||||
@@ -132,7 +133,7 @@
|
||||
<xpath expr="/form/sheet/notebook/page/field/tree/field[@name='partner_id']" position="replace">
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>
|
||||
</xpath>
|
||||
|
||||
|
||||
<xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='partner_id']" position="replace">
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>
|
||||
</xpath>
|
||||
@@ -142,18 +143,18 @@
|
||||
<xpath expr="/form/sheet/notebook/page/field/tree/field[@name='type']" position="replace">
|
||||
<field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)"/>
|
||||
</xpath>
|
||||
|
||||
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<act_window id="act_bank_statement_from_profile"
|
||||
name="Open Statements"
|
||||
res_model="account.bank.statement"
|
||||
src_model="account.statement.profile"
|
||||
name="Open Statements"
|
||||
res_model="account.bank.statement"
|
||||
src_model="account.statement.profile"
|
||||
domain="[('profile_id','=',active_id),]"
|
||||
view_type="form"/>
|
||||
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user