Browse Source

Merge pull request #207 from ghost/port_module_partner_street_number

[ADD] res.partner: Porting partner_street_number module to Odoo 9.0
pull/736/head
Ronald Portier 6 years ago
committed by GitHub
parent
commit
db0cd31132
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      partner_street_number/__init__.py
  2. 11
      partner_street_number/__openerp__.py
  3. 11
      partner_street_number/static/src/css/field.css
  4. 12
      partner_street_number/views/assets.xml
  5. 53
      partner_street_number/views/res_partner.xml

2
partner_street_number/__init__.py

@ -36,7 +36,7 @@ def post_init_hook(cr, registry):
cr.execute( cr.execute(
'SELECT id, street FROM res_partner ' 'SELECT id, street FROM res_partner '
'WHERE street IS NOT NULL and street_name IS NULL' 'WHERE street IS NOT NULL and street_name IS NULL'
)
)
partner_obj = registry['res.partner'] partner_obj = registry['res.partner']
for partner in cr.fetchall(): for partner in cr.fetchall():
partner_obj.write( partner_obj.write(

11
partner_street_number/__openerp__.py

@ -21,17 +21,18 @@
{ {
"name": "Street name and number", "name": "Street name and number",
"summary": "Introduces separate fields for street name and street number.", "summary": "Introduces separate fields for street name and street number.",
"version": "8.0.0.1.0",
"version": "9.0.0.1.0",
"author": "Therp BV,Odoo Community Association (OCA)", "author": "Therp BV,Odoo Community Association (OCA)",
"website": "https://github.com/oca/partner-contact", "website": "https://github.com/oca/partner-contact",
"category": 'Tools', "category": 'Tools',
"depends": [ "depends": [
'base'
],
'web',
],
"data": [ "data": [
'views/res_partner.xml', 'views/res_partner.xml',
],
'installable': False,
'views/assets.xml',
],
'installable': True,
'license': 'AGPL-3', 'license': 'AGPL-3',
'post_init_hook': 'post_init_hook', 'post_init_hook': 'post_init_hook',
} }

11
partner_street_number/static/src/css/field.css

@ -0,0 +1,11 @@
.o_address_street_name {
float: left !important;
margin-right: 2% !important;
width: 75% !important;
}
.o_address_street_number {
margin-right: 0% !important;
width: 25% !important;
}

12
partner_street_number/views/assets.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<template id="assets_backend" name="partner_street_number backend assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/partner_street_number/static/src/css/field.css"/>
</xpath>
</template>
</data>
</openerp>

53
partner_street_number/views/res_partner.xml

@ -7,46 +7,63 @@
<field name="model">res.partner</field> <field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/> <field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="/form/sheet//div/field[@name='street']"
<xpath expr="//div[@class='o_address_format']//field[@name='street']"
position="after"> position="after">
<div>
<field name="street_name" style="width: 80%%"
placeholder="Street..."
attrs="{'readonly': [('use_parent_address','=',True)]}"
<field name="street_name" class="o_address_street o_address_street_name"
placeholder="Street..."
attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"
/> />
<field name="street_number" style="width: 19%%"
placeholder="Number..."
attrs="{'readonly': [('use_parent_address','=',True)]}"
<field name="street_number" class="o_address_street o_address_street_number"
placeholder="Number..."
attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"
/> />
</div>
</xpath> </xpath>
<xpath expr="/form/sheet//div/field[@name='street']"
<xpath expr="//div[@class='o_address_format']//field[@name='street']"
position="attributes"> position="attributes">
<attribute name="invisible">1</attribute> <attribute name="invisible">1</attribute>
</xpath> </xpath>
<xpath expr="//form[@string='Contact']/sheet/group/div/field[@name='street']"
<xpath expr="//div[@name='div_address']//field[@name='street']"
position="after"> position="after">
<div>
<field name="street_name" style="width: 80%%"
<field name="street_name" class="o_address_street o_address_street_name"
placeholder="Street..." placeholder="Street..."
/> />
<field name="street_number" style="width: 19%%"
<field name="street_number" class="o_address_street o_address_street_number"
placeholder="Number..." placeholder="Number..."
/> />
</div>
</xpath> </xpath>
<xpath expr="//form[@string='Contact']/sheet/group/div/field[@name='street']"
<xpath expr="//div[@name='div_address']//field[@name='street']"
position="attributes"> position="attributes">
<attribute name="invisible">1</attribute> <attribute name="invisible">1</attribute>
</xpath> </xpath>
<xpath expr="//field[@name='child_ids']" position="attributes"> <xpath expr="//field[@name='child_ids']" position="attributes">
<attribute name="context">{'default_parent_id': active_id, 'default_street_name': street_name, 'default_street_number': street_number, 'default_street2': street2, 'default_city': city, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id, 'default_supplier': supplier, 'default_customer': customer, 'default_use_parent_address': True}</attribute>
<attribute name="context">{'default_parent_id': active_id, 'default_street_name': street_name, 'default_street_number': street_number, 'default_street2': street2, 'default_city': city, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id, 'default_supplier': supplier, 'default_customer': customer}</attribute>
</xpath> </xpath>
</field> </field>
</record> </record>
<record id="view_partner_address_form" model="ir.ui.view">
<field name="name">Add separate fields for street name and number in address form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_address_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@class='o_address_format']//field[@name='street']"
position="after">
<field name="street_name" class="o_address_street o_address_street_name"
placeholder="Street..."
/>
<field name="street_number" class="o_address_street o_address_street_number"
placeholder="Number..."
/>
</xpath>
<xpath expr="//div[@class='o_address_format']//field[@name='street']"
position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>
</data> </data>
</openerp> </openerp>
Loading…
Cancel
Save