콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
I've inherited the `view_order_product_search` view with: 

<?xml version="1.0" encoding="utf-8"?> <odoo> <record id="view_order_product_search_inherit" model="ir.ui.view"> <field name="name">sale.report.search.extend</field> <field name="model">sale.report</field> <field name="inherit_id" ref="sale.view_order_product_search"/> <field name="arch" type="xml"> <field name="date" position="after"> <field name="is_paid" /> <filter name="Pagado" string="Pagado" domain="[('is_paid', '=', True)]"/> </field> </field> </record> </odoo>
_____________________________________________________
And the inherited model like (UPDATED):

```
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import tools
from odoo import fields, models

import logging
_logger = logging.getLogger(__name__)

class SaleReport(models.Model):
_inherit = ['sale.report']
is_paid = fields.Boolean(string='Payment Received?', readonly=True)

def _query(self, with_clause='', fields={}, groupby='', from_clause=''):
fields['is_paid'] = ", s.is_paid as is_paid"
return super(SaleReport, self)._query(with_clause, fields, groupby=', s.is_paid')
```
_________________________________
and i'm able to install my moudule an Odoo 14 I have on my local raspberry, but when i try to install the module on a remote Odoo 13 I get:
El campo `is_paid` no existe
Contexto del error:
Vista `sale.report.search.extend`
[view_id: 1852, xml_id: n/a, model: sale.report, parent_id: 736]
None" while parsing /opt/bitnami/apps/odoo/data/addons/13.0/pagado/report/sale_report_extended_views.xml...


I've checked and the `is_paid` column has been added to the `sale_order` table (cause i also added the field there) but I cannot see a `sales_report` table...

Also reading other posts I see it may be a deps problem, and I'm not sure which deps should I add besides: `'depends': ['base', 'sale'],`

Can i get some help here? I've been looking for days...

아바타
취소
베스트 답변

Hi,

Can you try with this?

def _query(self, with_clause='', fields={}, groupby='', from_clause=''):
    fields['invoice_status'] = ', s.invoice_status as invoice_status'
    groupby += ', s.invoice_status'
    return super(SaleReport, self)._query(with_clause, fields, groupby, from_clause)
 

you need to remove groupby=', s.is_paid' while returning the call.

and ADD Dependency ---> sale_management
아바타
취소
작성자 베스트 답변

thanks for your help Niyas. I've updated my code as you suggested (you can see the update on my initial post), but the problem still persists, I think its a problem with the view, cause I manage to install the module without all the `report/` code and if I go to edit the view directly on the Odoo's frontend I get the exact same error...

아바타
취소
작성자

also if in developer mode I go to the 'View fields' of the sale.order model I see the field listed there...

베스트 답변

Hi,

You have to inherit the  query of the sale.report model that creates this view and add the field into it. See an example of adding  margin field to the same model after inheriting.

class SaleReport(models.Model):
_inherit = 'sale.report'

margin = fields.Float('Margin')

def _query(self, with_clause='', fields={}, groupby='', from_clause=''):
fields['margin'] = ", SUM(l.margin / CASE COALESCE(s.currency_rate, 0) WHEN 0 THEN 1.0 ELSE s.currency_rate END) AS margin"
return super(SaleReport, self)._query(with_clause, fields, groupby, from_clause)


Thanks

아바타
취소
관련 게시물 답글 화면 활동
0
6월 22
2383
2
5월 23
2410
0
1월 24
169
1
4월 23
2214
0
4월 22
2852