Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1 Responder
1326 Visualizações

hi all, i am creating a custom module, i have created Model and it can be seen in Technical -> Models (the code is below) which is fine, then i created View but when upgrading Module in Apps it is throwing Error. 

due to some problems here i am posting View code and Error message in Comment.

please help to find out what i am doing wrong and how to resolve it.


My Model code is here:

from odoo import models, fields


class CRMInquiry(models.Model):

_name = 'crm.inquiry'

_description = 'CRM Lead Inquiry'


product_id = fields.Many2one('product.product', string='Product Name', required=True)

qty = fields.Integer(string='Quantity', default=1)


note: as mentioned above, check View code and Error in Comments below.

in continuation of my topic below :

https://www.odoo.com/forum/help-1/v16-inherit-crm-pipeline-view-and-add-page-tab-with-custom-fields-236904

regards

Avatar
Cancelar
Autor

My view code as per your advised code:

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_crm_lead_form_inherit01" model="ir.ui.view">
<field name="name">crm.leads.inherit</field>
<field name="model">crm.inquiry</field>
<field name="inherit_id" ref="crm.crm_lead_view_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='lead']" position="after">
<page name="">th
<group>
<field name="product_id"/>
<field name="qty"/>
</group>
</page>
</xpath>
</field>
</record>
</odoo>

Autor

the Error while upgrading Module through Apps:

<form class="o_lead_opportunity_form" js_class="crm_form">
<header>
<button name="action_set_won_rainbowman" string="Won" type="object" class="oe_highlight" data-hotkey="w" title="Mark as won" attrs="{'invisible': ['|','|', ('active','=',False), ('probability', '=', 100), ('type', '=', 'lead')]}"/>

Field `stage_id` does not exist

View error context:
{'file': 'd:\\program files\\odoo '
'16.0e.20230607\\server\\odoo\\custom_addons\\crm_customz\\views\\crm_leads_custom_inquiry.xml',
'line': 1,
'name': 'crm.leads.inherit',
'view': ir.ui.view(2407,),
'view.model': 'crm.inquiry',
'view.parent': ir.ui.view(2318,),
'xmlid': 'view_crm_lead_form_inherit01'}

Melhor resposta

Hi SmithJohn,

Based On your Code:

  1. When you create view for this specific model (crm.inquiry) then its not present in odoo default code so you need create its own view.
  2. Don't inherit (crm_lead_view_form) this  view because this is used in (crm.lead) model if you add your both field inside (crm.lead) then you need to inherit this view.
  3. Right now you create your new model (crm.inquiry) so you need to create  its own view.
  4.  For your information if you need to add your both field like product_id and qty add in crm.lead  model then you need to add like this way (_inherit="crm.lead") and crm module add in depends of manifest file.

Thanks.

Avatar
Cancelar
Autor

thank you @Nikhil , i really don't know about this limitation,

the above mentioned View code is a sample to check if its correct or not. actually this will crm.inquiry will have multiple rows, view will be created with ' tree view + editable=bottom '.

as per your advise, if i add both fields in crm.lead and inherit view, add the functionality for multiple rows, how it will work? what i have to do to achieve this?

hope this clear.

regards

Autor

thanks a lot @Nikhil Nakrani,

now it is clear why it is showing error as mentioned in my opening post 2nd comment.
for beginners like me who can face the same situation:
- when we Inherit a view, we have to use same Model in original view which we are inheriting, because the view we are creating is actually Based on original view. hope this will help.

regards

Welcome SmithJohn

Publicações relacionadas Respostas Visualizações Atividade
2
ago. 24
2860
2
jan. 24
942
1
dez. 24
3487
0
jan. 24
1720
3
nov. 23
12973