Bỏ qua để đến Nội dung
Odoo Menu
  • Đăng nhập
  • Dùng thử miễn phí
  • Ứng dụng
    Tài chính
    • Kế toán
    • Hóa đơn
    • Chi phí
    • Bảng tính (BI)
    • Tài liệu
    • Ký tên
    Bán hàng
    • CRM
    • Bán hàng
    • POS Cửa hàng
    • POS Nhà hàng
    • Đăng ký
    • Cho thuê
    Trang web
    • Trình tạo trang web
    • Thương mại điện tử
    • Blog
    • Diễn đàn
    • Trò chuyện trực tiếp
    • Học trực tuyến
    Chuỗi cung ứng
    • Tồn kho
    • Sản xuất
    • PLM
    • Mua hàng
    • Bảo dưỡng
    • Chất lượng
    Nhân sự
    • Nhân viên
    • Tuyển dụng
    • Ngày nghỉ
    • Đánh giá
    • Giới thiệu
    • Đội xe
    Marketing
    • Marketing trên MXH
    • Marketing qua email
    • Marketing qua SMS
    • Sự kiện
    • Tự động hóa Marketing
    • Khảo sát
    Dịch vụ
    • Dự án
    • Bảng chấm công
    • Dịch vụ hiện trường
    • Hỗ trợ
    • Kế hoạch
    • Lịch hẹn
    Năng suất
    • Thảo luận
    • Phê duyệt
    • IoT
    • VoIP
    • Kiến thức
    • WhatsApp
    Ứng dụng của bên thứ ba Studio Odoo Nền tảng Đám mây Odoo
  • Ngành
    Bán lẻ
    • Nhà sách
    • Cửa hàng quần áo
    • Cửa hàng nội thất
    • Cửa hàng tạp hóa
    • Cửa hàng đồ kim khí
    • Cửa hàng đồ chơi
    Ẩm thực & Dịch vụ lưu trú
    • Bar và quán rượu
    • Nhà hàng
    • Đồ ăn nhanh
    • Guest house
    • Nhà phân phối đồ uống
    • Khách sạn
    Bất động sản
    • Công ty môi giới bất động sản
    • Công ty kiến trúc
    • Xây dựng
    • Quản lý bất động sản
    • Làm vườn
    • Hiệp hội chủ sở hữu bất động sản
    Tư vấn
    • Công ty kế toán
    • Đối tác Odoo
    • Công ty marketing
    • Công ty luật
    • Tuyển dụng
    • Thanh tra & chứng nhận
    Sản xuất
    • Dệt may
    • Kim loại
    • Nội thất
    • Ẩm thực
    • Nhà máy bia
    • Quà tặng doanh nghiệp
    Sức khoẻ & fitness
    • CLB thể thao
    • Cửa hàng kính mắt
    • Trung tâm fitness
    • Chuyên gia chăm sóc sức khỏe
    • Hiệu thuốc
    • Tiệm làm tóc
    Thương mại
    • Dịch vụ sửa chữa
    • Phần cứng CNTT & Hỗ trợ
    • Hệ thống năng lượng mặt trời
    • Công ty sản xuất giày
    • Dịch vụ vệ sinh
    • Dịch vụ HVAC
    Khác
    • Tổ chức phi lợi nhuận
    • Cơ quan môi trường
    • Cho thuê biển quảng cáo
    • Nhiếp ảnh
    • Cho thuê xe đạp
    • Đại lý phần mềm
    Xem tất cả ngành
  • Cộng đồng
    Học tập
    • Khóa học
    • Tài liệu
    • Chứng chỉ
    • Đào tạo
    • Blog
    • Podcast
    Thúc đẩy đào tạo
    • Chương trình đào tạo
    • Trò chơi kinh doanh Scale Up!
    • Tham quan Odoo
    Nhận phần mềm
    • Tải xuống
    • So sánh các phiên bản
    • Phiên bản
    Hợp tác
    • Github
    • Diễn đàn
    • Sự kiện
    • Dịch thuật
    • Trở thành đối tác
    • Dịch vụ dành cho Đối tác
    • Đăng ký công ty kế toán của bạn
    Nhận dịch vụ
    • Tìm đối tác
    • Tìm kế toán
    • Gặp chuyên gia hỗ trợ
    • Dịch vụ Triển khai
    • Khách hàng tham khảo
    • Hỗ trợ
    • Nâng cấp
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Nhận một buổi demo
  • Bảng giá
  • Trợ giúp

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

  • CRM
  • e-Commerce
  • Kế toán
  • Tồn kho
  • PoS
  • Dự án
  • MRP
All apps
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Hỗ trợ

smart button v10

Đăng ký nhận tin

Nhận thông báo khi có hoạt động trên bài viết này

Câu hỏi này đã bị gắn cờ
viewssearchbuttons
2 Trả lời
8634 Lượt xem
Ảnh đại diện
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
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Annadurai
Câu trả lời hay nhất

Hello,

use store = True in computed fields.

3
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Bréndou Serge Eric
Câu trả lời hay nhất

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
Ảnh đại diện
Huỷ bỏ
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!

Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!

Đăng ký
Bài viết liên quan Trả lời Lượt xem Hoạt động
Open View from Button Đã xử lý
views buttons
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
2
thg 12 23
19249
Button click and get data from other thirdparty api
views buttons
Ảnh đại diện
Ảnh đại diện
1
thg 7 17
5162
Search in subtree
views search
Ảnh đại diện
Ảnh đại diện
Ảnh đại diện
3
thg 3 15
4960
How to switch to a other view after clicking a button Đã xử lý
views buttons odoo8
Ảnh đại diện
Ảnh đại diện
3
thg 6 21
10193
Text in custom filter condition select dropdown control V12
views search 12
Ảnh đại diện
Ảnh đại diện
2
thg 8 20
4783
Cộng đồng
  • Khóa học
  • Tài liệu
  • Diễn đàn
Open source
  • Tải xuống
  • Github
  • Runbot
  • Dịch thuật
Dịch vụ
  • Lưu trữ Odoo.sh
  • Hỗ trợ
  • Nâng cấp
  • Phát triển tùy chỉnh
  • Đào tạo
  • Tìm kế toán
  • Tìm đối tác
  • Trở thành đối tác
Giới thiệu công ty
  • Công ty của chúng tôi
  • Tài sản thương hiệu
  • Liên hệ
  • Việc làm
  • Sự kiện
  • Podcast
  • Blog
  • Khách hàng
  • Pháp lý • Riêng tư
  • Bảo mật
الْعَرَبيّة 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 là bộ ứng dụng kinh doanh có open source đáp ứng tất cả các nhu cầu của công ty bạn: CRM, thương mại điện tử, kế toán, tồn kho, POS, quản lý dự án, v.v.

Định hướng giá trị riêng biệt của Odoo là tích hợp hoàn toàn và dễ dàng sử dụng.

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