Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • e-learning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Cervecería
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y soporte técnico
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Explorar todos los sectores
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Servicios para partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

How to get ids from Kanban cards

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
kanbanactive_id
2 Respuestas
3321 Vistas
Avatar
Sascha

Hi everyone,

I have a short question : How to access ids of shown kanban cards?

Do I need to rebuild the search and domain for py use or can I grab them from form view?

def get_sap_no(self):
if self.order_id:
# We search for order_id to get the customers_id
first = self.env['esc.sst'].search([('order_id', '=', self.order_id)], limit=1)

view = self.env.ref('esc_et.esc_ship_spares_kanban_view_filtered')
action = {'type': 'ir.actions.act_window',
'res_model'
: 'esc.sst',
'view_type'
: 'kanban',
'view_mode'
: 'kanban',
'view_id'
: view.id,
'domain'
: [('partner', '=', first.partner)],
'target'
: 'main',
​ ​ 'context': {
'partner' : first.partner,
​ ​ }
}
return action


edit: 

Wenn in JS, I don´t get a value.

_CloseSAPCase: function () {
var self = this;
alert(this.partner)
this._rpc({
model: 'esc.sst',
method: 'write_tch_order',
args: [],
context: {'partner': this.partner,}
}, {
shadow: true,
});

}


I only want to pass the partner number I got in my def get_sap_no to my def write_tch_order to perform  some stuff.

Programs way:

wizard button --> def_get_sap --> returns custom kanban view with domain filter -->JS Button to close case --> def write_thc_order

But after the Kanban return my partner is gone :(

0
Avatar
Descartar
Sascha
Autor

Okay, ehhm... nope...

maybe I should have added request for Odoo 15.0.

short :

wizard --> search partner -->open Kanban domain = partner --> do some stuff --> action button for doin stuff (added in JS by Cybros tutorial).
But both, JS and py saying nothing in self.env.context.get or self.partner


long:

I fully understood that each kanban cards is a tuple of the record and I already did a search as you can see in my code.
I have a wizard to enter order_id and search for it to get it´s partner no. I pass this partner to an action to get a filtered kanban view (see above my code, plz) related to my search.

I added a context as I only need to have the partner from there (beacause I can search for related values in model then).

'context': {
​ 'partner'
: first.partner,
}

But I wrap my head around to understand why I don´t have a value in self.env.context.get('partner') on my filtered Kanban. 




Avatar
Sascha
Autor Mejor respuesta
First : How to post xml code? codeblocks and nomral text will crash the xml parts of my post, so I deleted first bracket
Here you go-full code for every part involved:
Form where enter SAPNumber:

recordid="esc_ship_spares_form_view"model=""\ rel="ugc">ir\.ui\.view">
\ fieldname="name">esc_ship_spares_form_view/field>
\ fieldname="model">esc\.ship\.spare/field>
\ fieldname="arch"type="xml">
\ formaction_buttons="false">
\ Buttonname="get_sap_no"string="GetData"type="object"class="oe_highlight"/>fieldname="order_id"/>
\ /form>
\ /field>
/record>

defget_sap_no\(self\):
\ ​\#ifself\.order_id:
\ ​\#Wesearchfororder_idtogetthecustomers_id
\ ​sst=self\.env\['esc\.sst'\]\.search\(\[\('order_id','=',self\.order_id\)\],limit=1\)
\ ​\#raiseValidationError\(sst\.partner\)
\ ​view=self\.env\.ref\('mymodule\.esc_ship_spares_kanban_view_filtered'\)
\ ​action=\{
\ ​\ ​'type':'ir\.actions\.act_window',
\ ​\ ​'res_model':'esc\.sst',
\ ​\ ​'view_type':'kanban',
\ ​\ ​'view_mode':'kanban',
\ ​\ ​'view_id':view\.id,
\ ​\ ​'domain':\[\('partner','=',sst\.partner\)\],
\ ​\ ​'target':'inline',
\ ​\ ​'context':\{
\ ​\ ​'partner':sst\.partner
\ ​\ ​\}
\ ​\}
\ ​returnaction

The\ Kanban\ is\ extended\ with\ a\ js_class\ for\ custom\ button\ \(below\ kanban\)

recordid="esc_ship_spares_kanban_view_filtered"model=""\ rel="ugc">ir\.ui\.view">
\ ​fieldname="name">esc_ship_spares_kanban_view/field>
\ ​fieldname="model">esc\.sst/field>
\ ​fieldname="arch"type="xml">
\ ​kanbangroup_create="false"default_group_by="service_state">
\ ​\ ​fieldname="order_id"/>
\ ​\ ​fieldname="partner"/>
\ ​\ ​fieldname="service_state"/>
\ ​progressbarfield="service_state"colors='\{"eingang":"danger","verzug_1":"warning","verzug_2":"warning","erledigt":"success"\}'/>
\ ​templates>
\ ​tt\-name="kanban\-box">
\ ​divclass="oe_kanban_content">
\ ​divclass="o_kanban_record_title">
\ ​strong>
\ ​fieldname="order_id"/>\-\-\-\-\-fieldname="sst_date"/>
\ ​/strong>
\ ​br>/br>
\ ​Artikel:fieldname="spare_no"/>
\ ​br>/br>
\ ​fieldname="spare_descr"/>
\ ​br>/br>
\ ​fieldname="fk_status"/>
\ ​/div>
\ ​/div>
\ ​\ ​divclass="oe_kanban_footer_right">
\ ​/div>
\ ​/t>
\ ​/templates>
\ ​/kanban>
\ ​/field>
/record>

JS:

odoo\.define\('mymodule\.kanban_close_button',function\(require\)\{
"usestrict";
\ ​var\ KanbanController=require\('web\.KanbanController'\);
\ ​var\ KanbanView=require\('web\.KanbanView'\);
\ ​var\ viewRegistry=require\('web\.view_registry'\);
\ ​var\ KanbanCloseButton=KanbanController\.extend\(\{
\ ​buttons_template:'mymodule\.closebutton',
\ ​events:_\.extend\(\{\},KanbanController\.prototype\.events,\{
\ ​'click\ \.close_sst_case':'_CloseSAPCase',
\}\),

_CloseSAPCase:function\(\)\{
\ ​var\ self=this;
\ ​alert\(this\.partner\)
\ ​this\._rpc\(\{\ ​\ ​
\ ​model:'esc\.sst',
\ ​method:'write_tch_order',
\ ​args:\[\],
\ ​\ ​\},\{
\ ​shadow:true,
\ ​\}\);

\ ​\}
\ ​\}\);

var\ close_caseKanbanView=KanbanView\.extend\(\{
config:_\.extend\(\{\},KanbanView.prototype.config,{
Controller:KanbanCloseButton
}),
});
viewRegistry.add('PutSAP',close_caseKanbanView);
});

qweb template for button:


templatesid="template"xml:space="preserve">
​tt-extend="KanbanView.buttons"t-name="mymodule.closebutton">
​ ​tt-jquery="button"t-operation="replace">
​ ​buttont-if="widget.modelName=='esc.sst'"
​ ​class="btnbtn-primaryclose_sst_caseoe_highlight"
​ ​type="button">Auftragabschließen/button>
​ ​/t>
​/t>
/templates>

defwrite_tch_order(self):
#ship_em=self.env['esc.sst'].search([('service_state','=','versenden')])
#sst_partner=ship_em[0].partner
#self.sst_state_changes(sst_partner)
#forsstinship_em:
#...

raiseValidationError(self.partner)

So whats wrong, please?



0
Avatar
Descartar
Avatar
MUHAMMAD Imran
Mejor respuesta

, you can get the ids of Kanban cards by using the search() method on the model that represents the Kanban cards. For example, if the model is called project.task, you could use the following code to get the ids of all Kanban cards:


Copy code

from odoo import models


task_ids = models.execute_kw('project.task', 'search', [[]])

This will return a list of all task ids. If you want to filter the tasks based on some condition, you can pass a domain as the first argument to the search() method. For example, to get the ids of all Kanban cards with the status "Done", you could use the following code:


Copy code

task_ids = models.execute_kw('project.task', 'search', [[['state', '=', 'done']]])

You can also use the ORM API to get the ids of Kanban cards, like this:


Copy code

task_obj = self.env['project.task']

task_ids = task_obj.search([])

Also, you can use the ORM API to filter the ids of Kanban cards, like this:


Copy code

task_obj = self.env['project.task']

task_ids = task_obj.search([('state','=','done')])

Please note that this is just an example, and the exact code may vary depending on the specific version of Odoo and the customizations that have been made to the system

0
Avatar
Descartar
Sascha
Autor

Hi Muhammed,
Thanks for your efforts, but maybe I don´t understand your answer or you are explaining what I already got?
I filtered my Kanban-Cards on domain and return it into kanban domain (you can see it in my code...). So I now want to get the shown ids but :

1.) I added a context :
'context': {
'partner' : partner,
}
self.env.context.get('partner') is none
2.) self.whatever is none

