[REF] account_voucher: chatter messages replaced by a track on state, with a _track...
authorThibault Delavallée <tde@openerp.com>
Tue, 18 Dec 2012 17:23:30 +0000 (18:23 +0100)
committerThibault Delavallée <tde@openerp.com>
Tue, 18 Dec 2012 17:23:30 +0000 (18:23 +0100)
bzr revid: tde@openerp.com-20121218172330-dsy8dth8reafgq2i

addons/account_voucher/account_voucher.py
addons/account_voucher/account_voucher_data.xml

index 41d3476..491f50e 100644 (file)
@@ -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 <b>created</b>." % 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 <b>posted</b>." % (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 <b>reconciled</b>." % 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'
index 7e11f62..11a686d 100644 (file)
@@ -14,7 +14,7 @@
         </record>
 
         <!-- Voucher-related subtypes for messaging / Chatter -->
-        <record id="mt_voucher" model="mail.message.subtype">
+        <record id="mt_voucher_state_change" model="mail.message.subtype">
             <field name="name">Status Change</field>
             <field name="res_model">account.voucher</field>
         </record>