Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
1185 Vistas

I have a module created as follows: 









But, when I try to install the module app, it gives me this error, as shown in the print below, I have already tried all the ways to correct the div for sheet or group, but this error always returns, can someone help me, what did I do wrong?


Thank you in advance!


Avatar
Descartar
Autor

I made the relationship as I send the print here, but as I said the error persists.

from odoo import models, fields

class SaleOrder(models.Model):
_inherit = 'sale.order'

use_csv_purchase = fields.Boolean(related='partner_id.use_csv_purchase', string='CSV')

def _prepare_purchase_order(self, partner):
resultado = super()._prepare_purchase_order(partner)
if partner.use_csv_purchase:
resultado['notes'] += '\n' + self.use_csv_purchase_text
return resultado

In your inherited form view change the below:

<field name="partner_id.use_csv_purchase"/>

to

<field name="use_csv_purchase"/>

Autor

Thank you very much. I think it worked now :)

Mejor respuesta

You don't have use_scv_purchase field in sale.order, if you want to use it in form view you need to create it as related field to partner_id.use_scv_purchase in sale.order.


and change it in view as below:

<field name="use_csv_purchase"/>




Avatar
Descartar
Mejor respuesta

Hello,

In order to display the value of the partner_id.use_csv_purchases field in the view, you need to create a related field for it. To do this, you can add the following code snippet to the sale order Python file:

use_csv_purchases = fields.Boolean(related='partner_id.use_csv_purchases')

After adding this code, you can update the XML field to:

<field name="use_csv_purchases"/> <!-- line 15 -->

By doing this, a related field will be created that retrieves the value of the use_csv_purchases field from the partner_id field

Regards

Avatar
Descartar
Autor

Thank you very much colleague, I did as Waleed Ali Mohsen instructed me and it worked! Thank you for the help :)

Autor Mejor respuesta

Even though I correlated the field in the model, the error I showed above still persists, I already restarted the server, and it continues with the same problem. That means it doesn't allow me to install the app because of this. 

Error while validating view near:







Field "partner_id.use_csv_purchase" does not exist in model "sale.order"

View error context:
{'file': 'c:\\odoo\\odoo\\addons\\partner_add\\views\\sale_order_view.xml',
'line': 9,
'name': 'sale.order.form.inherit',
'view': ir.ui.view(1384,),
'view.model': 'sale.order',
'view.parent': ir.ui.view(789,),
'xmlid': 'sale_order_form_inherit'}

Avatar
Descartar

You will add the field to sale.order model as related field and change it in view as below:
<field name="use_csv_purchase"/>