Skip to Content
Menu
This question has been flagged
2 Replies
3131 Views

I have a problem with some of my users adding spurious state entries because they don't navigate the state field properly and, rather than selecting their desired state, they end up creating a new record in res_country_state, often with improper data.

I would like to restrict this behavior by suppressing the "Create and Edit" option on the widget.  Setting options no_create and/or no_quick_create are said to suppress the option for a many2one widget, but do not have any apparent effect on the o_address_state widget.

These changes are on a form extended from the base product leads form.

We are running Odoo Enterprise v13.x.

Thanks in advance.

Avatar
Discard
Best Answer

Hi,

You can do it easily in your ODOO Standard View as of now or do it via a custom module for no_create on the state field. 

Add option ==> "no_create": True




Now you get the desired result.




Thanks & Regards,

Sunny Sheth

Avatar
Discard
Author

I confirmed that your solution -- editing the form online -- works. I have extended the CRM module to add some fields to the leads form, and that is where I am trying to effect this new behavior.

I have replaced the base state_id field by this:

<xpath expr="//group/group[1]/div/field[@name='state_id']" position="replace">

<field name="state_id" class="o_address_state" placeholder="State"

options="{'no_open': True, 'no_create': True}"/>

</xpath>

This doesn't seem to effect the change. I confirmed that this addresses the correct field by making it invisible temporarily.

Can you put your Whole View / Record instead of the only XPath?

and add screenshot if possible

Thanks

Author

I added the whole record to this thread.

Author Best Answer

Here is the entire record:

