Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

smart button v10

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
viewssearchbuttons
2 Răspunsuri
8613 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Imagine profil
Annadurai
Cel mai bun răspuns

Hello,

use store = True in computed fields.

3
Imagine profil
Abandonează
Imagine profil
Bréndou Serge Eric
Cel mai bun răspuns

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
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Open View from Button Rezolvat
views buttons
Imagine profil
Imagine profil
Imagine profil
2
dec. 23
19227
Button click and get data from other thirdparty api
views buttons
Imagine profil
Imagine profil
1
iul. 17
5144
Search in subtree
views search
Imagine profil
Imagine profil
Imagine profil
3
mar. 15
4949
How to switch to a other view after clicking a button Rezolvat
views buttons odoo8
Imagine profil
Imagine profil
3
iun. 21
10179
Text in custom filter condition select dropdown control V12
views search 12
Imagine profil
Imagine profil
2
aug. 20
4764
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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