ACCOUNT, HR_TIMESHEET_INVOICE: add to_invoice to supplier invoice

bzr revid: ced-ee7364eccbfd449150f3ff9211ba0d4d4f972c17
This commit is contained in:
ced 2007-06-25 14:36:49 +00:00
parent b903472529
commit 7f462a3b63
3 changed files with 48 additions and 26 deletions

View File

@ -292,24 +292,16 @@ class account_invoice(osv.osv):
ait_obj.create(cr, uid, compute_taxes[key])
return True
def action_move_create(self, cr, uid, ids, *args):
ait_obj = self.pool.get('account.invoice.tax')
def _get_analityc_lines(self, cr, uid, id):
inv = self.browse(cr, uid, [id])[0]
cur_obj = self.pool.get('res.currency')
for inv in self.browse(cr, uid, ids):
if inv.move_id:
continue
if inv.type in ('in_invoice', 'in_refund') and abs(inv.check_total - inv.amount_total) >= (inv.currency_id.rounding/2.0):
print inv.check_total, inv.amount_total
raise osv.except_osv('Bad total !', 'Please verify the price of the invoice !\nThe real total does not match the computed total.')
company_currency = inv.company_id.currency_id.id
# create the analytical lines
line_ids = self.read(cr, uid, [inv.id], ['invoice_line'])[0]['invoice_line']
ils = self.pool.get('account.invoice.line').read(cr, uid, line_ids)
if inv.type in ('out_invoice', 'in_refund'):
sign = 1
else:
sign = -1
# one move line per invoice line
iml = self.pool.get('account.invoice.line').move_line_get(cr, uid, inv.id)
for il in iml:
if il['account_analytic_id']:
@ -325,7 +317,23 @@ class account_invoice(osv.osv):
'journal_id': self._get_journal_analytic(cr, uid, inv.type),
'ref': inv['number'],
})]
return iml
def action_move_create(self, cr, uid, ids, *args):
ait_obj = self.pool.get('account.invoice.tax')
cur_obj = self.pool.get('res.currency')
for inv in self.browse(cr, uid, ids):
if inv.move_id:
continue
if inv.type in ('in_invoice', 'in_refund') and abs(inv.check_total - inv.amount_total) >= (inv.currency_id.rounding/2.0):
print inv.check_total, inv.amount_total
raise osv.except_osv('Bad total !', 'Please verify the price of the invoice !\nThe real total does not match the computed total.')
company_currency = inv.company_id.currency_id.id
# create the analytical lines
line_ids = self.read(cr, uid, [inv.id], ['invoice_line'])[0]['invoice_line']
ils = self.pool.get('account.invoice.line').read(cr, uid, line_ids)
# one move line per invoice line
iml = self._get_analityc_lines(cr, uid, inv.id)
# check if taxes are all computed
compute_taxes = ait_obj.compute(cr, uid, inv.id)
if not inv.tax_line:

View File

@ -1,9 +1,9 @@
{
"name" : "Invoice on timesheet",
"name" : "Invoice on analytic lines",
"version" : "1.0",
"author" : "Tiny",
"category" : "Generic Modules/Human Resources",
"website" : "http://tinyerp.com/module_hr.html",
"category" : "Generic Modules/Accounting",
"website" : "http://tinyerp.com/",
"depends" : ["account",'hr_timesheet'],
"description": """
Module to generate invoices based on costs (human ressources, expenses, ...).

View File

@ -74,8 +74,7 @@ class account_analytic_line(osv.osv):
}
account_analytic_line()
class account_analytic_line(osv.osv):
_name = "hr.analytic.timesheet"
class hr_analytic_timesheet(osv.osv):
_inherit = "hr.analytic.timesheet"
def on_change_account_id(self, cr, uid, ids, account_id):
res = super(account_analytic_line,self).on_change_account_id(cr, uid, ids, account_id)
@ -85,5 +84,20 @@ class account_analytic_line(osv.osv):
st = self.pool.get('account.analytic.account').browse(cr, uid, account_id).to_invoice.id
res['value']['to_invoice'] = st or False
return res
account_analytic_line()
hr_analytic_timesheet()
class account_invoice(osv.osv):
_inherit = "account.invoice"
def _get_analityc_lines(self, cr, uid, id):
iml = super(account_invoice, self)._get_analityc_lines(cr, uid, id)
inv = self.browse(cr, uid, [id])[0]
if inv.type == 'in_invoice':
for il in iml:
if il['account_analytic_id']:
to_invoice = self.pool.get('account.analytic.account').read(cr, uid, [il['account_analytic_id']], ['to_invoice'])[0]['to_invoice']
if to_invoice:
il['analytic_lines'][0][2]['to_invoice'] = to_invoice[0]
return iml
account_invoice()