[MERGE] forward port branch saas-15 up to 48aac01c13

This commit is contained in:
Christophe Simonis
2018-09-11 19:06:22 +02:00
4 changed files with 22 additions and 5 deletions
+6
View File
@@ -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
@@ -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,
+11
View File
@@ -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
+1 -1
View File
@@ -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()