我只需要搜索视图并删除保存按钮。
如果您搜索并带来了必要的数据,但是我不需要显示“保存并新建”按钮,即只允许我根据所选的客户进行咨询。
我尝试下一个: 此函数搜索然后在字段中设置值。
@api.multi
@api.onchange('partner_id')
def _onchange_partner_id(self):
"""Método que busca el número de CI o Ruc digitado para cargar datos automaticamente"""
if self.partner_id:
contract_id = self.env['plan.partner.contract'].search([('partner_id', '=', self.partner_id.id)])
if contract_id:
for record in contract_id:
car_ids = self.env['plan.car'].search([('contract_id','=',record.id)])
self.contract_id = record.id
self.partner_ruc_id = record.partner_ruc_id
self.number_paid_fees = record.number_paid_fees
self.number_pending_fees = record.number_pending_fees
self.number_future_fees = record.number_future_fees
self.paid_amount = record.paid_amount
self.anticipated_amount = record.anticipated_amount
self.pending_amount = record.pending_amount
self.partial_amount = record.partial_amount
self.number_partial_fees = record.number_partial_fees
self.partial_amount_a = record.partial_amount_a
self.number_partial_a_fees = record.number_partial_a_fees
self.plan_car_id = car_ids
else:
raise Warning(_(
"Identification Number does not exist"))
答案 0 :(得分:0)
我满足了我的要求: 我使用向导,仅用于搜索: Python代码:
class plan_web_wallet_wizard(osv.osv_memory):
_name = 'plan.web.wallet.wizard'
_description = 'Web Wallet Wizard'
contract_id = fields.Many2one('plan.partner.contract', 'Plan Partner', Contract')
partner_id = fields.Many2one('res.partner',related='contract_id.partner_id')
plan_car_id = fields.One2many('plan.car',
related='contract_id.schedule_pay_ids')
@api.one
@api.depends('partner_id', 'ident_num')
def count_bidding_1(self):
bidding_obj = self.env['plan.bidding']
for record in self:
bidding_id = bidding_obj.search([('contract_id', '=', record.contract_id.id)])
if bidding_id:
self.count_bidding = len(bidding_id)
@api.onchange('partner_id')
def onchange_partner_id(self):
contract_obj = self.env['plan.partner.contract']
for record in self:
contract_id = contract_obj.search([('partner_id', '=', record.partner_id.id)])
if contract_id:
for contract in contract_id:
self.contract_id = contract.id
contract.calculate_summary()
@api.onchange('ident_num')
def onchange_ident_num(self):
contract_obj = self.env['plan.partner.contract']
for record in self:
contract_id = contract_obj.search([('ident_num', '=', record.ident_num)])
if contract_id:
for contract in contract_id:
self.contract_id = contract.id
XML文件:
<form string="wallet" name="wallet">
<sheet name="web_wallet" string="Web Wallet">
<h1 class="text-center" name="wellcome">
<label string="Wellcome Web Wallet"/>
</h1>
<br/>
<group name="search_contract" col="4">
<field name="partner_id" string="Customer" options="{'no_create_edit': True, 'no_open':True}"
domain="[('customer','=',1),('partner_state','=','adherent')]"/>
<field name="ident_num" string="RUC/CC" placeholder="Search identification number"/>
<field name="contract_id" string="Contract" domain="[('ident_num','=',ident_num)]"
options="{'no_create_edit': True, 'no_open':True}"/>
</group>
<notebook name="web_wallet">
<page name="contract_summary" string="Contract Summary">
<h1 name="string" class="text-center">
<label string="Contract Summary"/>
</h1>
</page>
<page name="web_paids" string="Contract Paids">
<h1 name="string" class="text-center">
<label string="Pagos Programados"/>
</h1>
<group name="paids">
<field name="plan_car_id" mode="tree" nolabel="1" readonly="1">
<tree string="List Paid Quotas" editable="false" readonly="1"
colors="blue:state=='draft';black:state=='done';gray:state=='cancel'">
<field readonly="1" name="plan_payment_number"/>
<field readonly="1" name="date_to"/>
<field readonly="1" name="name"/>
<field readonly="1" name="state"/>
<field readonly="1" name="contract_id"/>
<field readonly="1" name="partner_id" invisible="1"/>
<field readonly="1" name="inscription_quota" sum="Inscription" string="C.Ins."/>
<field readonly="1" name="capital_quota" sum="Capital" string="C.Cap."/>
<field readonly="1" name="administrative_quota" sum="Administrative" string="C.Adm."/>
<field readonly="1" name="monthly_quota" sum="Monthly" string="C.Mensual"/>
<field readonly="1" name="total_iva" sum="IVA" string="IVA"/>
<field readonly="1" name="total_quota" sum="Total" string="Total"/>
<field readonly="1" name="pay_type"/>
<field readonly="1" name="company_id" invisible="1"/>
<field readonly="1" name="plan_run_id" invisible="1"/>
</tree>
</field>
</group>
</page>
</notebook>
</sheet>
<footer>
<button special="cancel" string="Cerrar" class="oe_link"/>
</footer>
</form>