diff --git a/addons/account/account.py b/addons/account/account.py index 58c4cf447ef..cfcb52a03b9 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1065,10 +1065,14 @@ 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() diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 057947205f0..282c1712d19 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -92,13 +92,43 @@ class account_invoice(osv.osv): return [('none', _('Free Reference'))] def _amount_residual(self, cr, uid, ids, name, args, context=None): + """Function of the field residua. It computes the residual amount (balance) for each invoice""" + if context is None: + context = {} + ctx = context.copy() result = {} + currency_obj = self.pool.get('res.currency') for invoice in self.browse(cr, uid, ids, context=context): + nb_inv_in_partial_rec = max_invoice_id = 0 result[invoice.id] = 0.0 if invoice.move_id: - for m in invoice.move_id.line_id: - if m.account_id.type in ('receivable','payable'): - result[invoice.id] += m.amount_residual_currency + for aml in invoice.move_id.line_id: + if aml.account_id.type in ('receivable','payable'): + if aml.currency_id and aml.currency_id.id == invoice.currency_id.id: + result[invoice.id] += aml.amount_residual_currency + else: + ctx['date'] = aml.date + result[invoice.id] += currency_obj.compute(cr, uid, aml.company_id.currency_id.id, invoice.currency_id.id, aml.amount_residual, context=ctx) + + if aml.reconcile_partial_id.line_partial_ids: + #we check if the invoice is partially reconciled and if there are other invoices + #involved in this partial reconciliation (and we sum these invoices) + for line in aml.reconcile_partial_id.line_partial_ids: + if line.invoice: + nb_inv_in_partial_rec += 1 + #store the max invoice id as for this invoice we will make a balance instead of a simple division + max_invoice_id = max(max_invoice_id, line.invoice.id) + if nb_inv_in_partial_rec: + #if there are several invoices in a partial reconciliation, we split the residual by the number + #of invoice to have a sum of residual amounts that matches the partner balance + new_value = currency_obj.round(cr, uid, invoice.currency_id, result[invoice.id] / nb_inv_in_partial_rec) + if invoice.id == max_invoice_id: + #if it's the last the invoice of the bunch of invoices partially reconciled together, we make a + #balance to avoid rounding errors + result[invoice.id] = result[invoice.id] - ((nb_inv_in_partial_rec - 1) * new_value) + else: + result[invoice.id] = new_value + #prevent the residual amount on the invoice to be less than 0 result[invoice.id] = max(result[invoice.id], 0.0) return result diff --git a/addons/account_asset/i18n/es.po b/addons/account_asset/i18n/es.po index 4d174434e55..9c7f63514ef 100644 --- a/addons/account_asset/i18n/es.po +++ b/addons/account_asset/i18n/es.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2013-03-07 08:37+0000\n" -"PO-Revision-Date: 2012-12-21 23:00+0000\n" -"Last-Translator: FULL NAME \n" +"PO-Revision-Date: 2013-05-22 09:56+0000\n" +"Last-Translator: Pedro Manuel Baeza \n" "Language-Team: Spanish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2013-03-28 05:29+0000\n" -"X-Generator: Launchpad (build 16546)\n" +"X-Launchpad-Export-Date: 2013-05-23 06:19+0000\n" +"X-Generator: Launchpad (build 16640)\n" #. module: account_asset #: view:account.asset.asset:0 @@ -295,8 +295,8 @@ msgid "" "Prorata temporis can be applied only for time method \"number of " "depreciations\"." msgstr "" -"Prorata temporis puede ser aplicado solo para método de tiempo \"numero de " -"amortizaciones\"" +"El prorrateo de tiempo sólo se puede utilizar para el método de tiempo " +"\"numero de amortizaciones\"" #. module: account_asset #: field:account.asset.depreciation.line,remaining_value:0 @@ -546,7 +546,7 @@ msgstr "General" #: field:account.asset.asset,prorata:0 #: field:account.asset.category,prorata:0 msgid "Prorata Temporis" -msgstr "Tiempo prorateado" +msgstr "Tiempo prorrateado" #. module: account_asset #: model:ir.model,name:account_asset.model_account_invoice diff --git a/addons/account_followup/account_followup_customers.xml b/addons/account_followup/account_followup_customers.xml index f15d4da9524..6a619b8aa76 100644 --- a/addons/account_followup/account_followup_customers.xml +++ b/addons/account_followup/account_followup_customers.xml @@ -95,7 +95,7 @@