Skip to content

Commit

Permalink
[MERGE] forward port branch saas-14 up to 6b6d2c8
Browse files Browse the repository at this point in the history
  • Loading branch information
KangOl committed May 28, 2019
2 parents b1e1c78 + 6b6d2c8 commit cad0be2
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 19 deletions.
8 changes: 7 additions & 1 deletion addons/delivery/models/sale_order.py
Expand Up @@ -87,9 +87,15 @@ def _create_delivery_line(self, carrier, price_unit):
taxes_ids = self.fiscal_position_id.map_tax(taxes, carrier.product_id, self.partner_id).ids

# 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 = {
'order_id': self.id,
'name': carrier.with_context(lang=self.partner_id.lang).name,
'name': so_description,
'product_uom_qty': 1,
'product_uom': carrier.product_id.uom_id.id,
'product_id': carrier.product_id.id,
Expand Down
39 changes: 24 additions & 15 deletions addons/hr_expense/models/hr_expense.py
Expand Up @@ -168,26 +168,35 @@ def _compute_expense_totals(self, company_currency, account_move_lines, move_dat
total_currency -= line['amount_currency'] or line['price']
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
def action_move_create(self):
'''
main function that is called when trying to create the accounting entries related to an expense
'''
move_group_by_sheet = {}
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
acc_date = expense.sheet_id.accounting_date or expense.date
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': '/',
})
# create the move that will contain the accounting entries
if expense.sheet_id.id not in move_group_by_sheet:
move = self.env['account.move'].create(expense._prepare_move_values())
move_group_by_sheet[expense.sheet_id.id] = move
else:
move = move_group_by_sheet[expense.sheet_id.id]
Expand All @@ -198,7 +207,7 @@ def action_move_create(self):

#create one more move line, a counterline for the total on payable account
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 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))
Expand Down Expand Up @@ -231,7 +240,7 @@ def action_move_create(self):
'name': aml_name,
'price': total,
'account_id': emp_account,
'date_maturity': acc_date,
'date_maturity': move.date,
'amount_currency': diff_currency_p and total_currency or False,
'currency_id': diff_currency_p and expense.currency_id.id or False,
'payment_id': payment_id,
Expand Down
4 changes: 4 additions & 0 deletions addons/stock/models/product.py
Expand Up @@ -446,6 +446,10 @@ class ProductTemplate(models.Model):
relation="stock.location.route", string="Category Routes",
related='categ_id.total_route_ids')

@api.depends(
'product_variant_ids',
'product_variant_ids.stock_quant_ids',
)
def _compute_quantities(self):
res = self._compute_quantities_dict()
for template in self:
Expand Down
1 change: 1 addition & 0 deletions doc/cla/corporate/acsone.md
Expand Up @@ -27,3 +27,4 @@ Thomas Binsfeld thomas.binsfeld@acsone.eu https://github.com/ThomasBinsfeld
Benjamin Willig benjamin.willig@acsone.eu https://github.com/benwillig
François Honoré francois.honore@acsone.eu https://github.com/acsonefho
Denis Robinet denis.robinet@acsone.eu https://github.com/RobinetDenisAcsone
Benoit Aimont benoit.aimont@acsone.eu https://github.com/baimont
7 changes: 4 additions & 3 deletions odoo/addons/test_new_api/tests/test_new_fields.py
Expand Up @@ -209,11 +209,12 @@ def test_12_recursive_recompute(self):
self.assertEqual(c.display_name, 'B / C')
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(b.display_name, 'X')
self.assertEqual(c.display_name, 'X / C')
self.assertEqual(d.display_name, 'X / C / D')
self.assertEqual(c.display_name, 'X / X')
self.assertEqual(d.display_name, 'X / X / X')

def test_12_cascade(self):
""" test computed field depending on computed field """
Expand Down
2 changes: 2 additions & 0 deletions odoo/fields.py
Expand Up @@ -1052,6 +1052,8 @@ def determine_value(self, record):
recs = record._recompute_check(self)
if recs:
# recompute the value (only in cache)
if self.recursive:
recs = record
self.compute_value(recs)
# HACK: if result is in the wrong cache, copy values
if recs.env != env:
Expand Down

0 comments on commit cad0be2

Please sign in to comment.