[FIX] logger of account.bank.profile that was broken + use mail thread system

This commit is contained in:
unknown
2013-01-28 10:48:10 +01:00
parent d57d123d74
commit a121a99241
4 changed files with 26 additions and 37 deletions

View File

@@ -43,7 +43,6 @@ class AccountStatementProfil(Model):
help="Tic that box to automatically launch the completion " help="Tic that box to automatically launch the completion "
"on each imported file using this profile."), "on each imported file using this profile."),
'last_import_date': fields.datetime("Last Import Date"), 'last_import_date': fields.datetime("Last Import Date"),
'rec_log': fields.text('log', readonly=True),
'import_type': fields.selection( 'import_type': fields.selection(
get_import_type_selection, get_import_type_selection,
'Type of import', 'Type of import',
@@ -55,29 +54,17 @@ class AccountStatementProfil(Model):
def write_logs_after_import(self, cr, uid, ids, statement_id, num_lines, context): 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 Write the log in the logger
what has been done.
:param int/long statement_id: ID of the concerned account.bank.statement :param int/long statement_id: ID of the concerned account.bank.statement
:param int/long num_lines: Number of line that have been parsed :param int/long num_lines: Number of line that have been parsed
:return: True :return: True
""" """
if isinstance(ids, (int, long)): self.message_post(cr,
ids = [ids] uid,
for id in ids: ids,
log = self.read(cr, uid, id, ['rec_log'], context=context)['rec_log'] body=_('Statement ID %s have been imported with %s lines.') % (statement_id, num_lines),
log_line = log and log.split("\n") or [] context=context)
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)
return True return True
def prepare_global_commission_line_vals( def prepare_global_commission_line_vals(

View File

@@ -16,10 +16,9 @@
<field name="import_type"/> <field name="import_type"/>
<button name="%(account_statement_base_import.statement_importer_action)d" <button name="%(account_statement_base_import.statement_importer_action)d"
string="Import Bank Statement" string="Import Bank Statement"
type="action" icon="gtk-ok" type="action" icon="gtk-ok"
colspan = "2"/> colspan = "2"/>
<separator colspan="4" string="Import Logs"/> <separator colspan="4" string="Import Logs"/>
<field name="rec_log" colspan="4" nolabel="1"/>
</field> </field>
</field> </field>
</record> </record>
@@ -39,6 +38,6 @@
</field> </field>
</record> </record>
</data> </data>
</openerp> </openerp>

View File

@@ -31,6 +31,8 @@ class AccountStatementProfil(Model):
journal to use, the partner and commision account and so on. journal to use, the partner and commision account and so on.
""" """
_name = "account.statement.profile" _name = "account.statement.profile"
_inherit = ['mail.thread']
_description = "Statement Profil" _description = "Statement Profil"
_columns = { _columns = {

View File

@@ -18,6 +18,7 @@
<field name="force_partner_on_bank"/> <field name="force_partner_on_bank"/>
<field name="balance_check"/> <field name="balance_check"/>
<field name="bank_statement_prefix"/> <field name="bank_statement_prefix"/>
<field name="message_ids" widget="mail_thread" placeholder="Share a note..." colspan="4"/>
</form> </form>
</field> </field>
</record> </record>
@@ -46,10 +47,10 @@
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
</record> </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"> <record id="view_treasury_statement_search" model="ir.ui.view">
<field name="name">account.bank.statement.search</field> <field name="name">account.bank.statement.search</field>
<field name="model">account.bank.statement</field> <field name="model">account.bank.statement</field>
@@ -87,7 +88,7 @@
</field> </field>
</record> </record>
<record id="view_treasury_statement_form" model="ir.ui.view"> <record id="view_treasury_statement_form" model="ir.ui.view">
<field name="name">account.bank.statement.form</field> <field name="name">account.bank.statement.form</field>
<field name="model">account.bank.statement</field> <field name="model">account.bank.statement</field>
@@ -98,7 +99,7 @@
<!-- Add before the group : profile and related infos --> <!-- Add before the group : profile and related infos -->
<xpath expr="/form/sheet/group/group/field[@name='journal_id']" position="replace"> <xpath expr="/form/sheet/group/group/field[@name='journal_id']" position="replace">
</xpath> </xpath>
<xpath expr="/form/sheet/group" position="after"> <xpath expr="/form/sheet/group" position="after">
<group> <group>
<field name="profile_id" select="1" required="1" on_change="onchange_imp_config_id(profile_id)" widget="selection"/> <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"/> <field name="balance_check" invisible="1"/>
</group> </group>
</xpath> </xpath>
# Make balance visible or not depending on profile # Make balance visible or not depending on profile
<xpath expr="/form/sheet/group/group/field[@name='balance_start']" position="attributes"> <xpath expr="/form/sheet/group/group/field[@name='balance_start']" position="attributes">
<attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute> <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"> <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)]}"/> <field name="balance_end" widget="monetary" options='{"currency_field" : "currency"}' attrs="{'invisible':[('balance_check','=',False)]}"/>
</xpath> </xpath>
<xpath expr="/form/sheet/notebook/page/field/tree/field[@name='sequence']" position="after"> <xpath expr="/form/sheet/notebook/page/field/tree/field[@name='sequence']" position="after">
<field name="id" readonly="1" /> <field name="id" readonly="1" />
</xpath> </xpath>
<xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='date']" position="before"> <xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='date']" position="before">
<field name="id" readonly="1" /> <field name="id" readonly="1" />
</xpath> </xpath>
@@ -132,7 +133,7 @@
<xpath expr="/form/sheet/notebook/page/field/tree/field[@name='partner_id']" position="replace"> <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)]"/> <field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>
</xpath> </xpath>
<xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='partner_id']" position="replace"> <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)]"/> <field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>
</xpath> </xpath>
@@ -142,18 +143,18 @@
<xpath expr="/form/sheet/notebook/page/field/tree/field[@name='type']" position="replace"> <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)"/> <field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)"/>
</xpath> </xpath>
</field> </field>
</record> </record>
<act_window id="act_bank_statement_from_profile" <act_window id="act_bank_statement_from_profile"
name="Open Statements" name="Open Statements"
res_model="account.bank.statement" res_model="account.bank.statement"
src_model="account.statement.profile" src_model="account.statement.profile"
domain="[('profile_id','=',active_id),]" domain="[('profile_id','=',active_id),]"
view_type="form"/> view_type="form"/>
</data> </data>
</openerp> </openerp>