summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-09-11 19:06:22 +0200
committerChristophe Simonis <chs@odoo.com>2018-09-11 19:06:22 +0200
commit49a7295ce9ee1cfb3dd6f85989dd4cf0a98d084c (patch)
tree4e75be5576bc109d70f4d758235465a4772cbc44
parent3d09560ffc779e169ed9488e4e07928204dd234d (diff)
parent48aac01c131a8b877d9b5ab98e2730816215fd3b (diff)
[MERGE] forward port branch saas-15 up to 48aac01c131
-rw-r--r--addons/account/models/account.py6
-rw-r--r--addons/account/models/account_bank_statement.py8
-rw-r--r--doc/cla/individual/ivantodorovich.md11
-rw-r--r--odoo/addons/base/res/res_partner.py2
4 files changed, 22 insertions, 5 deletions
diff --git a/addons/account/models/account.py b/addons/account/models/account.py
index 0a274a89275..276ae945916 100644
--- a/addons/account/models/account.py
+++ b/addons/account/models/account.py
@@ -240,6 +240,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
diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py
index 54a61a986e6..1341851d3f0 100644
--- a/addons/account/models/account_bank_statement.py
+++ b/addons/account/models/account_bank_statement.py
@@ -289,7 +289,7 @@ class AccountBankStatement(models.Model):
WHERE account_id IS NULL AND stl.amount != 0.0 AND not exists (select 1 from account_move_line aml where aml.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),)
@@ -317,7 +317,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.ids),)
@@ -627,7 +627,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_repr(float_round(amount, precision_digits=precision), precision_digits=precision),
'partner_id': self.partner_id.id,
@@ -678,7 +678,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,
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 <ivan.todorovich@gmail.com> https://github.com/ivantodorovich
diff --git a/odoo/addons/base/res/res_partner.py b/odoo/addons/base/res/res_partner.py
index 88161c68e50..a96b62933a5 100644
--- a/odoo/addons/base/res/res_partner.py
+++ b/odoo/addons/base/res/res_partner.py
@@ -448,7 +448,7 @@ class Partner(models.Model):
""" 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()