From ff613d8763655c57e0b179df4059bf5fe9490886 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 26 Jan 2017 09:44:57 +0100 Subject: [PATCH 01/15] [FIX] hr: correctly format mention partner suggestions Rev. 36f6f26 changed the format of the returned list of employees. Javascript is expecting an array containing the array of employees, each employee being a dict with keys id, name, email. But from rev. 36f6f26, it returned an array of employees, themselves represented by an array containing their id, name and email. As the format changed, the Javascript mention mechanism never used the prefetched employees, and always fallbacked on an RPC to fetch suggestions amongs all partners. --- addons/hr/res_partner.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/hr/res_partner.py b/addons/hr/res_partner.py index 5f85ce66186..aa9aa516b66 100644 --- a/addons/hr/res_partner.py +++ b/addons/hr/res_partner.py @@ -14,8 +14,9 @@ class Partner(models.Model): try: employee_group = self.env.ref('base.group_user') - for user in employee_group.users: - suggestions.append((user.partner_id.id, user.name, user.email)) + hr_suggestions = [{'id': user.partner_id.id, 'name': user.name, 'email': user.email} + for user in employee_group.users] + suggestions.append(hr_suggestions) return suggestions except AccessError: return suggestions From 4232a081640134eaced9c89834a5e15ee1c7362b Mon Sep 17 00:00:00 2001 From: "Adrien Peiffer (ACSONE)" Date: Thu, 26 Jan 2017 10:29:04 +0100 Subject: [PATCH 02/15] [FIX] mass_mailing: ondelete cascade on transient The test wizard will be dropped eventually but it is not possible to delete the mass-mailing before the transient is cleaned too due to the required field. To make it faster, add a ondelete cascade on the field. Closes #15217 --- addons/mass_mailing/wizard/test_mailing.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mass_mailing/wizard/test_mailing.py b/addons/mass_mailing/wizard/test_mailing.py index 20c57f80609..ea570ebb755 100644 --- a/addons/mass_mailing/wizard/test_mailing.py +++ b/addons/mass_mailing/wizard/test_mailing.py @@ -11,7 +11,8 @@ class TestMassMailing(osv.TransientModel): _columns = { 'email_to': fields.char('Recipients', required=True, help='Comma-separated list of email addresses.'), - 'mass_mailing_id': fields.many2one('mail.mass_mailing', 'Mailing', required=True), + 'mass_mailing_id': fields.many2one( + 'mail.mass_mailing', 'Mailing', required=True, ondelete='cascade'), } _defaults = { From cfcc37bca50baf43843ac938ea26cf23d7a30b25 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Thu, 26 Jan 2017 08:34:41 +0100 Subject: [PATCH 03/15] [FIX] expression: leaf in o2m with m2o inherits'd field The reverse field of a one2many could be originating from an inherits'd field, this was solved in some instance with f5e5bbda. The issue could still happen in some instances when doing a comparison of: - the one2many field to a False value, - the one2many with a negative operator and an empty set to negate, With this change, the ORM is used in such a situation. closes #15234 opw-704962 --- openerp/addons/test_inherit/tests/test_inherit.py | 6 ++++++ openerp/osv/expression.py | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/openerp/addons/test_inherit/tests/test_inherit.py b/openerp/addons/test_inherit/tests/test_inherit.py index f6057817ee4..8e12b0b7e08 100644 --- a/openerp/addons/test_inherit/tests/test_inherit.py +++ b/openerp/addons/test_inherit/tests/test_inherit.py @@ -74,6 +74,12 @@ class test_inherits(common.TransactionCase): self.assertIn(daughter, partner_demo.daughter_ids) # search the partner from the daughter record + partners = self.env['res.partner'].search([('daughter_ids', 'like', 'not existing daugther')]) + self.assertFalse(partners) + partners = self.env['res.partner'].search([('daughter_ids', 'not like', 'not existing daugther')]) + self.assertIn(partner_demo, partners) + partners = self.env['res.partner'].search([('daughter_ids', '!=', False)]) + self.assertIn(partner_demo, partners) partners = self.env['res.partner'].search([('daughter_ids', 'in', daughter.ids)]) self.assertIn(partner_demo, partners) diff --git a/openerp/osv/expression.py b/openerp/osv/expression.py index f29fc8f7084..2be571e538c 100644 --- a/openerp/osv/expression.py +++ b/openerp/osv/expression.py @@ -981,7 +981,14 @@ class expression(object): if call_null: o2m_op = 'in' if operator in NEGATIVE_TERM_OPERATORS else 'not in' - push(create_substitution_leaf(leaf, ('id', o2m_op, select_distinct_from_where_not_null(cr, column._fields_id, comodel._table)), model)) + # determine ids from column._fields_id + if comodel._fields[column._fields_id].store: + ids1 = select_distinct_from_where_not_null(cr, column._fields_id, comodel._table) + else: + ids2 = comodel.search(cr, uid, [(column._fields_id, '!=', False)], context=context) + recs = comodel.browse(cr, SUPERUSER_ID, ids2, {'prefetch_fields': False}) + ids1 = recs.mapped(column._fields_id).ids + push(create_substitution_leaf(leaf, ('id', o2m_op, ids1), model)) elif column._type == 'many2many': rel_table, rel_id1, rel_id2 = column._sql_names(model) From a8b1d30fca6bd0597746a619161af2f362ebac60 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 26 Jan 2017 15:20:43 +0100 Subject: [PATCH 04/15] [FIX] hr: Bank account from employee not loaded on payment on expense The bank account didn't appear when selecting SEPA credit transfer in ACCOUNTING>PURCHASE>PAYMENTS to refund an employee. The bank account is taken from partner set with the field home_address_id. So the account holder have to be set on the bank_account_id of the employee with the home_address_id. opw:702881 --- addons/hr/hr.py | 4 ++++ addons/hr/hr_view.xml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/hr/hr.py b/addons/hr/hr.py index e87ae89af24..f9b536c6915 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -198,6 +198,10 @@ class hr_employee(osv.osv): @api.multi def write(self, vals): + if 'address_home_id' in vals: + account_id = vals.get('bank_account_id') or self.bank_account_id.id + if account_id: + self.env['res.partner.bank'].browse(account_id).partner_id = vals['address_home_id'] tools.image_resize_images(vals) return super(hr_employee, self).write(vals) diff --git a/addons/hr/hr_view.xml b/addons/hr/hr_view.xml index 41ee36fb9cd..c6399119b1a 100644 --- a/addons/hr/hr_view.xml +++ b/addons/hr/hr_view.xml @@ -62,7 +62,7 @@ - + Date: Thu, 26 Jan 2017 18:45:14 +0100 Subject: [PATCH 05/15] [FIX] account: modal account.invoice.line form traceback In some instances we could get a traceback in the form view of an account.invoice.line object. This is because the `parent` field can be undefined depending of the way the form view was opened. For example there can be a account.invoice.line list in a sale.order.line form and this lead to a product_id with a traceback capable context. --- addons/account/views/account_invoice_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/views/account_invoice_view.xml b/addons/account/views/account_invoice_view.xml index 4d27ae6d465..27a854248df 100644 --- a/addons/account/views/account_invoice_view.xml +++ b/addons/account/views/account_invoice_view.xml @@ -61,7 +61,7 @@ + context="parent and {'partner_id': parent.partner_id}"/>