<record id="crm_lead_view_form_ext" model="ir.ui.view">
<field name="name">crm.lead.form.ext</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_lead_view_form"/>
<field name="arch" type="xml">
<xpath expr="//h2" position="replace"/>
<button name="%(crm.crm_lead_lost_action)d" position="attributes">
<attribute name="attrs">{'invisible': [('active', '=', False)]}
</attribute>
</button>
<button name="%(crm.action_crm_lead2opportunity_partner)d" position="after">
<button name="%(crm.crm_lead_lost_action)d" position="move"/>
</button>
<button name="action_set_lost" position="replace">
<button name="action_set_lost" string="Mark as Lost" type="object" invisible="1"/>
</button>
<button name="action_set_lost" position="after">
<button name="%(action_crm_lead2irslogics)d" string="Submit Case to IRS Logics"
type="action"
help="Submit Case to IRS Logics"
class="oe_highlight"
attrs="{'invisible': ['|', ('active', '=', False), ('irs_logics_case_id', '!=', False)]}"/>
</button>
<xpath expr="//group/group[1]/field[@name='partner_id']" position="before">
<field name="id_string" string="Lead ID" readonly="1"/>
</xpath>
<xpath expr="//group/group[2]/field[@name='partner_id']" position="before">
<field name="id_string" string="Lead ID" readonly="1"/>
</xpath>
<xpath expr="//field[@name='function']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='email_cc']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='website']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='lang_id']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='team_id']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//group/group[4]/field[@name='tag_ids']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//group/group[6]/field[@name='tag_ids']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='user_id']" position="replace">
<field name="user_id"
string="Settlement Officer"
domain="[('share', '=', False)]"
context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'sales_team.group_sale_salesman_all_leads'], 'team_id': team_id}"/>
</xpath>
<xpath expr="//field[@name='user_id']" position="replace">
<field name="user_id"
string="Settlement Officer"
domain="[('share', '=', False)]"
context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'sales_team.group_sale_salesman_all_leads'], 'team_id': team_id}"/>
</xpath>
<xpath expr="//field[@name='user_id']" position="before">
<field name="contact_first_name" string="Contact First Name"/>
<field name="contact_last_name" string="Contact Last Name"/>
<field name="last4"/>
<field name="opening_salesperson_user_id" required="True"/>
</xpath>
<xpath expr="//group/group[4]/field[@name='priority']" position="before">
<field name="irs_logics_case_id" readonly="1"/>
<field name="irs_logics_case_status" readonly="1"/>
<field name="irs_logics_endpoint" readonly="1"/>
</xpath>
<xpath expr="//group/group[1]/div/field[@name='state_id']" position="replace">
<field name="state_id" class="o_address_state" placeholder="State"
options="{'no_open': True, 'no_create': True}"/>
</xpath>
<xpath expr="//group/group[6]/field[@name='priority']" position="before">
<field name="irs_logics_case_id" readonly="1"/>
<field name="irs_logics_case_status" readonly="1"/>
<field name="irs_logics_endpoint" readonly="1"/>
</xpath>
<xpath expr="//page[1]" position="replace">
<page name="description" string="Third Base">
<field name="description" placeholder="Enter Third Base notes..."/>
</page>
</xpath>
<xpath expr="//page[@name='extra']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//page[@name='extra']" position="before">
<page name="tax_lien" string="Tax Liens">
<field name="tax_liens">
<tree create="true" delete="true">
<field name="plaintiff"/>
<field name="company_currency" invisible="1"/>
<field name="amount" string="Amount" class="oe_inline" widget='monetary'
options="{'currency_field': 'company_currency'}"/>
<field name="filing_date"/>
<field name="state_filed"/>
<field name="county"/>
<control>
<create name="add_lien_control" string="Add a lien"/>
</control>
</tree>
</field>
</page>
<page name="financial_data" string="Snap Financials">
<group string="Firms">
<group colspan="4">
<field name="customer_has_retained_other_firm"
string="Has customer retained another firm?" widget="boolean_toggle"/>
<field name="customer_has_retained_other_firm_notes" string="Notes"/>
</group>
</group>
<group string="Employment">
<group colspan="4">
<field name="employment_status" string="Employment Status"/>
<field name="employer"/>
<field name="employment_notes" string="Notes"/>
</group>
</group>
<group string="Income">
<group colspan="4">
<div class="o_row">
<field name="company_currency" invisible="1"/>
<field name="income" string="Income" class="oe_inline" widget='monetary'
options="{'currency_field': 'company_currency'}"/>
<span class="mr-1">Per</span>
<field name="income_frequency"/>
<span class="mr-1">Paid</span>
<field name="pay_period"/>
</div>
</group>
<group colspan="4">
<field name="income_notes" string="Notes" colspan="4"
placeholder="Enter details regarding customer's income here."/>
</group>
</group>
<group>
<group string="Assets" name="assets" colspan="4">
<field name="assets" nolabel="1"
placeholder="Enter details regarding customer's assets here."/>
</group>
</group>
<group>
<group string="Bank Data" name="bank_data" colspan="4">
<field name="bank_data" nolabel="1"
placeholder="Enter details regarding customer's bank accounts here."/>
</group>
</group>
<group>
<group string="Credit Score" colspan="4">
<group colspan="2">
<field name="credit_score"/>
</group>
<group colspan="4">
<field name="credit_score_notes" string="Notes"
placeholder="Enter details regarding customer's credit here."/>
</group>
</group>
</group>
</page>
<page name="closer_notes" string="Closer Notes">
<field name="closer_notes" placeholder="Add closer notes..."/>
</page>
<page name="tax_data" string="Tax Data">
<group string="General">
<group>
<field name="contact_first_name"/>
<field name="contact_last_name"/>
</group>
<group>
<field name="file_name"/>
<field name="list_date"/>
</group>
</group>
<group string="LexisNexis">
<group>
<field name="entity_type"/>
<field name="rmsid"/>
</group>
<group>
<field name="orig_dept"/>
<field name="age_range"/>
</group>
</group>
<group string="FLA">
<group>
<field name="ssn_fin"/>
</group>
</group>
<group string="ATYPE">
<group>
<field name="crrt"/>
<field name="dpc"/>
<field name="barcode"/>
<field name="gender"/>
<field name="individual"/>
<field name="business"/>
<field name="federal_tax"/>
<field name="state_tax"/>
</group>
<group>
<field name="ul_month"/>
<field name="rdi"/>
<field name="ran"/>
</group>
</group>
</page>
</xpath>
<!-- move third base (aka description aka page[1]) after closer notes -->
<xpath expr="//page[@name='closer_notes']" position="after">
<xpath expr="//page[1]" position="move"/>
</xpath>
</field>
</record>

Avatar
Discard

Hi,

Please try with the below code for the state_id field

<field name="state_id" class="o_address_state" placeholder="State"

options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/>

Thanks

Author

Thanks for looking at this. I tried your suggestion -- options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/> -- but this did not change the results.

Author

To be clear, I tried this as a replacement in my extended view (shown above).