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

I know I can write code and create a module to add custom fields to Odoo.

I also know that custom fields can be added via the User Interface easily.  Is it possible to create a new field that gets it value automatically (by a calculation) from another set of fields?

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

1.  Enable the option to show Margins on Sales Orders:

       Sales --> Configuration --> Settings  

     


2.  Add the field via the User Interface:

      Settings --> Technical --> Database Structure --> Fields

      Create

      

The code for the Compute section is:

for record in self:
    if record['amount_total'] > 0: 
record['x_margin_percentage'] = record['margin'] / record['amount_total']


3. Add the field to the User Interface, by creating a view that inherits and overrides the Odoo Sales Order Form view that adds the margin field:

      Settings --> Technical --> User Interface --> Views

      Create

      

The XML for the Architecture field is:

<field name="margin" position="after">    
<field name="x_margin_percentage">
</field>


Finished Customization:


아바타
취소

Note: You may also want to use amount_untaxed instead of amount_total if you don't want tax included in the margin calculation

베스트 답변

Hello Ray,

I saw what you did there and  I was wondering if you can provide info on how can I create a turnover average, which measures the number of each product divided by 365 days. So for every product, I can see how many units are sold per day.

Thanks in advance!

아바타
취소
관련 게시물 답글 화면 활동
0
5월 20
6225
4
10월 16
4094
1
6월 16
11258
1
5월 16
5802
2
3월 15
8582