[MERGE] forward port branch saas-15 up to cad0be27e7
This commit is contained in:
@@ -173,6 +173,25 @@ class HrExpense(models.Model):
|
|||||||
total_currency -= line['amount_currency'] or line['price']
|
total_currency -= line['amount_currency'] or line['price']
|
||||||
return total, total_currency, account_move_lines
|
return total, total_currency, account_move_lines
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def _prepare_move_values(self):
|
||||||
|
"""
|
||||||
|
This function prepares move values related to an expense
|
||||||
|
"""
|
||||||
|
self.ensure_one()
|
||||||
|
journal = self.sheet_id.bank_journal_id if self.payment_mode == 'company_account' else self.sheet_id.journal_id
|
||||||
|
acc_date = self.sheet_id.accounting_date or self.date
|
||||||
|
move_values = {
|
||||||
|
'journal_id': journal.id,
|
||||||
|
'company_id': self.env.user.company_id.id,
|
||||||
|
'date': acc_date,
|
||||||
|
'ref': self.sheet_id.name,
|
||||||
|
# force the name to the default value, to avoid an eventual 'default_name' in the context
|
||||||
|
# to set it to '' which cause no number to be given to the account.move when posted.
|
||||||
|
'name': '/',
|
||||||
|
}
|
||||||
|
return move_values
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def action_move_create(self):
|
def action_move_create(self):
|
||||||
'''
|
'''
|
||||||
@@ -180,19 +199,9 @@ class HrExpense(models.Model):
|
|||||||
'''
|
'''
|
||||||
move_group_by_sheet = {}
|
move_group_by_sheet = {}
|
||||||
for expense in self:
|
for expense in self:
|
||||||
journal = expense.sheet_id.bank_journal_id if expense.payment_mode == 'company_account' else expense.sheet_id.journal_id
|
# create the move that will contain the accounting entries
|
||||||
#create the move that will contain the accounting entries
|
if expense.sheet_id.id not in move_group_by_sheet:
|
||||||
acc_date = expense.sheet_id.accounting_date or expense.date
|
move = self.env['account.move'].create(expense._prepare_move_values())
|
||||||
if not expense.sheet_id.id in move_group_by_sheet:
|
|
||||||
move = self.env['account.move'].create({
|
|
||||||
'journal_id': journal.id,
|
|
||||||
'company_id': self.env.user.company_id.id,
|
|
||||||
'date': acc_date,
|
|
||||||
'ref': expense.sheet_id.name,
|
|
||||||
# force the name to the default value, to avoid an eventual 'default_name' in the context
|
|
||||||
# to set it to '' which cause no number to be given to the account.move when posted.
|
|
||||||
'name': '/',
|
|
||||||
})
|
|
||||||
move_group_by_sheet[expense.sheet_id.id] = move
|
move_group_by_sheet[expense.sheet_id.id] = move
|
||||||
else:
|
else:
|
||||||
move = move_group_by_sheet[expense.sheet_id.id]
|
move = move_group_by_sheet[expense.sheet_id.id]
|
||||||
@@ -203,7 +212,7 @@ class HrExpense(models.Model):
|
|||||||
|
|
||||||
#create one more move line, a counterline for the total on payable account
|
#create one more move line, a counterline for the total on payable account
|
||||||
payment_id = False
|
payment_id = False
|
||||||
total, total_currency, move_lines = expense._compute_expense_totals(company_currency, move_lines, acc_date)
|
total, total_currency, move_lines = expense._compute_expense_totals(company_currency, move_lines, move.date)
|
||||||
if expense.payment_mode == 'company_account':
|
if expense.payment_mode == 'company_account':
|
||||||
if not expense.sheet_id.bank_journal_id.default_credit_account_id:
|
if not expense.sheet_id.bank_journal_id.default_credit_account_id:
|
||||||
raise UserError(_("No credit account found for the %s journal, please configure one.") % (expense.sheet_id.bank_journal_id.name))
|
raise UserError(_("No credit account found for the %s journal, please configure one.") % (expense.sheet_id.bank_journal_id.name))
|
||||||
@@ -236,7 +245,7 @@ class HrExpense(models.Model):
|
|||||||
'name': aml_name,
|
'name': aml_name,
|
||||||
'price': total,
|
'price': total,
|
||||||
'account_id': emp_account,
|
'account_id': emp_account,
|
||||||
'date_maturity': acc_date,
|
'date_maturity': move.date,
|
||||||
'amount_currency': diff_currency_p and total_currency or False,
|
'amount_currency': diff_currency_p and total_currency or False,
|
||||||
'currency_id': diff_currency_p and expense.currency_id.id or False,
|
'currency_id': diff_currency_p and expense.currency_id.id or False,
|
||||||
'payment_id': payment_id,
|
'payment_id': payment_id,
|
||||||
|
|||||||
@@ -437,6 +437,10 @@ class ProductTemplate(models.Model):
|
|||||||
def _is_cost_method_standard(self):
|
def _is_cost_method_standard(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@api.depends(
|
||||||
|
'product_variant_ids',
|
||||||
|
'product_variant_ids.stock_quant_ids',
|
||||||
|
)
|
||||||
def _compute_quantities(self):
|
def _compute_quantities(self):
|
||||||
res = self._compute_quantities_dict()
|
res = self._compute_quantities_dict()
|
||||||
for template in self:
|
for template in self:
|
||||||
|
|||||||
@@ -27,3 +27,4 @@ Thomas Binsfeld thomas.binsfeld@acsone.eu https://github.com/ThomasBinsfeld
|
|||||||
Benjamin Willig benjamin.willig@acsone.eu https://github.com/benwillig
|
Benjamin Willig benjamin.willig@acsone.eu https://github.com/benwillig
|
||||||
François Honoré francois.honore@acsone.eu https://github.com/acsonefho
|
François Honoré francois.honore@acsone.eu https://github.com/acsonefho
|
||||||
Denis Robinet denis.robinet@acsone.eu https://github.com/RobinetDenisAcsone
|
Denis Robinet denis.robinet@acsone.eu https://github.com/RobinetDenisAcsone
|
||||||
|
Benoit Aimont benoit.aimont@acsone.eu https://github.com/baimont
|
||||||
|
|||||||
@@ -209,11 +209,12 @@ class TestFields(common.TransactionCase):
|
|||||||
self.assertEqual(c.display_name, 'B / C')
|
self.assertEqual(c.display_name, 'B / C')
|
||||||
self.assertEqual(d.display_name, 'B / C / D')
|
self.assertEqual(d.display_name, 'B / C / D')
|
||||||
|
|
||||||
b.name = 'X'
|
# rename several records to trigger several recomputations at once
|
||||||
|
(d + c + b).write({'name': 'X'})
|
||||||
self.assertEqual(a.display_name, 'A')
|
self.assertEqual(a.display_name, 'A')
|
||||||
self.assertEqual(b.display_name, 'X')
|
self.assertEqual(b.display_name, 'X')
|
||||||
self.assertEqual(c.display_name, 'X / C')
|
self.assertEqual(c.display_name, 'X / X')
|
||||||
self.assertEqual(d.display_name, 'X / C / D')
|
self.assertEqual(d.display_name, 'X / X / X')
|
||||||
|
|
||||||
# delete b; both c and d are deleted in cascade; c should also be marked
|
# delete b; both c and d are deleted in cascade; c should also be marked
|
||||||
# to recompute, but recomputation should not fail...
|
# to recompute, but recomputation should not fail...
|
||||||
|
|||||||
@@ -1032,6 +1032,8 @@ class Field(MetaField('DummyField', (object,), {})):
|
|||||||
recs = record._recompute_check(self)
|
recs = record._recompute_check(self)
|
||||||
if recs:
|
if recs:
|
||||||
# recompute the value (only in cache)
|
# recompute the value (only in cache)
|
||||||
|
if self.recursive:
|
||||||
|
recs = record
|
||||||
self.compute_value(recs)
|
self.compute_value(recs)
|
||||||
# HACK: if result is in the wrong cache, copy values
|
# HACK: if result is in the wrong cache, copy values
|
||||||
if recs.env != env:
|
if recs.env != env:
|
||||||
|
|||||||
Reference in New Issue
Block a user