chương 13: code trên Erp

36 499 0
chương 13: code trên Erp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Customizing Odoo for Your Business In this chapter, we will cover one of the greatest advantages of Odoo—the ability to customize the software to meet the unique needs of your business Fortunately, Odoo provides a great deal of flexibility in which you can customize Odoo without writing any code or developing a module We will begin by learning how to activate the Odoo developer mode and then back up our database This is a very important practice when customizing Odoo Next, we will learn how to add fields to our database and display them on forms and views Note that customizing Odoo is a very broad topic that would take many chapters to describe You might consider this to be an introduction to customization The following topics are covered in this chapter: • Entering and exiting the developer mode • Backing up our database • Restoring data from a backup • Appending custom fields to models • Displaying our newly added fields upon forms and list views Activating the developer mode To customize Odoo, the first step is to activate the developer mode Once you enter this mode, Odoo will provide you with a lot more onscreen information as you navigate through the interface This mode also allows you to make changes to the database and store that information in a file Trong chương này, bao gồm lợi lớn Openerp-khả tùy chỉnh phần mềm để đáp ứng nhu cầu riêng doanh nghiệp bạn May mắn thay, Openerp cung cấp linh hoạt, bạn tùy chỉnh Openerp mà không cần viết mã phát triển mô-đun Chúng bắt đầu cách học làm để kích hoạt chế độ phát triển Openerp sau lưu sở liệu Đây thực tế quan trọng tùy chỉnh Openerp Tiếp theo, tìm hiểu làm để thêm lĩnh vực sở liệu hiển thị chúng hình thức quan điểm Lưu ý tùy Openerp chủ đề rộng nhiều chương để mô tả Bạn xem giới thiệu tùy biếnnày: Các chủ đề đề cập chương • Bước vào rachế độ phát triển • Backinglên sở liệucủa • Khôi phụcdữ liệu từ lưu • Phụ thêm lĩnh vực tùy chỉnh để mô hình • Hiển thị lĩnh vực bổ sung theo hình thức List kích hoạt chế độ phát triển để tùy chỉnh Openerp, bước để kích hoạt chế độ nhà phát triển Khi bạn vào chế độ này, Openerp cung cấp cho bạn nhiều thông tin hình bạn điều hướng thông qua giao diện Chế độ cho phép bạn thực thay đổi sở liệu lưu trữ thông tin tập tin Customizing Odoo for Your Business To activate the developer mode, go to the menu in the top-right corner of the screen This menu will have the label of the user you are currently logged in as In our case, this is the Administrator menu Choose About Odoo from the menu: Để kích hoạt chế độ phát triển, vào menu góc bên phải hình Menu có nhãn bạn dùng để đăng nhập Trong trường hợp chúng tôi, Administrator menu Chọn Về Openerp từ trình đơn: Once you have entered this screen, you can click on Activate the developer mode to begin customizing Odoo Odoo recognizes that you are in the developer mode by adding &debug=# to the URL in your web browser Additionally, Odoo changes the information that is provided when you hover over various fields in the interface For example, when viewing a sales order record while in the developer mode, you can move the cursor over the Date field to reveal details about how that field is represented internally in Odoo Một bạn bước vào hình này, bạn nhấp vào Kích hoạt chế độ phát triển nhàđể bắt đầu tùy chỉnh Openerpbạn Openerp nhận bạn chế độ phát triển cách thêm & debug = # để URL trình duyệt web Ngoài ra, Openerp thay đổi thông tin cung cấp bạn di chuột qua lĩnh vực khác giao diện Ví dụ, xem kỷ lục đơn đặt hàng chế độ phát triển, bạn di chuyển trỏ ngày lĩnh vựcđể tiết lộ chi tiết cách lĩnh vực đại diện nội Openerp The preceding screenshot demonstrates how Odoo displays information while you are in the developer mode In this example, we can see that the Date field is named date_order and that the field belongs to the sale.order object Additionally, we can see the field type is date and there are modifiers assigned to the field This type of information will be of great value as you continue to customize Odoo Các ảnh chụp hình trước cho thấy cách Openerp hiển thị thông tin bạn chế độ phát triển Trong ví dụ này, thấy ngày trườngđược đặt tên date_order lĩnh vực thuộc đối tượng sale.order Ngoài ra, thấy loại hình trường ngày có bổ gán cho lĩnh vực Loại thông tin có giá trị lớn bạn tiếp tục tùy chỉnh Openerp Getting out of the developer mode Now that you are in the developer mode, there will come a time when you want to exit the developer mode and work with Odoo as you normally would To exit the developer mode, simply remove debug=# from the URL string in your browser: Bắt khỏi chế độ phát triển Bây bạn chế độ phát triển, có thời gian bạn muốn thoát khỏi chế độ phát triển làm việc với Openerp bạn bình thường Để thoát khỏi chế độ phát triển, cần loại bỏ debug = # từ chuỗi URL trình duyệt bạn: Make sure you leave the & symbol in place when you remove the debug tag from the URL If you get any errors or other unusual behavior after removing debug=# from your URL, you can typically use your browser's back button If this also fails, you can always restart the browser and log back in to Odoo Hãy chắn bạn để lại ký hiệu & chỗ bạn loại bỏ thẻ debug từ URL Nếu bạn nhận lỗi hành vi bất thường khác sau gỡ bỏ debug = # từ URL bạn, bạn thường sử dụng nút quay lại trình duyệt bạn Nếu điều thất bại, bạn khởi động lại trình duyệt đăng nhập trở lại để Openerp Customizing Odoo for Your Business Backing up your database When you make changes while in the developer mode, those changes are written into the database associated with the company One of the major advantages of this approach is that you not have to write code in Python or create a custom module to implement simple customizations One of the major disadvantages, however, is that there is the potential that you could make a change that is undesirable and perhaps difficult to reverse Therefore, it is very important and highly recommended that you make backups of your database both before and after you make any customization through the developer mode Do not skip this step! It is always a good idea to frequently back up your database However, it is absolutely imperative that you back up your database before undertaking any customization To back up your database, you must first log out of Odoo After you have successfully logged out, click on the Manage Databases link on the login form From this screen, you click on the Backup link in the top-left corner of the Database Management menu: Saolên sở liệu bạn bạn thực thay đổi chế độ nhà phát triển, thay đổi ghi vào sở liệu liên quan đến công ty Một ưu điểm phương pháp bạn không cần phải viết mã Python tạo mô-đun tùy chỉnh để thực tùy chỉnh đơn giản Một nhược điểm lớn, nhiên, có tiềm mà bạn làm cho thay đổi không mong muốn có lẽ khó đảo ngược Vì vậy, quan trọng khuyến khích bạn thực lưu sở liệu bạn trước sau bạn thực tùy biến thông qua chế độ phát triển Đừng bỏ qua bước này!Nó luôn ý tưởng tốt để thường xuyên lưu sở liệu bạn Tuy nhiên, hoàn toàn bắt buộc mà bạn lưu sở liệu bạn trước thực tuỳ biến Để lưu sở liệu bạn, trước tiên bạn phải đăng nhập Openerp Sau bạn đăng nhập thành công, nhấn vào ManageDatabases liên kết mẫu đăng nhập Từ hình này, bạn bấm vào Backup liên kếttrong góc bên trái Quản lý Cơ sở menuliệu: Chapter 13 To back up your database, select the database from the pop-up menu and enter the master password for the Odoo installation (by default, Master Password will be admin) Next, click on the Backup button After you click on the Backup button, Odoo will then save your database to your local drive Depending on the browser you are using and the settings in your browser, the prompt you will get to save your file will vary The default filename will end with the dump extension After you save your file, Odoo will download it into the directory you have specified If this is the first time you have backed up your database, you should also take the time to verify that you can successfully restore the database While this may seem like an unnecessary exercise, it is important to remember that a backup is only as good as your ability to successfully restore it Restoring a database in Odoo To restore a database in Odoo, click on the Restore option in the Database Management menu: Để lưu sở liệu bạn, chọn sở liệu từ menu pop-up nhập mật cho việc cài đặt Openerp ( theo mặc định, Thầy Mật admin) Tiếp theo, nhấn vào Backup nút Sau bạn nhấp vào Backup, nút Openerp sau lưu sở liệu bạn vào ổ đĩa địa phương bạn Tùy thuộc vào trình duyệt bạn sử dụng thiết lập trình duyệt bạn, nhắc nhở bạn nhận để lưu tập tin bạn thay đổi Các tên tập tin mặc định kết thúc với phần mở rộng dump Sau bạn lưu tập tin bạn, Openerp tải vào thư mục mà bạn định Nếu lần bạn lưu sở liệu bạn, bạn nên dành thời gian để xác minh bạn khôi phục thành công sở liệu Trong điều giống tập không cần thiết, điều quan trọng nhớ lưu tốt khả bạn để khôi phục thành công Khôi phục sở liệu Openerp Để khôi phục lại sở liệu Openerp, click vào Restore tùy chọn quản lý sở liệu menu: To restore your database, you need to provide three pieces of information—the backup File you want to restore, Master Password of Odoo, and New database name Clicking on the Browse button in the file selection area will prompt you to select the dump file that was created when you performed the backup để khôi phục lại sở liệu bạn, bạn cần cung cấp ba mẩu thông lưu tin-file mà bạn muốn khôi phục, Master Password Openerp, tên sở liệumới.Nhấp vào Browse núttrong khu vực lựa chọn tập tin nhắc bạn chọn tập tin dump tạo bạn thực lưu Customizing Odoo for Your Business After you have specified the file and the other required fields, click on Restore to begin restoring the database A small progress bar at the bottom left of the browser will update you on the progress of the restore Once the restore is complete, log in to the database to make sure everything is working as expected Now with a successful backup and restoration, you are ready to begin customizing Odoo If something goes wrong, you will have the ability to restore your backup While customizing Odoo, remember to back up the database frequently and test the restore process often Adding a custom field to Odoo One of the most common reasons for customizing Odoo is to collect additional information that is specific to your company If you are running an insurance company, perhaps you want to specify the policy number on your sales order If you are working in property management, perhaps you would like to store the date in which the lease agreement will expire For our working example, we will be adding fields that will help us better manage the data and processes for our silkscreen company Specifically, we will be adding the following fields to the sales order header: Field name x_daterequired Label Date Required Field Date x_rush Rush Order Boolean [ 300 ] Purpose In the screen printing industry, deadlines drive when the production must begin and when the product should be The necessity to flag some sales orders as rush orders is related to Date Required A Rush Order label can then be prioritized and given expedited Customizing Odoo for Your Business Adding another field to the sales order form Following the same procedure, let's add the Rush Order checkbox to the Sales Order form If you get lost, simply refer to the procedure for adding the Date Required field to the form Here is a summary of the process: Select Manage Views from the pop-up menu on the top-left corner of the form Click on the Edit button to modify the view Scroll down and click on the + icon to the right of the x_daterequired field that we just added Click on New Field on the Properties form Fill out the form using x_rush for Field Name, Rush Order for Field Label, and Boolean for Field Type Do not check the Required field for this field as we want the ability to not have the Rush Order option checked Click on Save to store your new settings for the field Click on Update to tell Odoo to add the new field to the view Click on Update again to accept the default values for the field view Click on Close to exit the View Editor 10 Click on Close again to exit the Manage Views form thêmkhác trường vào mẫu đơn đặt hàng bán hàng sau quy trình này, thêm vào Rush thứ tự hộp kiểm bán hàng đặt mẫuhàng.Nếu bạn bị lạc, bạn cần tham khảo thủ tục cho việc thêm bắt buộc ngày lĩnh vựcmẫutrình: Dưới tóm tắt Chọn Quản lý nhìn từ menu pop-up góc bên trái hình thứcvào Click chỉnh sửa nút để thay đổi quan điểm Cuộn xuống nhấn vào + biểu tượng dấubên phải x_daterequired trườngmà vừa thêm Nhấn vào New Fieldtrên Properties hình thức [ 56 ] Điền vào biểu mẫu sử dụng x_rush cho TênField,Rush tự cho DòngLabel,và Boolean cho FieldType Không kiểm tra thôngbắt tinbuộcđối với lĩnh vực muốn có khả Rush tự tùy chọnkiểm tra Nhấp vào Save để lưu cài đặt cho lĩnh vực Click vào Update để nói Openerp thêm lĩnh vực để xem Click vào Update lần để chấp nhận giá trị mặc định cho điểm trường Nhấn Close để thoát khỏi biênsoạn 10 Nhấn Close lần để thoát Quảnlý xem hình [ 57 ] Chapter 13 If you have followed the preceding steps, you should now have the Rush Order checkbox added to the Sales Order form Using the same method, you can add fields to almost any form within Odoo Adding a field to an existing view After adding our fields to the sale.order model and displaying them on the Sales Order form, it would be nice to include these fields in our sales order listing This way, users can see at a glance when orders are due and know whether they are rush orders [ 58 ] Customizing Odoo for Your Business We begin by going to the Sales Order list view and choosing Manage Views Next, click on Edit to bring up the View Editor for the sales order list: You will notice that this list is far less complex than the one for the Order Sales form view This is simply because a list view (also known as a tree view) has much fewer options and fields on it than a form that edits and manages the data for just one record at a time Click on the + to the right of the date_order field This will pop open the Properties window: [ 59 ] [ 60 ] Chapter 13 After selecting x_daterequired in the list, click on the two Update buttons Then, you can follow the same process to add the x_rush field to the list view Finally, click on the Close buttons to shut the View Editor as well as the Manage Views form The screen will refresh, and you will see our two new fields in the Sales Order list view As you can see, it is pretty easy to create new fields and then add those fields to views and forms Customizing search operations in Odoo In addition to having the ability to modify the forms and list views in Odoo, you can also customize searching in Odoo to better fit the needs of your organization For example, when customers place orders, it is common in a business-to-business scenario that you will be provided a purchase order or another source document that the customer references internally By default, Odoo does not include the source document field in your search You must use the Advanced Search function each and every time, in order to look up a customer's order by the source document that they have provided to you As in much of this book, this example comes from a real case scenario When customers call, often they might not have an invoice number or sales order number from your company; instead, they might only have their internal source document Let's see how we can customize Odoo to more easily search on [ 61 ] the Source Document field in the sales order [ 62 ] Customizing Odoo for Your Business Specifying additional fields you wish for Odoo to use in the search One of the greatest features of Odoo's developer tools is that you can hover over any field in a form and see important information about that field For our example, we are going to hover over the Source Document field to learn how this field is represented within Odoo's database As you can see, the field name for the Source Document field in the sales order is origin We can also verify that this field belongs to the sale.order object and it is of Type char We will use this information to modify the search view so that we can add the ability to search for the source document in our list view without using the advanced search Editing the search view You edit the search view by navigating to the list for the search you wish to modify In this case, we will simply click on Sales Orders under the main Sales menu Then, under the Debug View menu, choose Edit SearchView [ 310 ] Chapter 13 The XML for the search view, as shown here, will appear for you to edit: Take a little time to look at the structure of this form You will see that many tags start with [...]... và phục hồi thành công, bạn đã sẵn sàng để bắt đầu tùy chỉnh Openerp Nếu có điều gì sai, bạn sẽ có khả năng để khôi phục lại bản sao lưu của bạn Trong khi tùy biến Openerp, nhớ sao lưu cơ sở dữ liệu thường xuyên và kiểm tra quá trình khôi phục thường Thêm một thông tin để Openerp Một trong những lý do phổ biến nhất cho các tùy biến Openerp là để thu thập thêm thông tin nào cụ thể về công ty bạn Nếu... ưu tiên và đưa ra quyết nhanh điều trị _ 13 Chương Tênlĩnh vực hải quan tại Openerp nên được đi trước bởi X_ Điều này là để tên trường trong các phiên bản tương lai Openerp và cập nhật tiêu chuẩn sẽ không vô tình mâu thuẫn với các lĩnh vực tùy chỉnh bạn đã thêm Cách dễ nhất để thêm một lĩnh vực tùy chỉnh mẫu là bằng cách sử dụng một trình đơn xuất hiện trên hình thức đó Trong trường hợp này, chúng... của chúng tôi để hình thành Đặt Vị trí trườngđể AfterA, mà nói Openerp mà chúng tôi muốn thêm lĩnh vực mới của chúng tôi sau khi lĩnh vực client_order_ref trên xem mẫu [ 50 ] Nếu trường chúng ta muốn hiển thị các đã tồn tại trong mô hình sale.order, chúng tôi chỉ có thể chọn nó từ pop-up menu bên cạnh lĩnhvực,và nó sẽ được hiển thị trên giao diện mẫu Thay vào đó, nhấp chuột vào New Field nútđể thêm... dụng Nhóm danh sáchở phía dưới Để bây giờ, chúng tôi sẽ chấp nhận tất cả các giá trị mặc định và bấm vào Cập nhật để đóng màn hình này Tiếp đến, kích vào Close trên View Editor cửa sổvà một lần nữa nhấn vào Close trên Manage xem cửasổvào: Openerp sẽ tự động làm mới các hàng đơn đặt hình thứchàng,cho phép bạn xem các ngàybắt buộc Dòngbạn vừa thêm [ 55 ] Customizing Odoo for Your Business Adding another... lĩnh vực để xuất hiện trên biểu mẫu Ví dụ, chúng ta có thể ghi đè lên nhãn lĩnh vực, chúng tôi thiết lập trong các thuộc địa bằng cách xác định một giá trị khác nhau trong chuỗi lĩnh vựcvào mẫu này Một Name trườngcó thể chứa tối đa 64 ký tự chữ số và dấu gạch dưới nhưng không có ký tự đặc biệt khác và không gian Tên thường có thể xuất hiện khó hiểu, nhưng người dùng cuối Openerp thường không cần đến... trường client_order_ref Nó được chọn trong các ảnh chụp màn hình trước và gắn nhãn Xem biên tập 637 sale.order- Bây giờ, nhấp chuột vào cộng nhỏ màu xanh(+).biểu tượng trong tập hợp các nút trên bên phải Điều này cho Openerp mà bạn muốn thêm một trường tại vị trí cụ thể trong xem After clicking on the plus (+) icon, you are presented with a Properties form The Node Type field is prepopulated with field,... buộc ngày lĩnh vựcmẫutrình: Dưới đây là một bản tóm tắt của quá 1 Chọn Quản lý nhìn từ menu pop-up ở góc trên bên trái của hình thứcvào 2 Click chỉnh sửa nút để thay đổi quan điểm 3 Cuộn xuống và nhấn vào + biểu tượng dấubên phải của x_daterequired trườngmà chúng ta vừa thêm 4 Nhấn vào New Fieldtrên Properties hình thức [ 56 ] 5 Điền vào biểu mẫu sử dụng x_rush cho TênField,Rush tự cho DòngLabel,và... hàng đặt hình thứchàng.Để bắt đầu thêm một lĩnh vực, điều hướng đến bán hàng | Đơn đặt hàng bánhàng,mở một trật tự trong giao diện hình thức, và chọn Manage xem từ menu pop-up của nhà phát triển ở góc trên bên trái của biểu mẫu Thực đơn của nhà phát triển không có một nhãn hiệu nhưng hiển thị gỡ lỗi Xem # là lựa chọn đầu tiên của nó [ 47 ] Customizing Odoo for Your Business By default, Odoo will select... view currently selected is the sale order.form view (For now, ignore other values such as External ID and Inherited View.) Click on the Edit button to modify the sale.order.form view Theo mặc định, Openerp sẽ chọn xem bạn là khi bạn chọn xemManage tùy chọntừ menu Trong trường hợp này, quan điểm đang được chọn là việc bán hàng.order.form xem (Đối với doanh nghiệp, bỏ qua các giá trị khác như ID bên ngoài... x_daterequired in the pop-up list At this point, the field has been added to the sale.order model in the database We are now ready to add this field to our Sales Order form Click on Update to proceed: Openerp sẽ tự động chọn x_daterequired trong danh sách pop-up Tại thời điểm này, lĩnh vực này đã được thêm vào mô hình sale.order trong cơ sở dữ liệu Bây giờ chúng ta đã sẵn sàng để thêm các lĩnh vực này đểcủa

Ngày đăng: 27/04/2016, 17:23

Từ khóa liên quan

Mục lục

  • Customizing Odoo for

    • Activating the developer mode

    • kích hoạt chế độ phát triển

      • Getting out of the developer mode

      • Bắt ra khỏi chế độ phát triển

      • Backing up your database

      • Saolên cơ sở dữ liệu của bạn

        • Restoring a database in Odoo

        • Khôi phục cơ sở dữ liệu trong Openerp

        • Adding a custom field to Odoo

        • Thêm một thông tin để Openerp

          • Adding another field to the sales order form

          • thêmkhác trường vào các mẫu đơn đặt hàng bán hàng

          • Adding a field to an existing view

            • Customizing search operations in Odoo

              • Specifying additional fields you wish for Odoo to use in the search

              • Editing the search view

              • Examining the models in Odoo

              • Summary

Tài liệu cùng người dùng

Tài liệu liên quan