raise osv.except_osv(_('Error!'), _('You should choose the periods that belong to the same company.'))
if period_date_start > period_date_stop:
raise osv.except_osv(_('Error!'), _('Start period should precede then end period.'))
+
+ # /!\ We do not include a criterion on the company_id field below, to allow producing consolidated reports
+ # on multiple companies. It will only work when start/end periods are selected and no fiscal year is chosen.
+
#for period from = january, we want to exclude the opening period (but it has same date_from, so we have to check if period_from is special or not to include that clause or not in the search).
if period_from.special:
- return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop), ('company_id', '=', company1_id)])
- return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop), ('company_id', '=', company1_id), ('special', '=', False)])
+ return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop)])
+ return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop), ('special', '=', False)])
-account_period()
class account_journal_period(osv.osv):
_name = "account.journal.period"
]
_order = 'code'
-account_tax_code()
+ def get_precision_tax():
+ def change_digit_tax(cr):
- res = pooler.get_pool(cr.dbname).get('decimal.precision').precision_get(cr, SUPERUSER_ID, 'Account')
++ res = openerp.registry(cr.dbname)['decimal.precision'].precision_get(cr, SUPERUSER_ID, 'Account')
+ return (16, res+3)
+ return change_digit_tax
+
class account_tax(osv.osv):
"""
A tax object.
res[expense.id] = total
return res
+ def _get_expense_from_line(self, cr, uid, ids, context=None):
+ return [line.expense_id.id for line in self.pool.get('hr.expense.line').browse(cr, uid, ids, context=context)]
+
def _get_currency(self, cr, uid, context=None):
user = self.pool.get('res.users').browse(cr, uid, [uid], context=context)[0]
- if user.company_id:
- return user.company_id.currency_id.id
- else:
- return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)], context=context)[0]
+ return user.company_id.currency_id.id
_name = "hr.expense.expense"
_inherit = ['mail.thread']
res['value'].update({'uom_id': product.uom_id.id})
return res
-hr_expense_line()
+ class account_move_line(osv.osv):
+ _inherit = "account.move.line"
+
+ def reconcile(self, cr, uid, ids, type='auto', writeoff_acc_id=False, writeoff_period_id=False, writeoff_journal_id=False, context=None):
+ res = super(account_move_line, self).reconcile(cr, uid, ids, type=type, writeoff_acc_id=writeoff_acc_id, writeoff_period_id=writeoff_period_id, writeoff_journal_id=writeoff_journal_id, context=context)
+ #when making a full reconciliation of account move lines 'ids', we may need to recompute the state of some hr.expense
+ account_move_ids = [aml.move_id.id for aml in self.browse(cr, uid, ids, context=context)]
+ expense_obj = self.pool.get('hr.expense.expense')
+ currency_obj = self.pool.get('res.currency')
+ if account_move_ids:
+ expense_ids = expense_obj.search(cr, uid, [('account_move_id', 'in', account_move_ids)], context=context)
+ for expense in expense_obj.browse(cr, uid, expense_ids, context=context):
+ if expense.state == 'done':
+ #making the postulate it has to be set paid, then trying to invalidate it
+ new_status_is_paid = True
+ for aml in expense.account_move_id.line_id:
+ if aml.account_id.type == 'payable' and not currency_obj.is_zero(cr, uid, expense.company_id.currency_id, aml.amount_residual):
+ new_status_is_paid = False
+ if new_status_is_paid:
+ expense_obj.write(cr, uid, [expense.id], {'state': 'paid'}, context=context)
+ return res
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
<button name="refuse" states="confirm,accepted" string="Refuse" type="workflow" groups="base.group_hr_user" />
<button name="draft" states="confirm,cancelled" string="Set to Draft" type="workflow" groups="base.group_hr_user" />
<button name="done" states="accepted" string="Generate Accounting Entries" type="workflow" groups="account.group_account_invoice" class="oe_highlight"/>
- <button name="action_view_receipt" states="done" string="Open Accounting Entries" type="object" groups="account.group_account_invoice"/>
+ <button name="action_view_move" states="done" string="Open Accounting Entries" type="object" groups="account.group_account_invoice"/>
- <field name="state" widget="statusbar" statusbar_visible="draft,confirm,accepted,done" statusbar_colors='{"confirm":"blue","cancelled":"red"}'/>
+ <field name="state" widget="statusbar" statusbar_visible="draft,confirm,accepted,done,paid" statusbar_colors='{"confirm":"blue","cancelled":"red"}'/>
</header>
<sheet>
<group>