Pular para o conteúdo
Odoo Menu
  • Entrar
  • Experimente grátis
  • Aplicativos
    Finanças
    • Financeiro
    • Faturamento
    • Despesas
    • Planilhas (BI)
    • Documentos
    • Assinar Documentos
    Vendas
    • CRM
    • Vendas
    • PDV Loja
    • PDV Restaurantes
    • Assinaturas
    • Locação
    Websites
    • Criador de Sites
    • e-Commerce
    • Blog
    • Fórum
    • Chat ao Vivo
    • e-Learning
    Cadeia de mantimentos
    • Inventário
    • Fabricação
    • PLM - Ciclo de Vida do Produto
    • Compras
    • Manutenção
    • Qualidade
    Recursos Humanos
    • Funcionários
    • Recrutamento
    • Folgas
    • Avaliações
    • Indicações
    • Frota
    Marketing
    • Redes Sociais
    • Marketing por E-mail
    • Marketing por SMS
    • Eventos
    • Automação de Marketing
    • Pesquisas
    Serviços
    • Projeto
    • Planilhas de Horas
    • Serviço de Campo
    • Central de Ajuda
    • Planejamento
    • Compromissos
    Produtividade
    • Mensagens
    • Aprovações
    • Internet das Coisas
    • VoIP
    • Conhecimento
    • WhatsApp
    Aplicativos de terceiros Odoo Studio Plataforma Odoo Cloud
  • Setores
    Varejo
    • Loja de livros
    • Loja de roupas
    • Loja de móveis
    • Mercearia
    • Loja de ferramentas
    • Loja de brinquedos
    Comida e hospitalidade
    • Bar e Pub
    • Restaurante
    • Fast Food
    • Hospedagem
    • Distribuidor de bebidas
    • Hotel
    Imóveis
    • Imobiliária
    • Escritório de arquitetura
    • Construção
    • Administração de propriedades
    • Jardinagem
    • Associação de proprietários de imóveis
    Consultoria
    • Escritório de Contabilidade
    • Parceiro Odoo
    • Agência de marketing
    • Escritório de advocacia
    • Aquisição de talentos
    • Auditoria e Certificação
    Fabricação
    • Têxtil
    • Metal
    • Móveis
    • Alimentação
    • Cervejaria
    • Presentes corporativos
    Saúde e Boa forma
    • Clube esportivo
    • Loja de óculos
    • Academia
    • Profissionais de bem-estar
    • Farmácia
    • Salão de cabeleireiro
    Comércio
    • Handyman
    • Hardware e Suporte de TI
    • Sistemas de energia solar
    • Sapataria
    • Serviços de limpeza
    • Serviços de climatização
    Outros
    • Organização sem fins lucrativos
    • Agência Ambiental
    • Aluguel de outdoors
    • Fotografia
    • Aluguel de bicicletas
    • Revendedor de software
    Navegar por todos os setores
  • Comunidade
    Aprenda
    • Tutoriais
    • Documentação
    • Certificações
    • Treinamento
    • Blog
    • Podcast
    Empodere a Educação
    • Programa de educação
    • Scale Up! Jogo de Negócios
    • Visite a Odoo
    Obtenha o Software
    • Baixar
    • Comparar edições
    • Releases
    Colaborar
    • Github
    • Fórum
    • Eventos
    • Traduções
    • Torne-se um parceiro
    • Serviços para parceiros
    • Cadastre seu escritório contábil
    Obtenha os serviços
    • Encontre um parceiro
    • Encontre um Contador
    • Conheça um consultor
    • Serviços de Implementação
    • Referências de Clientes
    • Suporte
    • Upgrades
    Github YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Faça uma demonstração
  • Preços
  • Ajuda

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

  • CRM
  • e-Commerce
  • Financeiro
  • Inventário
  • PoS
  • Projeto
  • MRP
All apps
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
Ajuda

smart button v10

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
viewssearchbuttons
2 Respostas
8622 Visualizações
Avatar
Dominic Anyanna

hello 

am developing a module that manages members of an association and their loans . and i wanted to create a smart button that shows all loans linked to a member . i have created the button but when i click on it it does not show a list of the loans . would appreciate any guidance i can get .


members model 




from odoo import models, fields, api

class ranchy_members(models.Model):
_name = 'members.ranchy'
_rec_name = 'member_firstname'

