bzr revid: fp@tinyerp.com-20090415161351-m90nqeu5wjl3gf4x
This commit is contained in:
Fabien Pinckaers
2009-04-15 18:13:51 +02:00
4 changed files with 74 additions and 10 deletions
@@ -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]
+17 -4
View File
@@ -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)}}
@@ -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):
@@ -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: