Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Guest House
    • Distributeur de boissons
    • Hotel
    Real Estate
    • Real Estate Agency
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consulting
    • Accounting Firm
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Solar Energy Systems
    • Cordonnier
    • Services de nettoyage
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

smart button v10

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
viewssearchbuttons
2 Réponses
8562 Vues
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
Ignorer
Avatar
Annadurai
Meilleure réponse

Hello,

use store = True in computed fields.

3
Avatar
Ignorer
Avatar
Bréndou Serge Eric
Meilleure réponse

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
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Open View from Button Résolu
views buttons
Avatar
Avatar
Avatar
2
déc. 23
19142
Button click and get data from other thirdparty api
views buttons
Avatar
Avatar
1
juil. 17
5071
Search in subtree
views search
Avatar
Avatar
Avatar
3
mars 15
4917
How to switch to a other view after clicking a button Résolu
views buttons odoo8
Avatar
Avatar
3
juin 21
10108
Text in custom filter condition select dropdown control V12
views search 12
Avatar
Avatar
2
août 20
4718
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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