member_id = fields.Id
member_firstname = fields.Char(string="Name")
member_lastname = fields.Char(string="Name of father/husband")
member_addresss = fields.Char(string="Residential Address")
add_permanent = fields.Char(string="Pemanent Address")
business_addresss = fields.Char(string="Business Address")
member_phone = fields.Char(string="phone number")
member_pic = fields.Binary("image", help="select image here")
member_age = fields.Char(string="Age")
marital_status = fields.Selection(
[('Single','Single'), ('married','married'),('divorced','Divorced'),('widow','widow')],
'Marital status')
education = fields.Selection(
[('none','None'), ('primary','Primary'),('secondary','Secondary'),('tertiary','Tertiary')],
'Formal Education')
next_kin = fields.Char(string="Next of Kin Name")
kin_phone = fields.Char(string="Next of Kin Phone")
memberof = fields.Many2one('corps.ranchy',string="name of group")
business_type = fields.Char(string="Type of Business")
business_period = fields.Char(string="How long in business")
average_income = fields.Char(string="Average monthly income")
loan_ids = fields.One2many('ranchy.loans', 'member_ids', string='Loans')
loan_id = fields.Many2one('ranchy.loans', compute='_compute_loan_id', string='Current Loan', help='Latest loan of member')
loan_count = fields.Integer(compute='_compute_loan_count', string='Loans')

def _compute_loan_id(self):
""" get the lastest loan """
Loan = self.env['ranchy.loans']
for member in self:
member.loan_id = Loan.search([('member_ids', '=', member.id)], order='date_start desc', limit=1)

def _compute_loan_count(self):
# read_group as sudo, since contract count is displayed on form view
loan_data = self.env['ranchy.loans'].sudo().read_group([('member_ids', 'in', self.ids)], ['member_ids'], ['member_ids'])
result = dict((data['member_ids'][0], data['member_ids_count']) for data in loan_data)
for member in self:
member.loan_count = result.get(member.id, 0)
loans model

class ranchy_loans(models.Model):
_name = 'ranchy.loans'
_inherit = ['mail.thread', 'ir.needaction_mixin']

state = fields.Selection([
('new', 'New Apllication'),
('awaiting', 'awaiting approval'),
('approve', 'awaiting disbursement'),
('disburse', 'disbursed/repayment'),
('paid', 'paid'),
],track_visibility='onchange',default='new')
#This function is triggered when the user clicks on the button 'Set to concept'
@api.one
def concept_progressbar(self):
self.write({
'state': 'awaiting',
})
#This function is triggered when the user clicks on the button 'Set to started'
@api.one
def approved_progressbar(self):
self.write({
'state': 'approve'
})
#This function is triggered when the user clicks on the button 'In progress'
@api.one
def disburse_progressbar(self):
self.write({
'state': 'disburse'
})
#This function is triggered when the user clicks on the button 'Done'
@api.one
def paid_progressbar(self):
self.write({
'state': 'paid',
})
loan_id = fields.Id
currency_id = fields.Many2one(
'res.currency', string='Currency')
total_repayments = fields.Monetary(
'Total Repayments',
# optional: currency_field='currency_id',
)
amount_disburse = fields.Monetary(
'Amount',
# optional: currency_field='currency_id',
)
amount_applied = fields.Monetary(
'Amount applied for',
# optional: currency_field='currency_id',
)
amount_approved = fields.Monetary(
'Amount approved',
# optional: currency_field='currency_id',
)
amount_balance = fields.Monetary(
'Balance',
# optional: currency_field='currency_id',
)
last_loan = fields.Monetary(
'last loan recieved amount',
# optional: currency_field='currency_id',
)
date_payed = fields.Date('Date loan was fully paid')
date_disburse = fields.Date('Date')
member_ids = fields.Many2one(
'members.ranchy', string='Member',
# optional:
ondelete='restrict',
context={},
domain=[],
)
stage = fields.Selection(
[('1st','First'), ('2nd','Second'),('3rd','third')],
'Stage')
installments = fields.Selection(
[('23','23'), ('20','20'),('18','18')],
'number of installments')
date_firstinstall = fields.Date('Date of first installment')
date_finalinstall = fields.Date('Date of last installment')
any_family = fields.Boolean('Is any family member of yours registered with the group')
if_true = fields.Char('If true mention name')
or_reg = fields.Boolean('Or registered in any other group of ranchi empowerment centre')
indebted = fields.Boolean('Are you indebted to any otherMFB/MFI')
if_true2 = fields.Char('If true Name')
if_true3 = fields.Char('Outstanding Balance')
view
<?xml version="1.0"?>
<odoo>
<data>


