Skip to content

Commit

Permalink
Merge pull request #125 from sodexis/9.0-partner-address-type-default
Browse files Browse the repository at this point in the history
[PORT][9.0] partner address type default
  • Loading branch information
pedrobaeza committed Mar 7, 2016
2 parents ac8c14b + 4485ed8 commit 95cfe4a
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 58 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ addons:
- expect-dev # provides unbuffer utility
- python-lxml # because pip installation is slow
- python-unidecode
- wkhtmltopdf

env:
global:
Expand Down
6 changes: 3 additions & 3 deletions partner_address_type_default/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################
# © 2015 AvanzOSC, Pedro M. Baeza, Sodexis, OdooMRP team
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
28 changes: 6 additions & 22 deletions partner_address_type_default/__openerp__.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,14 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c)
# 2015 Serv. Tec. Avanzados - Pedro M. Baeza (http://www.serviciosbaeza.com)
# 2015 AvanzOsc (http://www.avanzosc.es)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
# © 2015 AvanzOSC, Pedro M. Baeza, Sodexis, OdooMRP team
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Partner Address Type Default",
"version": "1.0",
"author": "OdooMRP team,"
"AvanzOSC,"
"Serv. Tecnol. Avanzados - Pedro M. Baeza",
"Sodexis"
"website": "http://www.odoomrp.com",
"contributors": [
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com",
Expand All @@ -39,5 +23,5 @@
"data": [
"views/res_partner_view.xml",
],
'installable': False,
'installable': True,
}
9 changes: 4 additions & 5 deletions partner_address_type_default/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################
from . import res_partner
from . import sale_order
# © 2015 AvanzOSC, Pedro M. Baeza, Sodexis, OdooMRP team
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import res_partner, sale_order
6 changes: 3 additions & 3 deletions partner_address_type_default/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################
# © 2015 AvanzOSC, Pedro M. Baeza, Sodexis, OdooMRP team
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, fields, api


Expand Down
29 changes: 12 additions & 17 deletions partner_address_type_default/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################
from openerp import models
# © 2015 AvanzOSC, Pedro M. Baeza, Sodexis, OdooMRP team
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, api


class SaleOrder(models.Model):
_inherit = "sale.order"

def onchange_partner_id(self, cr, uid, ids, part, context=None):
partner_obj = self.pool['res.partner']
result = super(SaleOrder, self).onchange_partner_id(
cr, uid, ids, part, context=context)
partner = partner_obj.browse(cr, uid, part, context=context)
value = result['value']
if partner.child_ids:
for line in partner.child_ids:
if line.type == 'invoice' and line.default_address:
value['partner_invoice_id'] = line.id
if line.type == 'delivery' and line.default_address:
value['partner_shipping_id'] = line.id
result['value'] = value
@api.onchange('partner_id')
def onchange_partner_id(self):
result = super(SaleOrder, self).onchange_partner_id()
for line in self.partner_id.child_ids:
if line.type == 'invoice' and line.default_address:
self.partner_invoice_id = line.id
if line.type == 'delivery' and line.default_address:
self.partner_shipping_id = line.id
return result
17 changes: 9 additions & 8 deletions partner_address_type_default/views/res_partner_view.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- © 2015 AvanzOSC, Pedro M. Baeza, Sodexis, OdooMRP team
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<openerp>
<data>
<record model="ir.ui.view" id="view_partner_form_inh_defaultaddress">
<field name="name">view.partner.form.inh.defaultaddress</field>
<record model="ir.ui.view" id="view_partner_form_inherit">
<field name="name">view.partner.form.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="//form[@string='Contact']//sheet//group//div[@name='div_type']" position="after">
<label for="default_address" attrs="{'invisible':['|',('customer', '=', False),('type', 'not in', ('invoice','delivery'))]}"/>
<div name="default_address" attrs="{'invisible':['|',('customer', '=', False),('type', 'not in', ('invoice','delivery'))]}">
<field name="default_address"/>
</div>
<newline/>
<xpath
expr="//page/field/form//field[@name='type']" position="after">
<group attrs="{'invisible':['|',('customer', '=', False),('type', 'not in', ('invoice','delivery'))]}">
<field name="default_address" />
</group>
</xpath>
</field>
</record>
Expand Down

0 comments on commit 95cfe4a

Please sign in to comment.