콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
1985 화면

I need customer module and customer info(here api response text)
example ı have one customer jack joe and a get info button 
click button and info comes json format to text field

아바타
취소
작성자 베스트 답변

hebele

아바타
취소

if you are receiving any exception please share those details, when you say its not working, its hard to know what is not working.

작성자

there is no error code ı cant figure it

베스트 답변

yo can follow this steps:

  1. Create a new module: Create a new Odoo module with the necessary files and directories.

  2. Define the customer model: In your custom module, create a new Python file, let's call it customer.py, and define the customer model with the required fields. For example:

from odoo import fields, models

class Customer(models.Model):
_name = 'custom.module.customer'
_description = 'Customer'

​ name =fieldsChar(string='Name')

  1. Define the view: In the same module, create a new XML file, let's call it customer_view.xml, and define the view for the customer model. Include a button and a text field to display the API response. For example:


odoo>
data>
record model="ir.ui.view" id="view_customer_form">
field name="name">custom.module.customer.form
field name="model">custom.module.customer
field name="arch" type="xml">
form>
sheet>
group>
field name="name"/>
button name="get_customer_info" string="Get Info" type="object" class="oe_highlight"/>
field name="api_response_text" widget="text" readonly="1"/>
/group>
/sheet>
/form>
/field>
/record>
 /data>
/odoo>

  1. Implement the button action: In the customer.py file, add a method that will be called when the button is clicked. This method can make the API request and set the API response text in the api_response_text field. For example:

from odoo import models, fields, api

class Customer(models.Model):
_name = 'custom.module.customer'
_description = 'Customer'

name = fields.Char(string='Name')
api_response_text = fields.Text(string='API Response', readonly=True)

@api.multi
def get_customer_info(self):
# Make the API request and obtain the response
api_response = "API response text goes here"

# Set the API response text in the field
self.api_response_text = api_response

Make sure to replace the placeholder API response with the actual code to fetch the customer information from the API.

  1. Update the module manifest: In the __manifest__.py file of your custom module, include the necessary information, such as the module name, dependencies, and views.

After implementing these steps, you should be able to install the module and see the customer form view with the "Get Info" button. Clicking the button will trigger the get_customer_info() method, and the API response text will be displayed in the api_response_text field.



아바타
취소