<act_window id="ranchy.action_window" res_model="members.ranchy" name="ranchy" view_mode="tree,form"/>



<menuitem action="ranchy.action_window" name="ranchy" id="ranchy.menu_root" groups="base.group_user" sequence ="450"/>
<menuitem action="ranchy.action_window" name="Members" id="ranchy.members" parent="ranchy.menu_root" sequence="1"/>


<record id= "ranchy_members_template_form_view" model= "ir.ui.view">
<field name="priority" eval="15"/>
<field name="model">members.ranchy</field >
<field name="arch" type= "xml">


<form>
<sheet>
<button type="action" class="oe_right oe_stat_button"
icon="fa-pencil-square-o" align="right" name="%(action_all_loans)d" >
<field name="loan_count" widget="statinfo"/>
</button>
<group>
<field name="member_pic" widget='image' />
<field name="member_firstname"/>
<field name="member_lastname"/>
</group>
<notebook>
<page string="Contact Information">
<group>
<field name="member_addresss"/>
<field name="add_permanent"/>
<field name="business_addresss"/>
<field name="member_phone"/>
</group>
</page>
<page string="Member Data">
<group>
<field name="member_age"/>
<field name="marital_status"/>
<field name="education"/>
<field name="next_kin"/>
<field name="kin_phone"/>
</group>
</page>
<page string="union and Business Information">
<group>
<field name="memberof"/>
<field name="business_type"/>
<field name="business_period"/>
<field name="average_income"/>

</group>
</page>
</notebook>
</sheet>

</form>

</field>
</record>

<record model="ir.actions.act_window" id="action_all_loans">
<field name="name">All Loans</field>
<field name="model">ranchy.loans</field>
<field name="view_mode">tree,form,search</field>
<field name="context">{'search_default_member_ids': [active_id],'default_member_ids': active_id}</field>
<field name="domain">[('loan_ids', '=', active_id)]</field>
</record>


<record id="loans_all_members" model="ir.ui.view">
<field name="name">All Loans</field>

<field name="model">ranchy.loans</field>
<field name="arch" type="xml">
<tree string="Payments">


</tree>
</field>
</record>



<record id="action_all_members_form"
model="ir.actions.act_window.view">
<field name="act_window_id" ref="action_all_loans"/>
<field name="view_id" ref="loans_all_members" />
<field name="view_mode">tree</field>
<field name="sequence">10</field>
</record>
     
0
Avatar
Cancelar
Avatar
Annadurai
Melhor resposta

Hello,

use store = True in computed fields.

3
Avatar
Cancelar
Avatar
Bréndou Serge Eric
Melhor resposta

Hello! I think your problem is in the definition of your action 'action_to_all_loans': the domain is not correct it should be [('member_ids','=',active_id)] because according to your definition member_ids is the inverse field of the One2many relation.

And I think you dont need to add 'search_default_member_ids': [active_id]  in the context if you are already applying a domain on member_ids....




0
Avatar
Cancelar
Está gostando da discussão? Não fique apenas lendo, participe!

Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!

Inscreva-se
Publicações relacionadas Respostas Visualizações Atividade
Open View from Button Resolvido
views buttons
Avatar
Avatar
Avatar
2
dez. 23
19237
Button click and get data from other thirdparty api
views buttons
Avatar
Avatar
1
jul. 17
5146
Search in subtree
views search
Avatar
Avatar
Avatar
3
mar. 15
4952
How to switch to a other view after clicking a button Resolvido
views buttons odoo8
Avatar
Avatar
3
jun. 21
10180
Text in custom filter condition select dropdown control V12
views search 12
Avatar
Avatar
2
ago. 20
4766
Comunidade
  • Tutoriais
  • Documentação
  • Fórum
Open Source
  • Baixar
  • Github
  • Runbot
  • Traduções
Serviços
  • Odoo.sh Hosting
  • Suporte
  • Upgrade
  • Desenvolvimentos personalizados
  • Educação
  • Encontre um Contador
  • Encontre um parceiro
  • Torne-se um parceiro
Sobre nós
  • Nossa empresa
  • Ativos da marca
  • Contato
  • Empregos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidade
  • Segurança
الْعَرَبيّة 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 é um conjunto de aplicativos de negócios em código aberto que cobre todas as necessidades de sua empresa: CRM, comércio eletrônico, contabilidade, estoque, ponto de venda, gerenciamento de projetos, etc.

A proposta de valor exclusiva Odoo é ser, ao mesmo tempo, muito fácil de usar e totalmente integrado.

Site feito com

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