~openbig/bigconsulting/bank_statement

« back to all changes in this revision

Viewing changes to account_payment_discount_extension/account_payment_discount.py

  • Committer: aag(OpenERP)
  • Date: 2010-09-16 08:31:26 UTC
  • mfrom: (91.1.6 bigconsulting)
  • Revision ID: aag@tinyerp.co.in-20100916083126-3cpmjto2uyxt5564
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import netsvc
24
24
from osv import fields, osv
25
25
import time
26
 
from datetime import datetime
27
 
from dateutil.relativedelta import relativedelta
28
26
from mx import DateTime
29
27
 
30
28
class payment_order(osv.osv):
47
45
                payment_data = self.pool.get('account.payment.term').browse(cr, uid, inv.payment_term.id).cash_discount_ids
48
46
                if payment_data:
49
47
                    delay = payment_data[0].delay
50
 
                    self.write(cr, uid, [inv.id], {'next_payment_date':(datetime.now() + relativedelta(days=delay)).strftime('%Y-%m-%d')})
 
48
                    if inv.date_invoice:
 
49
                        date_invoice =inv.date_invoice
 
50
                    else:
 
51
                        date_invoice = time.strftime('%Y-%m-%d')
 
52
                    self.write(cr, uid, [inv.id], {'next_payment_date':(DateTime.strptime(date_invoice, '%Y-%m-%d') + DateTime.RelativeDateTime(days=delay)).strftime('%Y-%m-%d')})
51
53
        return data
52
54
        
53
55
    def _next_date(self, cr, uid, ids, context=None):
88
90
        'discount_date': fields.date('Discount Date'),
89
91
        'pay_amount': fields.float('Pay Amount'),
90
92
    }
91
 
payment_line()
 
 
b'\\ No newline at end of file'
 
93
payment_line()
 
94
 
 
95
class res_partner(osv.osv):
 
96
    _inherit = 'res.partner'
 
97
    _columns = {
 
98
        'property_customer_cash_discount_account': fields.property(
 
99
            'account.account',
 
100
            type='many2one',
 
101
            relation='account.account',
 
102
            string="Customer Cash Discount Account",
 
103
            method=True,
 
104
            view_load=True,
 
105
            domain="[('type', '=', 'receivable')]",
 
106
            required=True),
 
107
        'property_supplier_cash_discount_account': fields.property(
 
108
            'account.account',
 
109
            type='many2one',
 
110
            relation='account.account',
 
111
            string="Supplier Cash Discount Account",
 
112
            method=True,
 
113
            view_load=True,
 
114
            domain="[('type', '=', 'payable')]",
 
115
            required=True),
 
116
      }
 
117
res_partner()