From a9ecf87d85d29d0532fab1f45a2eab3d0d31a60c Mon Sep 17 00:00:00 2001 From: Ted Salmon Date: Tue, 3 Jan 2017 13:23:54 -0800 Subject: [PATCH] IMP] base_kanban_stage: Updates per PR * Update depends to `base` * Update priority selections to match Odoo guidelines * Update comment block to triple double quotes * Update `kanban_user_id` to `user_id` in code and view * Update README to incorporate use of mode in example view --- base_kanban_stage/README.rst | 12 +++++++----- base_kanban_stage/__manifest__.py | 2 +- base_kanban_stage/models/base_kanban_abstract.py | 12 +++++++----- base_kanban_stage/views/base_kanban_abstract.xml | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/base_kanban_stage/README.rst b/base_kanban_stage/README.rst index 7fe39570c..8f683f429 100644 --- a/base_kanban_stage/README.rst +++ b/base_kanban_stage/README.rst @@ -35,16 +35,18 @@ Usage _inherit = 'base.kanban.abstract' * Extend the provided base Kanban view (``base_kanban_abstract_view_kanban``) - as needed by the child model. The base view has four ``name`` attributes - intended to provide convenient XPath access to different parts of the Kanban - card. They are ``card_dropdown_menu``, ``card_header``, ``card_body``, and - ``card_footer``: + as needed by the child model while making sure to set the ``mode`` to + ``primary`` so that inheritance works properly. The base view has four + ``name`` attributes intended to provide convenient XPath access to different + parts of the Kanban card. They are ``card_dropdown_menu``, ``card_header``, + ``card_body``, and ``card_footer``: .. code-block:: xml My Model - Kanban View my.model + primary @@ -90,7 +92,7 @@ Contributors * Dave Lasley * Oleg Bulkin -* Daniel Reis +* Daniel Reis Maintainer ---------- diff --git a/base_kanban_stage/__manifest__.py b/base_kanban_stage/__manifest__.py index 213f9b6d8..ecb053f2f 100644 --- a/base_kanban_stage/__manifest__.py +++ b/base_kanban_stage/__manifest__.py @@ -9,7 +9,7 @@ 'author': "LasLabs, Odoo Community Association (OCA)", 'category': 'base', 'depends': [ - 'web_kanban', + 'base', ], 'website': 'https://laslabs.com', 'license': 'LGPL-3', diff --git a/base_kanban_stage/models/base_kanban_abstract.py b/base_kanban_stage/models/base_kanban_abstract.py index d1b03901c..3bcd9e5a2 100644 --- a/base_kanban_stage/models/base_kanban_abstract.py +++ b/base_kanban_stage/models/base_kanban_abstract.py @@ -6,10 +6,10 @@ from odoo import api, fields, models class BaseKanbanAbstract(models.AbstractModel): - '''Inherit from this class to add support for Kanban stages to your model. + """ Inherit from this class to add support for Kanban stages to your model. All public properties are preceded with kanban_ in order to isolate from child models, with the exception of stage_id, which is a required field in - the Kanban widget and must be defined as such.''' + the Kanban widget and must be defined as such. """ _name = 'base.kanban.abstract' _order = 'kanban_priority desc, kanban_sequence' @@ -24,7 +24,7 @@ class BaseKanbanAbstract(models.AbstractModel): ' stage and with the same priority', ) kanban_priority = fields.Selection( - selection=[('0', 'Normal'), ('5', 'Medium'), ('10', 'High')], + selection=[('0', 'Normal'), ('1', 'Medium'), ('2', 'High')], index=True, default='0', help='The priority of the record (shown as stars in Kanban views)', @@ -39,7 +39,7 @@ class BaseKanbanAbstract(models.AbstractModel): default=lambda s: s._default_stage_id(), domain=lambda s: [('res_model.model', '=', s._name)], ) - kanban_user_id = fields.Many2one( + user_id = fields.Many2one( string='Assigned To', comodel_name='res.users', index=True, @@ -105,7 +105,9 @@ class BaseKanbanAbstract(models.AbstractModel): def _read_group_stage_ids( self, domain=None, read_group_order=None, access_rights_uid=None ): - stage_model = self.env['base.kanban.stage'].sudo(access_rights_uid) + stage_model = self.env['base.kanban.stage'] + if access_rights_uid: + stage_model = stage_model.sudo(access_rights_uid) stages = stage_model.search([('res_model.model', '=', self._name)]) names = [(r.id, r.display_name) for r in stages] fold = {r.id: r.fold for r in stages} diff --git a/base_kanban_stage/views/base_kanban_abstract.xml b/base_kanban_stage/views/base_kanban_abstract.xml index 5f5615f9e..984889565 100644 --- a/base_kanban_stage/views/base_kanban_abstract.xml +++ b/base_kanban_stage/views/base_kanban_abstract.xml @@ -19,7 +19,7 @@ - +