[FORWARD] Forward port of addons 7.0 until revision 9172
authorThibault Delavallée <tde@openerp.com>
Tue, 28 May 2013 10:45:00 +0000 (12:45 +0200)
committerThibault Delavallée <tde@openerp.com>
Tue, 28 May 2013 10:45:00 +0000 (12:45 +0200)
bzr revid: tde@openerp.com-20130528104500-ds3irrs2u0qpst37

1  2 
addons/account/account.py
addons/account/account_invoice.py
addons/account_followup/account_followup_customers.xml
addons/auth_signup/static/src/js/auth_signup.js
addons/base_vat/base_vat.py
addons/hr_expense/hr_expense.py
addons/hr_expense/hr_expense_view.xml
addons/mail/static/src/js/mail.js
addons/project_issue/project_issue.py
addons/sale/sale.py
addons/sale_stock/sale_stock.py

@@@ -1059,11 -1065,16 +1059,15 @@@ class account_period(osv.osv)
              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"
@@@ -1853,7 -1869,14 +1857,13 @@@ class account_tax_code(osv.osv)
      ]
      _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.
Simple merge
Simple merge
@@@ -52,15 -53,9 +52,12 @@@ class hr_expense_expense(osv.osv)
              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']
@@@ -448,5 -454,28 +455,27 @@@ class hr_expense_line(osv.osv)
              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:
@@@ -67,8 -67,8 +67,8 @@@
                      <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>
Simple merge
Simple merge
Simple merge
Simple merge