Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
2768 Visualizzazioni
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...

Avatar
Abbandona
Risposta migliore

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
Avatar
Abbandona
Autore Risposta migliore

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...

Avatar
Abbandona
Autore

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

Risposta migliore

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

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
giu 22
2173
2
mag 23
2181
0
gen 24
169
1
apr 23
2008
0
apr 22
2593