Browse Source

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
pull/679/head
Ted Salmon 8 years ago
committed by Dave Lasley
parent
commit
6f3c0c0f7e
  1. 12
      base_kanban_stage/README.rst
  2. 2
      base_kanban_stage/__openerp__.py
  3. 12
      base_kanban_stage/models/base_kanban_abstract.py
  4. 2
      base_kanban_stage/views/base_kanban_abstract.xml

12
base_kanban_stage/README.rst

@ -35,16 +35,18 @@ Usage
_inherit = 'base.kanban.abstract' _inherit = 'base.kanban.abstract'
* Extend the provided base Kanban view (``base_kanban_abstract_view_kanban``) * 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 .. code-block:: xml
<record id="my_model_view_kanban" model="ir.ui.view"> <record id="my_model_view_kanban" model="ir.ui.view">
<field name="name">My Model - Kanban View</field> <field name="name">My Model - Kanban View</field>
<field name="model">my.model</field> <field name="model">my.model</field>
<field name="mode">primary</field>
<field name="inherit_id" ref="base_kanban_stage.base_kanban_abstract_view_kanban"/> <field name="inherit_id" ref="base_kanban_stage.base_kanban_abstract_view_kanban"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//div[@name='card_header']"> <xpath expr="//div[@name='card_header']">
@ -90,7 +92,7 @@ Contributors
* Dave Lasley <dave@laslabs.com> * Dave Lasley <dave@laslabs.com>
* Oleg Bulkin <obulkin@laslabs.com> * Oleg Bulkin <obulkin@laslabs.com>
* Daniel Reis
* Daniel Reis <dreis.pt@hotmail.com>
Maintainer Maintainer
---------- ----------

2
base_kanban_stage/__openerp__.py

@ -9,7 +9,7 @@
'author': "LasLabs, Odoo Community Association (OCA)", 'author': "LasLabs, Odoo Community Association (OCA)",
'category': 'base', 'category': 'base',
'depends': [ 'depends': [
'web_kanban',
'base',
], ],
'website': 'https://laslabs.com', 'website': 'https://laslabs.com',
'license': 'LGPL-3', 'license': 'LGPL-3',

12
base_kanban_stage/models/base_kanban_abstract.py

@ -6,10 +6,10 @@ from openerp import api, fields, models
class BaseKanbanAbstract(models.AbstractModel): 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 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 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' _name = 'base.kanban.abstract'
_order = 'kanban_priority desc, kanban_sequence' _order = 'kanban_priority desc, kanban_sequence'
@ -24,7 +24,7 @@ class BaseKanbanAbstract(models.AbstractModel):
' stage and with the same priority', ' stage and with the same priority',
) )
kanban_priority = fields.Selection( kanban_priority = fields.Selection(
selection=[('0', 'Normal'), ('5', 'Medium'), ('10', 'High')],
selection=[('0', 'Normal'), ('1', 'Medium'), ('2', 'High')],
index=True, index=True,
default='0', default='0',
help='The priority of the record (shown as stars in Kanban views)', 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(), default=lambda s: s._default_stage_id(),
domain=lambda s: [('res_model.model', '=', s._name)], domain=lambda s: [('res_model.model', '=', s._name)],
) )
kanban_user_id = fields.Many2one(
user_id = fields.Many2one(
string='Assigned To', string='Assigned To',
comodel_name='res.users', comodel_name='res.users',
index=True, index=True,
@ -105,7 +105,9 @@ class BaseKanbanAbstract(models.AbstractModel):
def _read_group_stage_ids( def _read_group_stage_ids(
self, domain=None, read_group_order=None, access_rights_uid=None 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)]) stages = stage_model.search([('res_model.model', '=', self._name)])
names = [(r.id, r.display_name) for r in stages] names = [(r.id, r.display_name) for r in stages]
fold = {r.id: r.fold for r in stages} fold = {r.id: r.fold for r in stages}

2
base_kanban_stage/views/base_kanban_abstract.xml

@ -19,7 +19,7 @@
<field name="kanban_legend_blocked"/> <field name="kanban_legend_blocked"/>
<field name="kanban_legend_normal"/> <field name="kanban_legend_normal"/>
<field name="kanban_legend_done"/> <field name="kanban_legend_done"/>
<field name="kanban_user_id"/>
<field name="user_id"/>
<templates> <templates>
<t t-name="kanban-box"> <t t-name="kanban-box">
<div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.kanban_color.raw_value)} o_kanban_record oe_kanban_global_click"> <div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.kanban_color.raw_value)} o_kanban_record oe_kanban_global_click">

Loading…
Cancel
Save