From 020906659e55bd41a07ab0e4e79da903af7b50c1 Mon Sep 17 00:00:00 2001 From: xmo-odoo Date: Wed, 9 May 2018 09:45:29 +0200 Subject: [PATCH 1/3] [FIX] orm: "relate" binding type on actions When ir.values was removed and the "action" ir.values were merged directly into the actions themselves, "client_action_relate" was discarded as unused (and possibly too similar to client_action_multi?). *However*: * it was actually used implicitly as "relate" was the default key2 of the XML tag * and it had a crucial difference from client_action_multi: client_action_multi is shown on both form and list views by default and only on list if multi=True, whereas relate is shown on *either* the form or list view (tree if multi else form) This means without relate the actions which should be only visible on the form view are now on both list and tree, which leads to overpopulated `Action` menus and odd behaviours (e.g. actions relying active_id on lists, which id do they get and why?) => reintroduce relate as "action_form_only" for the specific case of multi=False and either no key2 or a key2 of client_action_relate. If multi=True then binding_type=action. Fixes #20124 Followup: Task 1843603 to remove #multi and redundancy --- odoo/addons/base/ir/ir_actions.py | 1 + odoo/models.py | 4 ++++ odoo/tools/convert.py | 7 +++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/odoo/addons/base/ir/ir_actions.py b/odoo/addons/base/ir/ir_actions.py index 646615cb593..862d288ac5b 100644 --- a/odoo/addons/base/ir/ir_actions.py +++ b/odoo/addons/base/ir/ir_actions.py @@ -34,6 +34,7 @@ class IrActions(models.Model): binding_model_id = fields.Many2one('ir.model', ondelete='cascade', help="Setting a value makes this action available in the sidebar for the given model.") binding_type = fields.Selection([('action', 'Action'), + ('action_form_only', "Form-only"), ('report', 'Report')], required=True, default='action') diff --git a/odoo/models.py b/odoo/models.py index 1b0207e9eb9..202887a31be 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -1391,6 +1391,9 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): resaction = [action for action in bindings['action'] if view_type == 'tree' or not action.get('multi')] + resrelate = [] + if view_type == 'form': + resrelate = bindings['action_form_only'] for res in itertools.chain(resreport, resaction): res['string'] = res['name'] @@ -1398,6 +1401,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): result['toolbar'] = { 'print': resreport, 'action': resaction, + 'relate': resrelate, } return result diff --git a/odoo/tools/convert.py b/odoo/tools/convert.py index 59e87d6ee32..97fb2be7330 100644 --- a/odoo/tools/convert.py +++ b/odoo/tools/convert.py @@ -427,11 +427,14 @@ form: module.record_id""" % (xml_id,) if rec.get('target'): res['target'] = rec.get('target','') + if rec.get('multi'): + res['multi'] = safe_eval(rec.get('multi', 'False')) if src_model: res['binding_model_id'] = self.env['ir.model']._get(src_model).id res['binding_type'] = 'report' if rec.get('key2') == 'client_print_multi' else 'action' - if rec.get('multi'): - res['multi'] = safe_eval(rec.get('multi', 'False')) + if rec.get('key2') in (None, 'client_action_relate'): + if not res.get('multi'): + res['binding_type'] = 'action_form_only' id = self.env['ir.model.data']._update('ir.actions.act_window', self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode) self.idref[xml_id] = int(id) From 665fcb62cfc0231125fc5d0815668b945e2a8d0d Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Tue, 8 May 2018 17:50:52 +0200 Subject: [PATCH 2/3] [FIX] website: always show menu if its a container with visible menus Before this commit: 1. If a menu was used as a container (dropdown) and had an unpublished page_id (website.page), we would never show that menu (and so its submenus) even if it has visible submenu. Some users are stuck with this since they: a) create a new page 'A' (unpublished by default) included in menu. b) create a new page 'B' (unpublished by default) included in menu. c) set 'B' as a submenu of 'A' in the menu manager d) decide to publish the website.page linked to menu 'B' Then, since menu 'A' is linked to an unpublished page, the menu 'A' and 'B' are never visible. 2. If a menu is being created with an URL that match a website.page URL, the m2o relation will automatically be set (website.menu.page_id). Still, if the user type the URL without the leading slash, the m2o won't be set. This could be misleading since on the page property in the page manager the URL is being shown without the leading slash even if it is stored in DB. Now: 1. We always show menu container if they contains visible submenu, even if the container menu is linked to an unpublished page 2. The page URL search is more clever and will match URL even if the only difference is the leading slash. This closes #24635 --- addons/website/models/website.py | 3 ++- addons/website/views/website_templates.xml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 35038877749..eb5483f7915 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -885,9 +885,10 @@ class Menu(models.Model): for menu in data['data']: menu_id = self.browse(menu['id']) # if the url match a website.page, set the m2o relation - page = self.env['website.page'].search([('url', '=', menu['url'])], limit=1) + page = self.env['website.page'].search(['|', ('url', '=', menu['url']), ('url', '=', '/' + menu['url'])], limit=1) if page: menu['page_id'] = page.id + menu['url'] = page.url elif menu_id.page_id: menu_id.page_id.write({'url': menu['url']}) menu_id.write(menu) diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml index 16fc3e33444..3573ca8a4df 100644 --- a/addons/website/views/website_templates.xml +++ b/addons/website/views/website_templates.xml @@ -74,7 +74,7 @@ -
  • From b793e23ae53b5f1edab8c98bbed7ac5f5f921280 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 8 May 2018 10:57:53 +0200 Subject: [PATCH 3/3] [FIX] stock: incorrect PO sequence - Create 2 companies A & B - Create a sequence for PO in each company - Set User A in Company A and Admin in Company B - Create a MTO product with a 'Buy' route - Create a SO with User A using the product, validate The PO created uses the sequence for Company B instead of Company A. The creation is done as `sudo`, and ultimately `next_by_code` will use the company of the Admin. opw-1839656 --- addons/stock/models/procurement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/models/procurement.py b/addons/stock/models/procurement.py index 6f8402c1fe7..49f65a8f61c 100644 --- a/addons/stock/models/procurement.py +++ b/addons/stock/models/procurement.py @@ -77,7 +77,7 @@ class ProcurementRule(models.Model): data = self._get_stock_move_values(product_id, product_qty, product_uom, location_id, name, origin, values, group_id) # Since action_confirm launch following procurement_group we should activate it. - move = self.env['stock.move'].sudo().create(data) + move = self.env['stock.move'].sudo().with_context(force_company=data.get('company_id', False)).create(data) move._action_confirm() return True