跳至内容
菜单
此问题已终结
2 回复
5618 查看

Hi!

I'm trying to create a button in contact to open the opportunity (in crm.lead) and add a field inside the the form opportunity

The problem is that when I want use this table I get an error:

  • When I want to inherit the model get:

    • This Error

          raise TypeError("Model %r does not exist in registry." % name)

          TypeError: Model 'crm.lead' does not exist in registry. - - -

    • And the code is:

          _inherit = 'crm.lead'
          
          status = fields.Selection(
              selection = [('prospect','Prospect'), ('etude','Etude'), ('accepte','Accepté'), ('chantier','Chantier'), ('cloturee','Cloturée'), ('refusee','Refusée')],
              string = 'Statut',
              default = "prospect")

              When I want to inherit de form I get:
                  This Error:
      Model not found: crm.lead Error context: View `crm_crm_case_form_view_oppor` [view_id: 1363, xml_id: n/a, model: crm.lead, parent_id: 1332] None" while parsing file:/c:/users/da-sil_t/desktop/freelance/pepitelab/di-environnement-back/custom_addons/agence/views/inherit_crm_team.xml:28, near <record id="crm_crm_case_form_view_oppor_inherit_agence" model="ir.ui.view"> <field name="name">crm_crm_case_form_view_oppor</field> <field name="model">crm.lead</field> <field name="inherit_id" ref="crm.crm_case_form_view_oppor"/> <field name="arch" type="xml"> <xpath expr="//field[@name='active']" position="after"> <field name="status"/> </xpath> </field> </record>

      The crm module is well installed and I can make a create for an opportunity (its work without problem):
              crm_id = self.env['crm.lead'].sudo().create({'name': res.name, 'partner_id': res.raison_social.id, 'user_id': res.charge_da.user_id.id, 'status': res.status})
      形象
      丢弃
      最佳答案

      Hi,  Théo


      Seems like dependency of "crm" module is not present in your custom module. Kindly add "crm" dependency inside "__manifest__.py" file in your custom module. In order to fix this issue.


      Feel free to ask in case you still have the same issue.


      Thanks,
      Ashish Singh (Team Lead)
      Webkul Software Private Limited
      形象
      丢弃
      编写者 最佳答案

      It works perfectly thank you very much @Ashish Singh

      形象
      丢弃

      Hi, Theo

      It's great that your issue is resolved. If you liked my assistance then I would really appreciate if you can take out a few minutes out of your busy schedule and put a google review for us here -

      https://www.google.com/search?q=webkul&oq=webkul+&aqs=chrome..69i57j69i60l3j0l2.4182j0j7&sourceid=chrome&ie=UTF-8#lrd=0x390ce561c5555555:0xcfb40ae166ce6c21,1

      Thanks

      Ashish Singh