product_warranty: migration V9

This commit is contained in:
Cyril Gaudin
2016-04-21 16:32:59 +02:00
committed by Maxime Chambreuil
parent 750db08274
commit 72cc7e75c2
11 changed files with 84 additions and 198 deletions

View File

@@ -32,6 +32,7 @@ Contributors
* Joël Grand-Guillaume <joel.grandguillaume@gmail.com> * Joël Grand-Guillaume <joel.grandguillaume@gmail.com>
* Ondřej Kuzník <ondrej.kuznik@credativ.co.uk> * Ondřej Kuzník <ondrej.kuznik@credativ.co.uk>
* Yanina Aular <yanina.aular@vauxoo.com> * Yanina Aular <yanina.aular@vauxoo.com>
* Cyril Gaudin <cyril.gaudin@camptocamp.com>
Maintainer Maintainer
---------- ----------

View File

@@ -1,23 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
######################################################################### # © 2016 Cyril Gaudin (Camptocamp)
# # # © 2009-2011 Akretion, Emmanuel Samyn
# # # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
#########################################################################
# #
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU 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 General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
from . import models from . import models

View File

@@ -22,7 +22,7 @@
{ {
'name': 'Product warranty', 'name': 'Product warranty',
'version': '8.0.1.0.0', 'version': '9.0.1.0.0',
'category': 'Generic Modules/Product', 'category': 'Generic Modules/Product',
'author': "Akretion,Odoo Community Association (OCA),Vauxoo", 'author': "Akretion,Odoo Community Association (OCA),Vauxoo",
'website': 'http://akretion.com', 'website': 'http://akretion.com',
@@ -38,7 +38,7 @@
'demo/res_company.xml', 'demo/res_company.xml',
], ],
'test': [], 'test': [],
'installable': False, 'installable': True,
'active': False, 'active': False,
'images': ['images/product_warranty.png'], 'images': ['images/product_warranty.png'],
} }

View File

@@ -37,7 +37,7 @@ Select the product you want to return and the reason for the return. You will ne
<field name="warranty_return_partner">supplier</field> <field name="warranty_return_partner">supplier</field>
<field name="warranty_duration">12</field> <field name="warranty_duration">12</field>
<field name="product_tmpl_id" ref="product.product_product_3_product_template"/> <field name="product_tmpl_id" ref="product.product_product_3_product_template"/>
<field name="name" ref="base.res_partner_5"/> <field name="name" ref="base.res_partner_3"/>
<field name="delay">5</field> <field name="delay">5</field>
<field name="min_qty">1</field> <field name="min_qty">1</field>
</record> </record>

View File

@@ -1,24 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
######################################################################### # © 2016 Cyril Gaudin (Camptocamp)
# # # © 2009-2011 Akretion, Emmanuel Samyn
# # # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
#########################################################################
# #
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU 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 General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
from . import return_instruction from . import return_instruction
from . import product_supplierinfo from . import product_supplierinfo

View File

