[MERGE] forward port branch 10.0 up to 01020e18e9
This commit is contained in:
@@ -87,9 +87,15 @@ class SaleOrder(models.Model):
|
|||||||
taxes_ids = self.fiscal_position_id.map_tax(taxes, carrier.product_id, self.partner_id).ids
|
taxes_ids = self.fiscal_position_id.map_tax(taxes, carrier.product_id, self.partner_id).ids
|
||||||
|
|
||||||
# Create the sales order line
|
# Create the sales order line
|
||||||
|
carrier_with_partner_lang = carrier.with_context(lang=self.partner_id.lang)
|
||||||
|
if carrier_with_partner_lang.product_id.description_sale:
|
||||||
|
so_description = '%s: %s' % (carrier_with_partner_lang.name,
|
||||||
|
carrier_with_partner_lang.product_id.description_sale)
|
||||||
|
else:
|
||||||
|
so_description = carrier_with_partner_lang.name
|
||||||
values = {
|
values = {
|
||||||
'order_id': self.id,
|
'order_id': self.id,
|
||||||
'name': carrier.with_context(lang=self.partner_id.lang).name,
|
'name': so_description,
|
||||||
'product_uom_qty': 1,
|
'product_uom_qty': 1,
|
||||||
'product_uom': carrier.product_id.uom_id.id,
|
'product_uom': carrier.product_id.uom_id.id,
|
||||||
'product_id': carrier.product_id.id,
|
'product_id': carrier.product_id.id,
|
||||||
|
|||||||
@@ -168,6 +168,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):
|
||||||
'''
|
'''
|
||||||
@@ -175,19 +194,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]
|
||||||
@@ -198,7 +207,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))
|
||||||
@@ -231,7 +240,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,
|
||||||
|
|||||||
@@ -446,6 +446,10 @@ class ProductTemplate(models.Model):
|
|||||||
relation="stock.location.route", string="Category Routes",
|
relation="stock.location.route", string="Category Routes",
|
||||||
related='categ_id.total_route_ids')
|
related='categ_id.total_route_ids')
|
||||||
|
|
||||||
|
@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')
|
||||||
|
|
||||||
def test_12_cascade(self):
|
def test_12_cascade(self):
|
||||||
""" test computed field depending on computed field """
|
""" test computed field depending on computed field """
|
||||||
|
|||||||
@@ -1013,6 +1013,8 @@ class Field(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