Hi,
Imagine that there are two selection fields, country and states as follows.
So when ever I select a country the states related to the country should be loaded out of all states. Any Idea about doing this in Odoo Website Form(QWEB) in Odoov15?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi,
Imagine that there are two selection fields, country and states as follows.
So when ever I select a country the states related to the country should be loaded out of all states. Any Idea about doing this in Odoo Website Form(QWEB) in Odoov15?
Hi, there,
Target:
Process:
1. XML(this editor is hard to use)
res.partner
2.py
@api.onchange('state_id')
def _onchange_state_id(self):
self.city_id = None
self.district_id = None
if self.state_id:
return {'domain': {'city_id': [('state_id', '=', self.state_id.id)]}}
else:
return {'domain': {'city_id': []}}
from odoo import fields, modelsHope it is useful.
class District(models.Model):
_name = 'res.country.district'
_description = 'District'
_order = 'name'
name = fields.Char("Name", required = True)
city_id = fields.Many2one(
'res.country.city', 'City'
)
class City(models.Model):
_name = 'res.country.city'
_description = 'City'
_order = 'name'
name = fields.Char("Name", required=True, translate=True)
zipcode = fields.Char("Zip")
state_id = fields.Many2one(
'res.country.state', 'State')
XML:
<record id="view_res_country_china_address_form" model="ir.ui.view">
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//div[hasclass('o_address_format')]" position="inside">
<field options='{"no_open": True}' name="state_id" placeholder="State Select" class="o_address_city"/>
<field options='{"no_open": True}' name="city_id" placeholder="City Select" class="o_address_city"/>
<field options='{"no_open": True}' name="district_id" placeholder="District Select" class="o_address_city"/>
</xpath>
</field>
</record>
Hi @tony,
This is not what I need.
I need to do this in the webisite module.
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj sięPowiązane posty | Odpowiedzi | Widoki | Czynność | |
---|---|---|---|---|
How to show a many2one field in the website?
Rozwiązane
|
|
3
lip 22
|
11932 | |
|
5
cze 19
|
7340 | ||
|
2
gru 24
|
10186 | ||
How to remove "contact us" from the header
Rozwiązane
|
|
4
mar 24
|
5974 | |
|
1
mar 24
|
2182 |