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

My goal is to show the not invoiced amount of salesorders grouped by delivery date with a graph.


for this i created a custom field (type float, since we invoice in EUR and CHF and i dont want to mess around with currency problems and for forecasting is this ok) which gets calculated like this:

for record in self:

    record['x_offener_betrag_calc'] = record.amount_total - record.amount_invoiced


the field works properly, i also can aggregate it in lists with sum. but somehow i cant use it in the diagram view. two problems here:

1. i cant select the field in the "values" list and dont find any possibilit to bring it there.

2. if i add filter and adjust the context manually like this:


{'group_by': ['commitment_date:month', 'partner_id'], 'graph_measure': 'x_offener_betrag_calc', 'graph_mode': 'bar', 'graph_groupbys': ['commitment_date:month', 'partner_id'], 'graph_order': None, 'graph_stacked': True}


then i get the following error when applying the filter:


Uncaught Promise > No aggregate function has been provided for the measure 'x_offener_betrag_calc'


has anybody an idea how to make that work?


아바타
취소
베스트 답변

Hi,

Make your field stored, then Odoo can aggregate it.

Example:

x_offener_betrag_calc = fields.Float(

    string="Not Invoiced Amount",

    compute="_compute_offener_betrag",

    store=True

)


@api.depends('amount_total', 'amount_invoiced')

def _compute_offener_betrag(self):

    for record in self:

        record.x_offener_betrag_calc = record.amount_total - record.amount_invoiced


Now your field is stored in the database, so you can use it in graph views, pivot views, and filters.


You can sum it by month, partner, or any other group.


Hope it helps

아바타
취소
베스트 답변

Hii,


In your model, update the field like this:

x_offener_betrag_calc = fields.Float(

    string="Not Invoiced Amount",

    compute="_compute_offener_betrag",

    store=True,

    group_operator='sum',  # ← This line is required!

)

@api.depends('amount_total', 'amount_invoiced')

def _compute_offener_betrag(self):

    for record in self:

        record.x_offener_betrag_calc = record.amount_total - record.amount_invoiced

Example Graph View XML with the Custom Field:

<record id="view_sale_order_graph_offener_betrag" model="ir.ui.view">

    <field name="name">sale.order.graph.offener.betrag</field>

    <field name="model">sale.order</field>

    <field name="arch" type="xml">

        <graph string="Open Sales by Delivery Date" type="bar" stacked="True">

            <field name="commitment_date" type="row" interval="month"/>

            <field name="partner_id" type="row"/>

            <field name="x_offener_betrag_calc" type="measure"/>

        </graph>

    </field>

</record>

 i  hope it is use full

아바타
취소
관련 게시물 답글 화면 활동
2
11월 25
98
0
11월 25
54
0
11월 25
74
4
11월 25
214
0
11월 25
138