@@ -1,25 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# ######################################################################## # © 2016 Cyril Gaudin (Camptocamp)
# # # © 2015 Vauxoo
# # # © 2009-2011 Akretion, Emmanuel Samyn, Benoît Guillot
# ######################################################################## # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# #
# Copyright 2015 Vauxoo
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn, Benoît Guillot #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU 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 General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##########################################################################
from openerp import api, fields, models from openerp import api, fields, models
@@ -28,14 +11,6 @@ class ProductSupplierInfo(models.Model):
_inherit = "product.supplierinfo" _inherit = "product.supplierinfo"
@api.model
def get_warranty_return_partner(self):
result = [('company', 'Company'),
('supplier', 'Supplier'),
('other', 'Other'),
]
return result
@api.model @api.model
def _get_default_instructions(self): def _get_default_instructions(self):
""" Get selected lines to add to exchange """ """ Get selected lines to add to exchange """
@@ -43,36 +18,35 @@ class ProductSupplierInfo(models.Model):
.search([('is_default', '=', True)], limit=1) .search([('is_default', '=', True)], limit=1)
return instruction_ids return instruction_ids
@api.one
@api.depends('warranty_return_partner') @api.depends('warranty_return_partner')
def _compute_warranty_return_address(self): def _compute_warranty_return_address(self):
""" Method to return the partner delivery address or if none, the """ Method to return the partner delivery address or if none, the
default address default address
""" """
return_partner = self.warranty_return_partner for record in self:
partner_id = self.company_id.partner_id.id return_partner = record.warranty_return_partner
if return_partner: partner_id = record.company_id.partner_id.id
if return_partner == 'supplier': if return_partner:
partner_id = self.name.id if return_partner == 'supplier':
elif return_partner == 'company': partner_id = record.name.id
if self.company_id.crm_return_address_id: elif return_partner == 'company':
partner_id = self.company_id.\ if record.company_id.crm_return_address_id:
crm_return_address_id.id partner_id = record.company_id.crm_return_address_id.id
elif return_partner == 'other': elif return_partner == 'other':
if self.warranty_return_other_address: if record.warranty_return_other_address:
partner_id = self.\ partner_id = record.warranty_return_other_address.id
warranty_return_other_address.id record.warranty_return_address = partner_id
self.warranty_return_address = partner_id
warranty_duration = fields.Float( warranty_duration = fields.Float(
'Period', 'Period',
help="Warranty in month for this product/supplier relation. Only " help="Warranty in month for this product/supplier relation. Only "
"for company/supplier relation (purchase order) ; the " "for company/supplier relation (purchase order) ; the "
"customer/company relation (sale order) always use the " "customer/company relation (sale order) always use the "
"product main warranty field") "product main warranty field"
)
warranty_return_partner = fields.Selection( warranty_return_partner = fields.Selection(
get_warranty_return_partner, [('company', 'Company'), ('supplier', 'Supplier'), ('other', 'Other')],
'Return type', string='Return type',
required=True, required=True,
default='company', default='company',
help="Who is in charge of the warranty return treatment toward the" help="Who is in charge of the warranty return treatment toward the"
@@ -81,22 +55,27 @@ class ProductSupplierInfo(models.Model):
"brand manufacturer. Doesn't necessarly mean that the " "brand manufacturer. Doesn't necessarly mean that the "
"warranty to be applied is the one of the return partner " "warranty to be applied is the one of the return partner "
"(ie: can be returned to the company and be under the " "(ie: can be returned to the company and be under the "
"brand warranty") "brand warranty)"
)
return_instructions = fields.Many2one( return_instructions = fields.Many2one(
'return.instruction', 'return.instruction',
'Instructions', 'Instructions',
default=_get_default_instructions, default=_get_default_instructions,
help="Instructions for product return") help="Instructions for product return"
)
active_supplier = fields.Boolean( active_supplier = fields.Boolean(
help="Is this supplier still active, only for information") help="Is this supplier still active, only for information"
)
warranty_return_address = fields.Many2one( warranty_return_address = fields.Many2one(
'res.partner', 'res.partner',
compute='_compute_warranty_return_address', compute='_compute_warranty_return_address',
string="Return address", string="Return address",
help="Where the goods should be returned " help="Where the goods should be returned "
"(computed field based on other infos.)") "(computed field based on other infos.)"
)
warranty_return_other_address = fields.Many2one( warranty_return_other_address = fields.Many2one(
'res.partner', 'res.partner',
string='Return address', string='Return address',
help="Where the customer has to send back the product(s) " help="Where the customer has to send back the product(s) "
"if warranty return is set to 'other'.") "if warranty return is set to 'other'."
)

View File

@@ -1,26 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # © 2016 Joel Grand-Guillaume, Cyril Gaudin (Camptocamp)
# # © 2009-2013 Akretion, Emmanuel Samyn, Raphaël Valyi, Sébastien Beau
# Copyright 2015 Vauxoo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# Copyright 2013 Camptocamp
# Copyright 2009-2013 Akretion,
# Author: Emmanuel Samyn, Raphaël Valyi, Sébastien Beau,
# Joel Grand-Guillaume
#
# 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/>.
#
##############################################################################
from openerp import fields, models from openerp import fields, models

View File

@@ -1,25 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# ######################################################################## # © 2016 Cyril Gaudin (Camptocamp)
# # # © 2015 Vauxoo
# # # © 2009-2011 Akretion, Emmanuel Samyn, Benoît Guillot
# ######################################################################## # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# #
# Copyright 2015 Vauxoo
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn, Benoît Guillot #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU 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 General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##########################################################################
from openerp import fields, models from openerp import fields, models

View File

@@ -1,23 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # © 2016 Cyril Gaudin (Camptocamp)
# # © 2015 Vauxoo, Yanina Aular
# Author: Yanina Aular # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# Copyright 2015 Vauxoo
#
# 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/>.
#
##############################################################################
from openerp.tests.common import TransactionCase from openerp.tests.common import TransactionCase
@@ -38,16 +22,19 @@ class TestProductWarranty(TransactionCase):
product_tmpl_id = self.env.ref('product.product_product_3') product_tmpl_id = self.env.ref('product.product_product_3')
partner_id = self.env.ref('base.res_partner_4') partner_id = self.env.ref('base.res_partner_4')
other_partner = self.env.ref('base.res_partner_12')
supplierinfo_data = dict(name=partner_id.id, supplierinfo_data = dict(
product_name='Test SupplierInfo for' name=partner_id.id,
' display Default Instruction', product_name='Test SupplierInfo for display Default Instruction',
min_qty=4, min_qty=4,
delay=5, delay=5,
warranty_return_partner='supplier', warranty_return_partner='supplier',
product_tmpl_id=product_tmpl_id.id,) product_tmpl_id=product_tmpl_id.id,
self.supplierinfo_brw = \ warranty_return_other_address=other_partner.id,
self.supplierinfo.create(supplierinfo_data) )
self.supplierinfo_brw = self.supplierinfo.create(supplierinfo_data)
def test_default_instruction(self): def test_default_instruction(self):
""" """
@@ -78,3 +65,10 @@ class TestProductWarranty(TransactionCase):
self.assertEquals(self.supplierinfo_brw.warranty_return_address.id, self.assertEquals(self.supplierinfo_brw.warranty_return_address.id,
self.supplierinfo_brw.company_id. self.supplierinfo_brw.company_id.
crm_return_address_id.id) crm_return_address_id.id)
self.supplierinfo_brw.write({'warranty_return_partner': 'other'})
self.assertEquals(
self.supplierinfo_brw.warranty_return_address.id,
self.supplierinfo_brw.warranty_return_other_address.id
)

