Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

How do I suppress "Create and Edit" option on state field in extended form?

Subscribe

Get notified when there's activity on this post

This question has been flagged
2 Replies
4769 Views
Avatar
Hummingbiz

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.

0
Avatar
Discard
Avatar
Sunny Sheth
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

0
Avatar
Discard
Hummingbiz
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.

Sunny Sheth

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

and add screenshot if possible

Thanks

Hummingbiz
Author

I added the whole record to this thread.

Avatar
Hummingbiz
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>

0
Avatar
Discard
Sunny Sheth

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

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

Hummingbiz
Author

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

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now