From 6d36343d5df7b344d4b05eb6941b3be339939959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Todorovich?= Date: Tue, 4 Sep 2018 21:41:35 -0300 Subject: [PATCH 1/5] [CLA] Signature for ivantodorovich --- doc/cla/individual/ivantodorovich.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 doc/cla/individual/ivantodorovich.md diff --git a/doc/cla/individual/ivantodorovich.md b/doc/cla/individual/ivantodorovich.md new file mode 100644 index 00000000000..d3352e4a1f7 --- /dev/null +++ b/doc/cla/individual/ivantodorovich.md @@ -0,0 +1,11 @@ +Argentina, 2018-09-04 + +I hereby agree to the terms of the Odoo Individual Contributor License +Agreement v1.0. + +I declare that I am authorized and able to make this agreement and sign this +declaration. + +Signed, + +Ivan Todorovich https://github.com/ivantodorovich From 8781286f1c35a7ee97bbb76c7933f24c8afaab43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Todorovich?= Date: Tue, 4 Sep 2018 21:31:16 -0300 Subject: [PATCH 2/5] [FIX] account: multi-company bank statement reconciliation In a multicompany environment, if the user is not logged-in in the same company as the statement's company (even though he might have access to it), the reconcile interface was filtering on the user's company instead of the bank statement lines's company. Was PR #26782 --- addons/account/models/account_bank_statement.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index e60c0dc09d4..cd9d6d70717 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -298,7 +298,7 @@ class AccountBankStatement(models.Model): WHERE account_id IS NULL AND not exists (select 1 from account_move m where m.statement_line_id = stl.id) AND company_id = %s """ - params = (self.env.user.company_id.id,) + params = (self.company_id.id,) if statements: sql_query += ' AND stl.statement_id IN %s' params += (tuple(statements.ids),) @@ -323,7 +323,7 @@ class AccountBankStatement(models.Model): ) AND aml.ref IN %s """ - params = (self.env.user.company_id.id, (st_lines_left[0].journal_id.default_credit_account_id.id, st_lines_left[0].journal_id.default_debit_account_id.id), tuple(refs)) + params = (self.company_id.id, (st_lines_left[0].journal_id.default_credit_account_id.id, st_lines_left[0].journal_id.default_debit_account_id.id), tuple(refs)) if statements: sql_query += 'AND stl.id IN %s' params += (tuple(stl_to_assign_partner),) @@ -620,7 +620,7 @@ class AccountBankStatementLine(models.Model): st_line_currency = self.currency_id or self.journal_id.currency_id currency = (st_line_currency and st_line_currency != company_currency) and st_line_currency.id or False precision = st_line_currency and st_line_currency.decimal_places or company_currency.decimal_places - params = {'company_id': self.env.user.company_id.id, + params = {'company_id': self.company_id.id, 'account_payable_receivable': (self.journal_id.default_credit_account_id.id, self.journal_id.default_debit_account_id.id), 'amount': float_round(amount, precision_digits=precision), 'partner_id': self.partner_id.id, @@ -671,7 +671,7 @@ class AccountBankStatementLine(models.Model): st_line_currency = self.currency_id or self.journal_id.currency_id currency = (st_line_currency and st_line_currency != company_currency) and st_line_currency.id or False precision = st_line_currency and st_line_currency.decimal_places or company_currency.decimal_places - params = {'company_id': self.env.user.company_id.id, + params = {'company_id': self.company_id.id, 'account_payable_receivable': (self.journal_id.default_credit_account_id.id, self.journal_id.default_debit_account_id.id), 'amount': float_round(amount, precision_digits=precision), 'partner_id': self.partner_id.id, From 415aa058069d394355d29bf6c7db6f8aeac95170 Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Tue, 11 Sep 2018 14:53:54 +0200 Subject: [PATCH 3/5] [IMP] account: add error when setting a foreign currency on account If currency set on account, all journal items part of this account must have either the same currency or no currency. --- addons/account/models/account.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index ef611962da9..6ceb5ba19b1 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -167,6 +167,12 @@ class AccountAccount(models.Model): move_lines = self.env['account.move.line'].search([('account_id', 'in', self.ids)], limit=1) if len(move_lines): raise UserError(_('You cannot change the value of the reconciliation on this account as it already has some moves')) + + if vals.get('currency_id'): + for account in self: + if self.env['account.move.line'].search_count([('account_id', '=', account.id), ('currency_id', 'not in', (False, vals['currency_id']))]): + raise UserError(_('You cannot set a currency on this account as it already has some journal entries having a different foreign currency.')) + return super(AccountAccount, self).write(vals) @api.multi From dc9b3df431c0c971b73870bcb9eaf90c07a84da8 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 10 Sep 2018 18:10:26 +0200 Subject: [PATCH 4/5] [FIX] calendar: keep recurring after edited one Since 76b7242 if we have a recurring event with 3 occurences: [4th 4:00-4th 5:00] [14th 4:00-14th 5:00] [24th 4:00-24th 4:00] And we detach the first one to modify it, then when getting the info of reccurring events not detached the system get: - starts: [14th 4:00] [24th 4:00] - stops: [4th 5:00] [14th 5:00] [24th 5:00] And wrongly apply the current filtering over: [14th 4:00-4th 5:00] [24th 4:00-14th 5:00] So the issue hides recurrences of event wrongly if: - they have not been detached - they don't have a duration of 0 - one or several previous events have been detached - the stop date of the nth previous event occurrence (nth equaling number of detached previous events) is not in the current filtering. With this change, the stops are also filtered based on start of occurrence + duration. Without the change, the added test fails with: False != '155-20120301120100' : Last event should be found searching it by date range note: for 10.0 up to not including 11.0 which is solved with #26901 opw-1866151 closes #26887 --- addons/calendar/models/calendar.py | 5 ++++- .../test_calendar_recurrent_event_case2.py | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py index 8929eb30c3a..0653621ed96 100644 --- a/addons/calendar/models/calendar.py +++ b/addons/calendar/models/calendar.py @@ -563,7 +563,10 @@ class Meeting(models.Model): recurring_meetings = self.search([('recurrent_id', '=', self.id), '|', ('active', '=', False), ('active', '=', True)]) for meeting in recurring_meetings: - rset1._exdate.append(todate(meeting.recurrent_id_date)) + date = todate(meeting.recurrent_id_date) + if date_field == 'stop': + date = date + timedelta(hours=self.duration) + rset1._exdate.append(date) return [d.astimezone(pytz.UTC) if d.tzinfo else d for d in rset1] @api.multi diff --git a/addons/calendar/tests/test_calendar_recurrent_event_case2.py b/addons/calendar/tests/test_calendar_recurrent_event_case2.py index 892c0ffe2aa..bd6ad89e212 100644 --- a/addons/calendar/tests/test_calendar_recurrent_event_case2.py +++ b/addons/calendar/tests/test_calendar_recurrent_event_case2.py @@ -85,14 +85,23 @@ class TestRecurrentEvent(common.TransactionCase): for meeting in meetings: self.assertEqual(meeting.name, 'Sprint Review for google modules', 'Name not changed for id: %s' % meeting.id) + # I detach first occurrence to check it is not modified by changing recurrent event. + min(meetings, key=lambda m: m.start).detach_recurring_event() + # I change description of my weekly meeting Review code with programmer. idval = '%d-%s' % (self.calendar_event_sprint_review.id, '20110425124700') self.CalendarEvent.browse(idval).write({'description': 'Review code of the module: sync_google_calendar.'}) - # I check whether that all the records of this recurrence has been edited. - meetings = self.CalendarEvent.search([('recurrent_id', '=', self.calendar_event_sprint_review.id)]) - for meeting in meetings: - self.assertEqual(meeting.description, 'Review code of the module: sync_google_calendar.', 'Description not changed for id: %s' % meeting.id) + # I check that detached event has not been edited. + detached_meeting = self.CalendarEvent.search([('recurrent_id', '=', self.calendar_event_sprint_review.id)]) + self.assertEqual(detached_meeting.description, False, 'Detached event description changed for id: %s' % meeting.id) + + # I verify wether I find an event by date range when subsequent to a detached one. + last_meeting = max(meetings, key=lambda m: m.start) + meetings = self.CalendarEvent.with_context({'virtual_id': True}).search([ + ('start', '<=', last_meeting.stop), ('stop', '>=', last_meeting.start) + ]) + self.assertEqual(meetings.id, last_meeting.id, 'Last event should be found searching it by date range') # I update the description of two meetings, and check that both have been updated self.calendar_event_sprint_review.write({'description': "Some description"}) From cd66b0984ee47d437fda7dd5e957df5fe27e95a3 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 11 Sep 2018 17:08:14 +0200 Subject: [PATCH 5/5] [FIX] base: only sync partners when `type` change --- odoo/addons/base/res/res_partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/addons/base/res/res_partner.py b/odoo/addons/base/res/res_partner.py index 2f47cf925d0..a222cbc8526 100644 --- a/odoo/addons/base/res/res_partner.py +++ b/odoo/addons/base/res/res_partner.py @@ -443,7 +443,7 @@ class Partner(models.Model, FormatAddress): """ Sync commercial fields and address fields from company and to children after create/update, just as if those were all modeled as fields.related to the parent """ # 1. From UPSTREAM: sync from parent - if values.get('parent_id') or values.get('type', 'contact'): + if values.get('parent_id') or values.get('type') == 'contact': # 1a. Commercial fields: sync if parent changed if values.get('parent_id'): self._commercial_sync_from_company()