From b0e5e6ffd46ca23824bcd14cdc5619f4e437622f Mon Sep 17 00:00:00 2001 From: husen daudi Date: Wed, 15 Apr 2009 10:26:13 +0530 Subject: [PATCH 1/3] Bugfix 361304 lp bug: https://launchpad.net/bugs/361304 fixed bzr revid: hda@hda-20090415045613-wfipffaak1xgrogo --- addons/report_account/report_receivable.py | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/addons/report_account/report_receivable.py b/addons/report_account/report_receivable.py index 61fb577a3f4..e7da923bd85 100644 --- a/addons/report_account/report_receivable.py +++ b/addons/report_account/report_receivable.py @@ -151,5 +151,57 @@ class report_aged_receivable(osv.osv): report_aged_receivable() +class report_invoice_created(osv.osv): + _name = "report.invoice.created" + _description = "Report of Invoices Created within Last 15 days" + _auto = False + _columns = { + 'name': fields.char('Description', size=64, readonly=True), + 'type': fields.selection([ + ('out_invoice','Customer Invoice'), + ('in_invoice','Supplier Invoice'), + ('out_refund','Customer Refund'), + ('in_refund','Supplier Refund'), + ],'Type', readonly=True), + 'number': fields.char('Invoice Number', size=32, readonly=True), + 'partner_id': fields.many2one('res.partner', 'Partner', readonly=True), + 'amount_untaxed': fields.float('Untaxed', readonly=True), + 'amount_total': fields.float('Total', readonly=True), + 'currency_id': fields.many2one('res.currency', 'Currency', readonly=True), + 'date_invoice': fields.date('Date Invoiced', readonly=True), + 'date_due': fields.date('Due Date', readonly=True), + 'residual': fields.float('Residual', readonly=True), + 'state': fields.selection([ + ('draft','Draft'), + ('proforma','Pro-forma'), + ('proforma2','Pro-forma'), + ('open','Open'), + ('paid','Done'), + ('cancel','Cancelled') + ],'State', readonly=True), + 'origin': fields.char('Origin', size=64, readonly=True), + 'create_date' : fields.datetime('Create Date', readonly=True) + } + _order = 'create_date' + + def init(self, cr): + cr.execute("""create or replace view report_invoice_created as ( + select + inv.id as id, inv.name as name, inv.type as type, + inv.number as number, inv.partner_id as partner_id, + inv.amount_untaxed as amount_untaxed, + inv.amount_total as amount_total, inv.currency_id as currency_id, + inv.date_invoice as date_invoice, inv.date_due as date_due, + inv.residual as residual, inv.state as state, + inv.origin as origin, inv.create_date as create_date + from + account_invoice inv + where + (to_date(to_char(inv.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') <= CURRENT_DATE) + AND + (to_date(to_char(inv.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') > (CURRENT_DATE-15)) + )""") +report_invoice_created() + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From ab164fe02228836497d1ba838baefd6e70f362f6 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 15 Apr 2009 10:57:38 +0200 Subject: [PATCH 2/3] [FIX] base_vat: implement a generic check of vat numbers bzr revid: christophe@tinyerp.com-20090415085738-b1jow8m2dh5tf9uf --- addons/base_vat/partner.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/addons/base_vat/partner.py b/addons/base_vat/partner.py index 408fb39f9cd..124c289803a 100644 --- a/addons/base_vat/partner.py +++ b/addons/base_vat/partner.py @@ -22,6 +22,8 @@ from osv import osv from osv import fields +import string +from tools.func import partial def mult_add(i, j): """Sum each digits of the multiplication of i and j.""" @@ -39,15 +41,26 @@ class res_partner(osv.osv): if not partner.vat: continue #FIXME return False? empty vat numbre is invalid? - vat_country, vat_number = partner.vat[:2].lower(), partner.vat[2:] - if vat_number.find(' ') != -1: - return False - check = getattr(self, 'check_vat_' + vat_country, lambda vn: False) + vat_country, vat_number = partner.vat[:2].lower(), partner.vat[2:].replace(' ', '') + check = getattr(self, 'check_vat_' + vat_country) if not check(vat_number): return False return True + def __getattr__(self, attr): + if not attr.startswith('check_vat_'): + super(res_partner, self).__getattr__(attr) + + def default_vat_check(self, cn, vn): + # by default, a VAT number is valid if: + # it starts with 2 letters + # has more than 3 characters + return len(vn) > 0 and len(cn) == 2 and cn[0] in string.ascii_lowercase and cn[1] in string.ascii_lowercase + + return partial(default_vat_check, self, attr[10:]) + + def vat_change(self, cr, uid, ids, value, context={}): return {'value': {'vat_subjected': bool(value)}} From 7b496b57b53ceedd888faa724933ed11164844b4 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Wed, 15 Apr 2009 19:33:32 +0530 Subject: [PATCH 3/3] [FIX] Bug 361540 : Analytic_journal_billing rate and project_timesheet corrected bzr revid: jvo@tinyerp.com-20090415140332-4tz8hs11s1tmt08s --- .../analytic_journal_billing_rate.py | 4 ++-- addons/project_timesheet/project_timesheet.py | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/addons/analytic_journal_billing_rate/analytic_journal_billing_rate.py b/addons/analytic_journal_billing_rate/analytic_journal_billing_rate.py index 22e26a87402..d83df50ebd1 100644 --- a/addons/analytic_journal_billing_rate/analytic_journal_billing_rate.py +++ b/addons/analytic_journal_billing_rate/analytic_journal_billing_rate.py @@ -48,7 +48,7 @@ class hr_analytic_timesheet(osv.osv): _inherit = "hr.analytic.timesheet" - def on_change_account_id(self, cr, uid, ids, user_id, account_id, unit_amount=0, journal_id=0): + def on_change_account_id(self, cr, uid, ids, account_id, user_id=False, unit_amount=0, journal_id=0): res = {} if not (account_id): #avoid a useless call to super @@ -62,7 +62,7 @@ class hr_analytic_timesheet(osv.osv): if not temp: #if there isn't any record for this journal_id and account_id - return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,account_id,user_id, unit_amount) + return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,account_id,user_id, unit_amount) else: #get the old values from super and add the value from the new relation analytic_journal_rate_grid r = self.pool.get('analytic_journal_rate_grid').browse(cr, uid, temp)[0] diff --git a/addons/project_timesheet/project_timesheet.py b/addons/project_timesheet/project_timesheet.py index ec53bddfb26..71c3542c010 100644 --- a/addons/project_timesheet/project_timesheet.py +++ b/addons/project_timesheet/project_timesheet.py @@ -59,9 +59,9 @@ class project_work(osv.osv): vals_line['user_id'] = vals['user_id'] vals_line['date'] = vals['date'][:10] vals_line['unit_amount'] = vals['hours'] - vals_line['account_id'] = obj_task.project_id.category_id.id - res = obj.on_change_account_id(cr, uid, False, obj_task.project_id.category_id.id) - print 'Got', res + acc_id = obj_task.project_id.category_id.id + vals_line['account_id'] = acc_id + res = obj.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = a @@ -109,7 +109,6 @@ class project_work(osv.osv): 'hr_analytic_timesheet_id':fields.integer('Related Timeline Id') } - project_work() class project_project(osv.osv):