Why´s nothing in context of kanban view? Code is in first post

MUHAMMAD Imran

It's difficult to determine the issue without the complete code and context, but here are some possible reasons why the context may not be present in the kanban view:

The context is being overridden: Sometimes other code in the system may be modifying or clearing the context. It's possible that the context is being overridden before it reaches the kanban view.

The context is not being passed correctly: The context is not passed correctly if the method or view that adds the context is not called. Make sure that the method that adds the context is being called correctly and that the context is being passed correctly to the kanban view.

The context is not being correctly referenced: If the reference to the context is incorrect, it will not be able to retrieve the context values. For example, if the reference to the partner context is self.env.context.get('partner') but the context value is actually self.env.context.get('partners'), it will return None.

The value of self.whatever is None: If the value of self.whatever is None, it could be due to several reasons, such as it's not defined in the code or it's not being passed correctly to the view.

It is recommended to add some debugging statements to your code to help you understand what's happening, such as printing out the contents of the context or the value of self.whatever to see what's causing the issue

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
How to make the order of "default_group_by" in kanban view?
kanban
Avatar
Avatar
1
ene 25
2869
odoo 15 undraggable records in kanban view
kanban
Avatar
0
ago 22
3364
add a second progressbar kanban
kanban
Avatar
0
mar 22
3393
Not display Kanban view ? Resuelto
kanban
Avatar
Avatar
1
oct 19
6508
replace the view tree with kanban
kanban
Avatar
Avatar
2
may 18
7547
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones empresariales de código abierto que cubre todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now