From 884c76a1f0a3cb69bd3bca77056242460867f4fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 18 Dec 2012 18:23:30 +0100 Subject: [PATCH] [REF] account_voucher: chatter messages replaced by a track on state, with a _track on model with subtype state_change. bzr revid: tde@openerp.com-20121218172330-dsy8dth8reafgq2i --- addons/account_voucher/account_voucher.py | 43 ++++------------------- addons/account_voucher/account_voucher_data.xml | 2 +- 2 files changed, 8 insertions(+), 37 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 41d3476..491f50e 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -266,6 +266,12 @@ class account_voucher(osv.osv): _inherit = ['mail.thread'] _order = "date desc, id desc" # _rec_name = 'number' + _track = { + 'state': { + 'account_voucher.mt_voucher_state_change': lambda self, cr, uid, obj, ctx=None: True, + }, + } + _columns = { 'active': fields.boolean('Active', help="By default, reconciliation vouchers made on draft bank statements are set as inactive, which allow to hide the customer/supplier payment while the bank statement isn't confirmed."), 'type':fields.selection([ @@ -293,7 +299,7 @@ class account_voucher(osv.osv): ('cancel','Cancelled'), ('proforma','Pro-forma'), ('posted','Posted') - ], 'Status', readonly=True, size=32, + ], 'Status', readonly=True, size=32, track_visibility=1, help=' * The \'Draft\' status is used when a user is encoding a new and unconfirmed Voucher. \ \n* The \'Pro-forma\' when voucher is in Pro-forma status,voucher does not have an voucher number. \ \n* The \'Posted\' status is used when user create voucher,a voucher number is generated and voucher entries are created in account \ @@ -350,11 +356,6 @@ class account_voucher(osv.osv): 'payment_rate_currency_id': _get_payment_rate_currency, } - def create(self, cr, uid, vals, context=None): - voucher = super(account_voucher, self).create(cr, uid, vals, context=context) - self.create_send_note(cr, uid, [voucher], context=context) - return voucher - def compute_tax(self, cr, uid, ids, context=None): tax_pool = self.pool.get('account.tax') partner_pool = self.pool.get('res.partner') @@ -1302,7 +1303,6 @@ class account_voucher(osv.osv): 'state': 'posted', 'number': name, }) - self.post_send_note(cr, uid, [voucher.id], context=context) if voucher.journal_id.entry_posted: move_pool.post(cr, uid, [move_id], context={}) # We automatically reconcile the account move lines. @@ -1310,8 +1310,6 @@ class account_voucher(osv.osv): for rec_ids in rec_list_ids: if len(rec_ids) >= 2: reconcile = move_line_pool.reconcile_partial(cr, uid, rec_ids, writeoff_acc_id=voucher.writeoff_acc_id.id, writeoff_period_id=voucher.period_id.id, writeoff_journal_id=voucher.journal_id.id) - if reconcile: - self.reconcile_send_note(cr, uid, [voucher.id], context=context) return True def copy(self, cr, uid, id, default=None, context=None): @@ -1329,33 +1327,6 @@ class account_voucher(osv.osv): default['date'] = time.strftime('%Y-%m-%d') return super(account_voucher, self).copy(cr, uid, id, default, context) - # ----------------------------------------- - # OpenChatter notifications and need_action - # ----------------------------------------- - _document_type = { - 'sale': 'Sales Receipt', - 'purchase': 'Purchase Receipt', - 'payment': 'Supplier Payment', - 'receipt': 'Customer Payment', - False: 'Payment', - } - - def create_send_note(self, cr, uid, ids, context=None): - for obj in self.browse(cr, uid, ids, context=context): - message = "%s created." % self._document_type[obj.type or False] - self.message_post(cr, uid, [obj.id], body=message, subtype="account_voucher.mt_voucher", context=context) - - def post_send_note(self, cr, uid, ids, context=None): - for obj in self.browse(cr, uid, ids, context=context): - message = "%s '%s' is posted." % (self._document_type[obj.type or False], obj.move_id.name) - self.message_post(cr, uid, [obj.id], body=message, subtype="account_voucher.mt_voucher", context=context) - - def reconcile_send_note(self, cr, uid, ids, context=None): - for obj in self.browse(cr, uid, ids, context=context): - message = "%s reconciled." % self._document_type[obj.type or False] - self.message_post(cr, uid, [obj.id], body=message, subtype="account_voucher.mt_voucher", context=context) - -account_voucher() class account_voucher_line(osv.osv): _name = 'account.voucher.line' diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/account_voucher_data.xml index 7e11f62..11a686d 100644 --- a/addons/account_voucher/account_voucher_data.xml +++ b/addons/account_voucher/account_voucher_data.xml @@ -14,7 +14,7 @@ - + Status Change account.voucher -- 1.7.10.4