diff --git a/addons/delivery/models/sale_order.py b/addons/delivery/models/sale_order.py index 5c0572b97f4..bc87d51b6f4 100644 --- a/addons/delivery/models/sale_order.py +++ b/addons/delivery/models/sale_order.py @@ -87,9 +87,15 @@ class SaleOrder(models.Model): 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, diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index 3740118a6e5..6c2b5a58b22 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -168,6 +168,25 @@ class HrExpense(models.Model): 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): ''' @@ -175,19 +194,9 @@ class HrExpense(models.Model): ''' 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] @@ -198,7 +207,7 @@ class HrExpense(models.Model): #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)) @@ -231,7 +240,7 @@ class HrExpense(models.Model): '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, diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index ec42b007bab..6cc0d290f77 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -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: diff --git a/doc/cla/corporate/acsone.md b/doc/cla/corporate/acsone.md index d4ee1947927..25b0e1b1c8a 100644 --- a/doc/cla/corporate/acsone.md +++ b/doc/cla/corporate/acsone.md @@ -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 diff --git a/odoo/addons/test_new_api/tests/test_new_fields.py b/odoo/addons/test_new_api/tests/test_new_fields.py index 6dc80305c7f..6b41bbec108 100644 --- a/odoo/addons/test_new_api/tests/test_new_fields.py +++ b/odoo/addons/test_new_api/tests/test_new_fields.py @@ -209,11 +209,12 @@ class TestFields(common.TransactionCase): 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 """ diff --git a/odoo/fields.py b/odoo/fields.py index 511fa0a3235..7dad4cf0f54 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -1013,6 +1013,8 @@ class Field(object): 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: