Some custom layout and add country and US states
This commit is contained in:
@@ -28,5 +28,4 @@
|
||||
from category import *
|
||||
from partner import *
|
||||
from country import *
|
||||
from state import *
|
||||
from address import *
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"xml" : [
|
||||
"category.xml",
|
||||
"partner.xml",
|
||||
"country.xml",
|
||||
"address.xml",
|
||||
],
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,10 +19,10 @@ class Address(OSV):
|
||||
zip = fields.Char('Zip', change_default=True, size=24,
|
||||
states=STATES)
|
||||
city = fields.Char('City', size=128, states=STATES)
|
||||
state = fields.Many2One("partner.state", 'State',
|
||||
domain="[('country_id','=',country_id)]", states=STATES)
|
||||
country = fields.Many2One('partner.country', 'Country',
|
||||
states=STATES)
|
||||
state = fields.Many2One("partner.country.state", 'State',
|
||||
domain="[('country', '=', country)]", states=STATES)
|
||||
email = fields.Char('E-Mail', size=64, states=STATES)
|
||||
phone = fields.Char('Phone', size=64, states=STATES)
|
||||
fax = fields.Char('Fax', size=64, states=STATES)
|
||||
|
||||
+8
-3
@@ -30,25 +30,30 @@
|
||||
<label name="type"/>
|
||||
<field name="type"/>
|
||||
<label name="active"/>
|
||||
<field name="active" invisible="0"/>
|
||||
<field name="active" invisible="0"
|
||||
xexpand="0" width="100"/>
|
||||
<label name="street"/>
|
||||
<field name="street"/>
|
||||
<label name="streetbis"/>
|
||||
<field name="streetbis"/>
|
||||
<newline/>
|
||||
<label name="zip"/>
|
||||
<field name="zip"/>
|
||||
<label name="city"/>
|
||||
<field name="city"/>
|
||||
<newline/>
|
||||
<label name="country"/>
|
||||
<field name="country" completion="1"/>
|
||||
<label name="state"/>
|
||||
<field name="state"/>
|
||||
<newline/>
|
||||
<label name="phone"/>
|
||||
<field name="phone"/>
|
||||
<label name="fax"/>
|
||||
<field name="fax"/>
|
||||
<label name="mobile"/>
|
||||
<field name="mobile"/>
|
||||
<newline/>
|
||||
<label name="fax"/>
|
||||
<field name="fax"/>
|
||||
<label name="email"/>
|
||||
<field name="email" widget="email"/>
|
||||
</form>
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<form string="Partner categories">
|
||||
<form string="Category">
|
||||
<label name="name"/>
|
||||
<field name="name"/>
|
||||
<label name="active"/>
|
||||
@@ -24,7 +24,7 @@
|
||||
<field name="field_childs">childs</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<tree string="Partner Categories">
|
||||
<tree string="Categories">
|
||||
<field name="name" select="1"/>
|
||||
<field name="active" select="2" invisible="1"/>
|
||||
</tree>
|
||||
|
||||
+28
-2
@@ -5,15 +5,16 @@ STATES = {
|
||||
|
||||
|
||||
class Country(OSV):
|
||||
'Partner Country'
|
||||
'Country'
|
||||
_name = 'partner.country'
|
||||
_description = __doc__
|
||||
_order='code'
|
||||
name = fields.Char('Country Name', size=64,
|
||||
help='The full name of the country.', required=True)
|
||||
help='The full name of the country.', required=True, translate=True)
|
||||
code = fields.Char('Country Code', size=2,
|
||||
help='The ISO country code in two chars.\n'
|
||||
'You can use this field for quick search.', required=True)
|
||||
state = fields.One2Many('partner.country.state', 'country', 'State')
|
||||
_sql_constraints = [
|
||||
('name_uniq', 'unique (name)',
|
||||
'The name of the country must be unique !'),
|
||||
@@ -48,3 +49,28 @@ class Country(OSV):
|
||||
context=context)
|
||||
|
||||
Country()
|
||||
|
||||
|
||||
class State(OSV):
|
||||
"State"
|
||||
_name = 'partner.country.state'
|
||||
_description = __doc__
|
||||
_order = 'code'
|
||||
country = fields.Many2One('partner.country', 'Country',
|
||||
required=True)
|
||||
name = fields.Char('State Name', size=64, required=True)
|
||||
code = fields.Char('State Code', size=3, required=True)
|
||||
|
||||
def create(self, cursor, user, vals, context=None):
|
||||
if 'code' in vals:
|
||||
vals['code'] = vals['code'].upper()
|
||||
return super(State, self).create(cursor, user, vals,
|
||||
context=context)
|
||||
|
||||
def write(self, cursor, user, ids, vals, context=None):
|
||||
if 'code' in vals:
|
||||
vals['code'] = vals['code'].upper()
|
||||
return super(State, self).write(cursor, user, ids, vals,
|
||||
context=context)
|
||||
|
||||
State()
|
||||
|
||||
+1279
File diff suppressed because it is too large
Load Diff
+11
-6
@@ -24,7 +24,9 @@
|
||||
<![CDATA[
|
||||
<form string="Partners">
|
||||
<label name="name"/>
|
||||
<field name="name"/>
|
||||
<field name="name" xexpand="1"/>
|
||||
<label name="active"/>
|
||||
<field name="active" xexpand="0" width="100"/>
|
||||
<notebook colspan="4">
|
||||
<page string="General">
|
||||
<field name="addresses" mode="form,tree" colspan="4">
|
||||
@@ -34,25 +36,30 @@
|
||||
<label name="type"/>
|
||||
<field name="type"/>
|
||||
<label name="active"/>
|
||||
<field name="active" invisible="0"/>
|
||||
<field name="active" invisible="0"
|
||||
xexpand="0" width="100"/>
|
||||
<label name="street"/>
|
||||
<field name="street"/>
|
||||
<label name="streetbis"/>
|
||||
<field name="streetbis"/>
|
||||
<newline/>
|
||||
<label name="zip"/>
|
||||
<field name="zip"/>
|
||||
<label name="city"/>
|
||||
<field name="city"/>
|
||||
<newline/>
|
||||
<label name="country"/>
|
||||
<field name="country" completion="1"/>
|
||||
<label name="state"/>
|
||||
<field name="state"/>
|
||||
<newline/>
|
||||
<label name="phone"/>
|
||||
<field name="phone"/>
|
||||
<label name="fax"/>
|
||||
<field name="fax"/>
|
||||
<label name="mobile"/>
|
||||
<field name="mobile"/>
|
||||
<newline/>
|
||||
<label name="fax"/>
|
||||
<field name="fax"/>
|
||||
<label name="email"/>
|
||||
<field name="email" widget="email"/>
|
||||
</form>
|
||||
@@ -66,8 +73,6 @@
|
||||
</field>
|
||||
<label name="lang"/>
|
||||
<field name="lang" widget="selection"/>
|
||||
<label name="active"/>
|
||||
<field name="active"/>
|
||||
<separator string="Categories" colspan="4"/>
|
||||
<field name="categories" colspan="4"/>
|
||||
</page>
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
from trytond.osv import fields, OSV
|
||||
STATES = {
|
||||
'readonly': "active == False"
|
||||
}
|
||||
|
||||
|
||||
class State(OSV):
|
||||
"Country state"
|
||||
_name = 'partner.state'
|
||||
_description = __doc__
|
||||
_order = 'code'
|
||||
country = fields.Many2One('partner.country', 'Country',
|
||||
required=True)
|
||||
name = fields.Char('State Name', size=64, required=True)
|
||||
code = fields.Char('State Code', size=3, required=True)
|
||||
|
||||
def create(self, cursor, user, vals, context=None):
|
||||
if 'code' in vals:
|
||||
vals['code'] = vals['code'].upper()
|
||||
return super(CountryState, self).create(cursor, user, vals,
|
||||
context=context)
|
||||
|
||||
def write(self, cursor, user, ids, vals, context=None):
|
||||
if 'code' in vals:
|
||||
vals['code'] = vals['code'].upper()
|
||||
return super(CountryState, self).write(cursor, user, ids, vals,
|
||||
context=context)
|
||||
|
||||
State()
|
||||
|
||||
Reference in New Issue
Block a user