Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
6178 มุมมอง

Hello All,

i inherited crm view and added a button on that form. And applied function for open that customer form from crm form. But after clicking on that button i'm getting error "ValueError: Field 'padding' does not exist".

I my sharing my python and xml code as well as screenshot of error:

class CustomCRM(models.Model):
_inherit = 'crm.lead'

@api.multi
def open_customer_view(self):
ir_model_data = self.env['ir.model.data']
view_id = ir_model_data.get_object_reference('base', 'action_partner_form')[1]
partner = self.env['res.partner'].browse(self.partner_id.id)
print("PARTNERS", partner, view_id)
if partner:
res = {

'view_type': 'form',
'view_mode': 'tree',
'views': [(view_id, 'form')],
'res_model': 'res.partner',
'view_id': view_id,
'type': 'ir.actions.act_window',
'res_id': partner.id,
'target': 'fullscreen',
# 'context': ctx,
}
return res
<record id="view_custom_crm_lead_form" model="ir.ui.view">
<field name="name">CustomCrmLead</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
<field name="arch" type="xml">
<data>
<xpath expr="//header//button[@name='action_set_won']" position="after">
<button name="open_customer_view" string="Customer Form" type="object"
class="btn-primary"/>
</xpath>
</data>
</field>
</record>


Thanks in advance

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

If Padding is custom field added by you. Then add that field into xml form you also and make it invisible if you want. 

Check the same after upgrading your module.

อวตาร
ละทิ้ง
ผู้เขียน

I'm not added any kind of 'padding' field in python.

ok...then upgrade base module separately first and see the result

Go to Apps -> search for 'base' -> click on upgrade

ผู้เขียน

Upgraded but still getting same error.

view_id = ir_model_data.get_object_reference('base', 'action_partner_form')[1]

In above statement your getting object reference of an action. You have to get object refernce of its form view . action_partner_form is an action not a form view.

If you want to open a customer form then use this :

view_id = ir_model_data.get_object_reference('base', 'view_partner_form')

verify the view_id is correct or not before executing the solution

ผู้เขียน

Ohh.. Thanks. silly mistake in function.

คำตอบที่ดีที่สุด

Hello,

padding field added in xml and forgot in python file

(or)

you forgot to upgrade your module after restart the server

อวตาร
ละทิ้ง
ผู้เขียน

I'm inherite default CRM and only added single button with above python function. No extra field added in python and xml file.

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
พ.ย. 17
4580
0
พ.ย. 17
3593
multiple images with preview in products แก้ไขแล้ว
2
ธ.ค. 17
12902
1
ต.ค. 17
2768
0
ก.พ. 25
1032