Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
1034 Zobrazení

I have this model:

class RouteSheet(models.Model):

    _name = 'route.sheet'

    _description = 'Route Sheet'


    state_id = fields.Many2one(

        'route.sheet.state',

        string="Estado",

        required=True,

        default=lambda self: self.env['route.sheet.state'].search([('code', '=', 'draft')], limit=1),

        help="Estado de la hoja de ruta"

    )

And this kanban view to the model:

<record id="view_route_sheet_kanban" model="ir.ui.view">

            <field name="name">route.sheet.kanban</field>

            <field name="model">route.sheet</field>

            <field name="arch" type="xml">

                <kanban default_group_by="state_id" group_create="False" group_delete="False" group_edit="False" records_draggable="False" quick_create="False" class="o_kanban_mobile" sample="1" default_order="data_doc desc">

                    <field name="state_id" />

                    <templates>

                        <t t-name="kanban-box">

                            <div t-attf-class="oe_kanban_card oe_kanban_global_click">

                                <div class="o_kanban_card_content">

                                    <t t-if="record.name.raw_value">

                                        <strong class="o_kanban_record_title oe_partner_heading">

                                            <field name="name"/>

                                        </strong>

                                    </t>

                                    <t t-else="">

                                        <strong class="o_kanban_record_title oe_partner_heading">Sin Nombre</strong>

                                    </t>

                                </div>

                                <div class="o_kanban_details">

                                    <div class="o_kanban_item">

                                        <span class="fa fa-truck o_kanban_icon"/>

                                        <t t-if="record.transport_id.raw_value">

                                            <field name="transport_id"/>

                                        </t>

                                        <t t-elif="!record.transport_id.raw_value">

                                            No hay transportista

                                        </t>

                                    </div>

                                    <div class="o_kanban_item">

                                        <span class="fa fa-user o_kanban_icon"/>

                                        <t t-if="record.chofer_id.raw_value">

                                            <field name="chofer_id"/>

                                        </t>

                                        <t t-elif="!record.chofer_id.raw_value">

                                            No hay chofer

                                        </t>

                                    </div>

                                    <div class="o_kanban_item">

                                        <span class="fa fa-car o_kanban_icon"/>

                                        <t t-if="record.vehicle_id.raw_value">

                                            <field name="vehicle_id"/>

                                        </t>

                                        <t t-elif="!record.vehicle_id.raw_value">

                                            No hay vehículo

                                        </t>

                                    </div>

                                </div>

                            </div>

                        </t>

                    </templates>

                </kanban>

            </field>

        </record>

and I have 3 statuses available for registration: "draft", "confirmed", "in_transit", "rendition", "closed" and "cancel". The problem is that in the kanban view only the columns whose status is in a record appear, if there are no records for a status, this status does not appear. For example, I have three records, each with a different status, so only three columns appear instead of six, and the ones that don't appear are the ones that are not related to any record. Is there any solution?

Avatar
Zrušit
Autor

It worked perfectly, thank you very much!

Nejlepší odpověď

See the note under the Context section of the documentation at https://www.odoo.com/documentation/17.0/developer/reference/user_interface/view_architectures.html#filter-create-pre-defined-filters

You need to define a group_expand method in your class, this is how we do it for Sales Team Members when grouping by Team:

https://github.com/odoo/odoo/blob/17.0/addons/sales_team/models/crm_team_member.py

crm_team_id = fields.Many2one('crm.team', group_expand='_read_group_crm_team_id')

@api.model
def _read_group_crm_team_id(self, teams, domain, order):
    """Read group customization in order to display all the teams in Kanban view, even if they are empty."""
    return self.env['crm.team'].search([], order=order)
Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
3
srp 25
1464
2
bře 25
1233
1
úno 25
1490
1
led 25
1673
1
pro 24
1995