From e5206f932962e9473479ecfd4138e3188b2ebd27 Mon Sep 17 00:00:00 2001 From: pinky <> Date: Thu, 28 Dec 2006 09:30:48 +0000 Subject: [PATCH] ACCOUNT: new cash_discount on payment term\n ACCOUNT: invoice: debug product_id_change bzr revid: pinky-ba5d75544867334035140493cc12dacf90d8b886 --- addons/account/account.py | 15 ++++++++++++++- addons/account/account_view.xml | 32 ++++++++++++++++++++++++++++++++ addons/account/invoice.py | 11 +++++------ 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 71af76f7224..fd77c7605db 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -36,6 +36,18 @@ from tools.misc import currency import mx.DateTime from mx.DateTime import RelativeDateTime, now, DateTime, localtime +class account_cash_discount(osv.osv): + _name = "account.cash.discount" + _description = "Cash Discount" #A reduction in the price of an item for sale allowed if payment is made within a stipulated period. + _columns = { + 'name': fields.char('Name', size=32), + 'date': fields.date('Date', required=True), + 'discount': fields.float('Discount (%)', digits=(16,2)), + 'payment_id': fields.many2one('account.payment.term','Associated Payment Term'), + } +account_cash_discount() + + class account_payment_term(osv.osv): _name = "account.payment.term" _description = "Payment Term" @@ -43,7 +55,8 @@ class account_payment_term(osv.osv): 'name': fields.char('Payment Term', size=32), 'active': fields.boolean('Active'), 'note': fields.text('Description'), - 'line_ids': fields.one2many('account.payment.term.line', 'payment_id', 'Terms') + 'line_ids': fields.one2many('account.payment.term.line', 'payment_id', 'Terms'), + 'cash_discount_ids': fields.one2many('account.cash.discount', 'payment_id', 'Cash Discount'), } _defaults = { 'active': lambda *a: 1, diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 546e6d61f59..80c1b3bb691 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -1092,6 +1092,36 @@ + + + + + + account.cash.discount.form + account.cash.discount + form + +
+ + + + + +
+ + + account.cash.discount.tree + account.cash.discount + tree + + + + + + + + + @@ -1142,6 +1172,8 @@ + + diff --git a/addons/account/invoice.py b/addons/account/invoice.py index c5c164a569c..dff8ca71c7d 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -525,12 +525,11 @@ class account_invoice_line(osv.osv): result['account_id'] = a[0] domain = {} - if not uom: - result['product_uom'] = res.uom_id.id or False - if result['product_uom']: - res2 = self.pool.get('product.uom').read(cr, uid, [result['product_uom']], ['category_id']) - if res2 and res2[0]['category_id']: - domain = {'product_uom':[('category_id','=',res2[0]['category_id'][0])]} + result['uos_id'] = uom or res.uom_id.id or False + if result['uos_id']: + res2 = res.uom_id.category_id.id + if res2 : + domain = {'uos_id':[('category_id','=',res2 )]} return {'value':result, 'domain':domain} def move_line_get(self, cr, uid, invoice_id, context={}):