[ADD]: hr_timesheet_invoice: create yaml for hr_timesheet_invoice module.
bzr revid: atp@tinyerp.co.in-20100531074135-m3eaf6rf7gul520r
This commit is contained in:
parent
b76eb08ea1
commit
a7172a010a
|
@ -44,7 +44,9 @@ reports, eso.""",
|
|||
'wizard/hr_timesheet_invoice_create_view.xml',
|
||||
'wizard/hr_timesheet_invoice_create_final_view.xml',
|
||||
],
|
||||
'demo_xml': ['hr_timesheet_invoice_demo.xml'],
|
||||
'demo_xml': ['hr_timesheet_invoice_demo.xml',
|
||||
],
|
||||
'test': ['test/test_hr_timesheet_invoice.yml'],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
'certificate': '0056091842381',
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
- |
|
||||
In order to test hr_timesheet_invoice in OpenERP, I create account line to manage invoice based on costs.
|
||||
- |
|
||||
In order to test flow, I create analytic line for sednacom analytic account.
|
||||
-
|
||||
!record {model: account.analytic.line, id: account_analytic_line_developyamlforhrmodule0}:
|
||||
account_id: account.analytic_sednacom
|
||||
amount: -1.0
|
||||
company_id: base.main_company
|
||||
date: '2010-05-30'
|
||||
general_account_id: account.a_expense
|
||||
journal_id: hr_timesheet.analytic_journal
|
||||
name: develop yaml for hr module
|
||||
product_id: hr_timesheet.product_consultant
|
||||
product_uom_id: product.uom_hour
|
||||
to_invoice: hr_timesheet_invoice.timesheet_invoice_factor2
|
||||
unit_amount: 5.00
|
||||
user_id: base.user_root
|
||||
|
||||
-
|
||||
Give partner name and price list in analytic account.
|
||||
-
|
||||
!record {model: account.analytic.account, id: account.analytic_sednacom}:
|
||||
partner_id: base.res_partner_9
|
||||
pricelist_id: product.list0
|
||||
|
||||
-
|
||||
I create invoice on analytic Line using "Invoice analytic Line" wizard.
|
||||
Give date , detail of each work , time spend on that work on this wizard.
|
||||
-
|
||||
!record {model: hr.timesheet.invoice.create, id: hr_timesheet_invoice_create_0}:
|
||||
accounts:
|
||||
- account.analytic_sednacom
|
||||
date: 1
|
||||
name: 1
|
||||
price: 1
|
||||
product: hr_timesheet.product_consultant
|
||||
time: 1
|
||||
|
||||
-
|
||||
I click on "Create Invoice" button of "Invoice analytic Line" wizard to create invoice.
|
||||
-
|
||||
!python {model: hr.timesheet.invoice.create}: |
|
||||
self.do_create(cr, uid, [ref("hr_timesheet_invoice_create_0")], {"active_ids": [ref("hr_timesheet_invoice.account_analytic_line_developyamlforhrmodule0")]})
|
||||
|
||||
- |
|
||||
I check that Invoice is create for this timesheet.
|
||||
-
|
||||
!python {model: account.analytic.line}: |
|
||||
exp = self.browse(cr, uid, [ref('account_analytic_line_developyamlforhrmodule0')])[0]
|
||||
|
||||
analytic_account_obj = self.pool.get('account.analytic.account')
|
||||
|
||||
data = self.pool.get('hr.timesheet.invoice.create').read(cr, uid, [ref("hr_timesheet_invoice_create_0")], [], context)[0]
|
||||
|
||||
account_ids = data['accounts']
|
||||
for account in analytic_account_obj.browse(cr, uid, account_ids, context):
|
||||
partner = account.partner_id.id
|
||||
|
||||
invoice_obj = self.pool.get('account.invoice')
|
||||
invoice_ids = invoice_obj.search(cr, uid, [('partner_id', '=', partner)])
|
||||
invoice_id = invoice_obj.browse(cr, uid, invoice_ids)[0]
|
||||
|
||||
for invoice in invoice_id.invoice_line:
|
||||
product = invoice.product_id.id
|
||||
|
||||
product_exp = data['product']
|
||||
|
||||
assert product == product_exp
|
||||
-
|
||||
I creating a final invoice for "Sednacom" analytic account.
|
||||
-
|
||||
!record {model: hr.timesheet.invoice.create.final, id: hr_timesheet_invoice_create_final_0}:
|
||||
balance_product: hr_timesheet.product_consultant
|
||||
date: 1
|
||||
name: 1
|
||||
price: 1
|
||||
time: 1
|
||||
-
|
||||
I click on "Create Invoice" button to create Invoice.
|
||||
-
|
||||
!python {model: hr.timesheet.invoice.create.final}: |
|
||||
self.do_create(cr, uid, [ref("hr_timesheet_invoice_create_final_0")], {"active_ids": [ref("account.analytic_sednacom")]})
|
||||
|
||||
|
||||
- |
|
||||
I can also make some theoretical revenue reports.
|
||||
- |
|
||||
I can also see timesheet profit using Timesheet profit report.
|
|
@ -71,8 +71,8 @@ class hr_timesheet_invoice_create(osv.osv_memory):
|
|||
|
||||
result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
|
||||
res = mod_obj.read(cr, uid, result, ['res_id'])
|
||||
|
||||
data = self.read(cr, uid, ids, [], context)[0]
|
||||
|
||||
account_ids = data['accounts']
|
||||
for account in analytic_account_obj.browse(cr, uid, account_ids, context):
|
||||
partner = account.partner_id
|
||||
|
@ -119,11 +119,11 @@ class hr_timesheet_invoice_create(osv.osv_memory):
|
|||
"GROUP BY product_id,to_invoice", (account.id,context['active_ids'],))
|
||||
|
||||
for product_id,factor_id,qty in cr.fetchall():
|
||||
product = pool.get('product.product').browse(cr, uid, product_id, context2)
|
||||
product = self.pool.get('product.product').browse(cr, uid, product_id, context2)
|
||||
if not product:
|
||||
raise osv.except_osv(_('Error'), _('At least one line has no product !'))
|
||||
factor_name = ''
|
||||
factor = pool.get('hr_timesheet_invoice.factor').browse(cr, uid, factor_id, context2)
|
||||
factor = self.pool.get('hr_timesheet_invoice.factor').browse(cr, uid, factor_id, context2)
|
||||
|
||||
if not data['product']:
|
||||
if factor.customer_name:
|
||||
|
@ -131,16 +131,16 @@ class hr_timesheet_invoice_create(osv.osv_memory):
|
|||
else:
|
||||
factor_name = product.name
|
||||
else:
|
||||
factor_name = pool.get('product.product').name_get(cr, uid, [data['product']], context=context)[0][1]
|
||||
factor_name = self.pool.get('product.product').name_get(cr, uid, [data['product']], context=context)[0][1]
|
||||
|
||||
if account.pricelist_id:
|
||||
pl = account.pricelist_id.id
|
||||
price = pool.get('product.pricelist').price_get(cr,uid,[pl], data['product'] or product_id, qty or 1.0, account.partner_id.id)[pl]
|
||||
price = self.pool.get('product.pricelist').price_get(cr,uid,[pl], data['product'] or product_id, qty or 1.0, account.partner_id.id)[pl]
|
||||
else:
|
||||
price = 0.0
|
||||
|
||||
taxes = product.taxes_id
|
||||
tax = pool.get('account.fiscal.position').map_tax(cr, uid, account.partner_id.property_account_position, taxes)
|
||||
tax = self.pool.get('account.fiscal.position').map_tax(cr, uid, account.partner_id.property_account_position, taxes)
|
||||
account_id = product.product_tmpl_id.property_account_income.id or product.categ_id.property_account_income_categ.id
|
||||
curr_line = {
|
||||
'price_unit': price,
|
||||
|
@ -159,7 +159,7 @@ class hr_timesheet_invoice_create(osv.osv_memory):
|
|||
#
|
||||
# Compute for lines
|
||||
#
|
||||
cr.execute("SELECT * FROM account_analytic_line WHERE account_id = %s and id = ANY (%s) AND product_id=%s and to_invoice=%s", (account.id, data['ids'], product_id, factor_id))
|
||||
cr.execute("SELECT * FROM account_analytic_line WHERE account_id = %s and id = %s AND product_id=%s and to_invoice=%s", (account.id, data['id'], product_id, factor_id))
|
||||
|
||||
line_ids = cr.dictfetchall()
|
||||
note = []
|
||||
|
@ -170,7 +170,7 @@ class hr_timesheet_invoice_create(osv.osv_memory):
|
|||
details.append(line['date'])
|
||||
if data['time']:
|
||||
if line['product_uom_id']:
|
||||
details.append("%s %s" % (line['unit_amount'], pool.get('product.uom').browse(cr, uid, [line['product_uom_id']])[0].name))
|
||||
details.append("%s %s" % (line['unit_amount'], self.pool.get('product.uom').browse(cr, uid, [line['product_uom_id']])[0].name))
|
||||
else:
|
||||
details.append("%s" % (line['unit_amount'], ))
|
||||
if data['name']:
|
||||
|
@ -180,8 +180,8 @@ class hr_timesheet_invoice_create(osv.osv_memory):
|
|||
note.append(u' - '.join(map(lambda x: unicode(x) or '',details)))
|
||||
|
||||
curr_line['note'] = "\n".join(map(lambda x: unicode(x) or '',note))
|
||||
pool.get('account.invoice.line').create(cr, uid, curr_line)
|
||||
cr.execute("update account_analytic_line set invoice_id=%s WHERE account_id = %s and id =ANY(%s)" ,(last_invoice, account.id,data['ids']))
|
||||
self.pool.get('account.invoice.line').create(cr, uid, curr_line)
|
||||
cr.execute("update account_analytic_line set invoice_id=%s WHERE account_id = %s and id =%s" ,(last_invoice, account.id,data['id']))
|
||||
|
||||
self.pool.get('account.invoice').button_reset_taxes(cr, uid, [last_invoice], context)
|
||||
|
||||
|
|
Loading…
Reference in New Issue