View File

@@ -1,29 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!--
##############################################################################
#
# Copyright (C) 2009-2011 Akretion, Emmanuel Samyn
#
# 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/>.
#
##############################################################################
-->
<openerp> <openerp>
<data> <data>
<!-- return instructions --> <!-- return instructions tree view -->
<!-- supplier info tree view -->
<record model="ir.ui.view" id="product_return_instructions_tree_view"> <record model="ir.ui.view" id="product_return_instructions_tree_view">
<field name="name">product.return.instructions.tree</field> <field name="name">product.return.instructions.tree</field>
<field name="model">return.instruction</field> <field name="model">return.instruction</field>
@@ -36,7 +14,7 @@
</field> </field>
</record> </record>
<!-- supplier info form view --> <!-- return instructions form view -->
<record model="ir.ui.view" id="product_return_instructions_form_view"> <record model="ir.ui.view" id="product_return_instructions_form_view">
<field name="name">product.return.instructions.form</field> <field name="name">product.return.instructions.form</field>
<field name="model">return.instruction</field> <field name="model">return.instruction</field>
@@ -64,20 +42,20 @@
groups="base.group_no_one" groups="base.group_no_one"
id="menu_product_return_instructions_action" id="menu_product_return_instructions_action"
parent="product.prod_config_main" sequence="3"/> parent="product.prod_config_main" sequence="3"/>
<!-- supplier info -->
<!-- supplier info tree view --> <!-- supplier info tree view -->
<record model="ir.ui.view" id="product_supplierinfo_warranty_tree_view"> <record model="ir.ui.view" id="product_supplierinfo_warranty_tree_view">
<field name="name">product.supplierinfo.warranty.tree</field> <field name="name">product.supplierinfo.warranty.tree</field>
<field name="model">product.supplierinfo</field> <field name="model">product.supplierinfo</field>
<field name="inherit_id" ref="product.product_supplierinfo_tree_view" /> <field name="inherit_id" ref="product.product_supplierinfo_tree_view" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='delay']" position="after"> <field name="min_qty" position="before">
<field name="warranty_duration"/> <field name="warranty_duration"/>
<field name="warranty_return_partner"/> <field name="warranty_return_partner"/>
<field name="warranty_return_address"/> <field name="warranty_return_address"/>
<field name="active_supplier"/> <field name="active_supplier"/>
<field name="return_instructions"/> <field name="return_instructions"/>
</xpath> </field>
</field> </field>
</record> </record>
@@ -87,7 +65,7 @@
<field name="model">product.supplierinfo</field> <field name="model">product.supplierinfo</field>
<field name="inherit_id" ref="product.product_supplierinfo_form_view" /> <field name="inherit_id" ref="product.product_supplierinfo_form_view" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<field position="after" name="company_id" groups="base.group_multi_company" widget="selection"> <xpath expr="//group[last()]" position="after">
<group string="Warranty informations" colspan="4"> <group string="Warranty informations" colspan="4">
<field name="active_supplier"/> <field name="active_supplier"/>
<field name="warranty_duration"/> <field name="warranty_duration"/>
@@ -97,12 +75,14 @@
<field name="warranty_return_partner"/> <field name="warranty_return_partner"/>
</group> </group>
<group> <group>
<field name="warranty_return_other_address" attrs="{'invisible':[('warranty_return_partner', '!=', 'other')], 'required':[('warranty_return_partner', '=', 'other')]}" class="oe_inline"/> <field name="warranty_return_other_address"
attrs="{'invisible':[('warranty_return_partner', '!=', 'other')], 'required':[('warranty_return_partner', '=', 'other')]}"
class="oe_inline"/>
<field name="warranty_return_address" attrs="{'invisible':[('warranty_return_partner', '=', 'other')]}" class="oe_inline" /> <field name="warranty_return_address" attrs="{'invisible':[('warranty_return_partner', '=', 'other')]}" class="oe_inline" />
</group> </group>
</group> </group>
</group> </group>
</field> </xpath>
</field> </field>
</record> </record>

View File

@@ -8,9 +8,11 @@
<field name="model">res.company</field> <field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/> <field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='company_registry']" position="after"> <xpath expr="//field[@name='company_registry']/ancestor::group" position="after">
<separator string="Crm product return address"/> <separator string="Crm product return address"/>
<field name="crm_return_address_id"/> <group>
<field name="crm_return_address_id"/>
</group>
</xpath> </xpath>
</field> </field>
</record> </record>