_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([
('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 \
'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')
'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.
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):
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'