From 0a802a431ef1482d4140f8ca5590af3670509016 Mon Sep 17 00:00:00 2001 From: David Vidal Date: Wed, 2 Aug 2017 12:24:12 +0200 Subject: [PATCH] [MIG] partner_risk_insurance: Migration to 10.0 --- partner_risk_insurance/README.rst | 62 ++++++++++ partner_risk_insurance/__init__.py | 20 ---- partner_risk_insurance/__manifest__.py | 26 ++++ partner_risk_insurance/__openerp__.py | 38 ------ partner_risk_insurance/i18n/es.po | 71 ++++++----- partner_risk_insurance/i18n/es_ES.po | 101 ---------------- .../i18n/partner_risk_insurance.pot | 112 ------------------ partner_risk_insurance/models/__init__.py | 23 +--- partner_risk_insurance/models/partner.py | 46 +++++++ partner_risk_insurance/models/res_partner.py | 57 --------- partner_risk_insurance/tests/__init__.py | 3 + .../tests/test_partner_risk_insurance.py | 24 ++++ .../views/res_partner_view.xml | 31 ++--- 13 files changed, 215 insertions(+), 399 deletions(-) create mode 100644 partner_risk_insurance/README.rst create mode 100644 partner_risk_insurance/__manifest__.py delete mode 100644 partner_risk_insurance/__openerp__.py delete mode 100644 partner_risk_insurance/i18n/es_ES.po delete mode 100644 partner_risk_insurance/i18n/partner_risk_insurance.pot create mode 100644 partner_risk_insurance/models/partner.py delete mode 100644 partner_risk_insurance/models/res_partner.py create mode 100644 partner_risk_insurance/tests/__init__.py create mode 100644 partner_risk_insurance/tests/test_partner_risk_insurance.py diff --git a/partner_risk_insurance/README.rst b/partner_risk_insurance/README.rst new file mode 100644 index 000000000..53a527700 --- /dev/null +++ b/partner_risk_insurance/README.rst @@ -0,0 +1,62 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +====================== +Partner Risk Insurance +====================== + +This module allows to set risk insurance information in the partners. + +Usage +===== + +In the partner page under the *Financial Risk* tab there is a new group called +*Credit Insurance*. + +The partner's credit limit can now be computed according to the sum of two new +fields: **Company's Credit Limit** and **Insurance's Credit Limit**. + +Another insurance info can be registered like: Incurance's Credit Coverage, +Insurance Grant Date or Insurance codes. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/134/10.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Daniel Campos +* David Vidal + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/partner_risk_insurance/__init__.py b/partner_risk_insurance/__init__.py index 89bd8fde7..21ff7c22f 100644 --- a/partner_risk_insurance/__init__.py +++ b/partner_risk_insurance/__init__.py @@ -1,23 +1,3 @@ # -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2009 Albert Cervera i Areny (http://www.nan-tic.com). -# Copyright (c) 2014 Factor Libre SL. -# -# 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 . -# -############################################################################## from . import models diff --git a/partner_risk_insurance/__manifest__.py b/partner_risk_insurance/__manifest__.py new file mode 100644 index 000000000..8d92e66a9 --- /dev/null +++ b/partner_risk_insurance/__manifest__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Copyright 2009 NaN·tic - Albert Cervera +# Copyright 2014 Factor Libre S.L. +# Copyright 2014 AvancOSC - Daniel Campos +# Copyright 2017 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + 'name': 'Partner Risk Insurance', + 'version': '10.0.1.0.0', + 'category': 'Sales Management', + 'summary': 'Lets set risk insurance info in the partners', + 'author': 'AvanzOSC,' + 'Factor Libre S.L,' + 'NaN·tic,' + 'Tecnativa,' + 'Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/partner-contact', + 'license': 'AGPL-3', + 'depends': [ + 'partner_financial_risk', + ], + 'data': [ + 'views/res_partner_view.xml', + ], + 'installable': True, +} diff --git a/partner_risk_insurance/__openerp__.py b/partner_risk_insurance/__openerp__.py deleted file mode 100644 index 7e19e10fa..000000000 --- a/partner_risk_insurance/__openerp__.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# 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 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/. -# -############################################################################## - -{ - "name": "Partner Risk Insurance", - "version": "1.0", - "description": """ - This module adds a new tab in the partner form to introduce risk insurance - information. -""", - "author": "OdooMRP team," - "AvanzOSC," - "Serv. Tecnol. Avanzados - Pedro M. Baeza," - "Factor Libre S.L," - "NaN·tic", - 'contributors': ["Daniel Campos "], - "website": "http://www.factorlibre.com", - "depends": [], - "category": "Custom Modules", - "data": ['views/res_partner_view.xml'], - "active": False, - "installable": True -} diff --git a/partner_risk_insurance/i18n/es.po b/partner_risk_insurance/i18n/es.po index 0f6cbbf69..ef2288f5c 100644 --- a/partner_risk_insurance/i18n/es.po +++ b/partner_risk_insurance/i18n/es.po @@ -1,88 +1,97 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * partner_risk_insurance -# -# Translators: -# Albert Cervera i Areny , 2009 +# * partner_risk_insurance +# msgid "" msgstr "" -"Project-Id-Version: odoomrp-wip (8.0)\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-10-07 10:44+0000\n" -"PO-Revision-Date: 2015-10-09 10:50+0000\n" -"Last-Translator: Pedro M. Baeza \n" -"Language-Team: Spanish (http://www.transifex.com/oca/odoomrp-wip-8-0/language/es/)\n" +"POT-Creation-Date: 2017-08-03 08:18+0000\n" +"PO-Revision-Date: 2017-08-03 10:20+0200\n" +"Last-Translator: Pedro M. Baeza \n" +"Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" "Language: es\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: partner_risk_insurance -#: help:res.partner,risk_insurance_code:0 +#: model:ir.model.fields,help:partner_risk_insurance.field_res_partner_risk_insurance_code +#: model:ir.model.fields,help:partner_risk_insurance.field_res_users_risk_insurance_code msgid "Code assigned to this partner by the risk insurance company." -msgstr "" +msgstr "Code assigned to this partner by the risk insurance company." #. module: partner_risk_insurance -#: field:res.partner,company_credit_limit:0 +#: model:ir.model.fields,field_description:partner_risk_insurance.field_res_partner_company_credit_limit +#: model:ir.model.fields,field_description:partner_risk_insurance.field_res_users_company_credit_limit msgid "Company's Credit Limit" msgstr "Límite de crédito de la compañía" #. module: partner_risk_insurance -#: view:res.partner:partner_risk_insurance.view_partner_form +#: model:ir.ui.view,arch_db:partner_risk_insurance.view_partner_form msgid "Credit Insurance" msgstr "Seguro de riesgo" #. module: partner_risk_insurance -#: help:res.partner,company_credit_limit:0 +#: model:ir.model.fields,help:partner_risk_insurance.field_res_partner_company_credit_limit +#: model:ir.model.fields,help:partner_risk_insurance.field_res_users_company_credit_limit msgid "Credit limit granted by the company." msgstr "Límite de crédito concedido por la compañía" #. module: partner_risk_insurance -#: help:res.partner,insurance_credit_limit:0 +#: model:ir.model.fields,help:partner_risk_insurance.field_res_partner_insurance_credit_limit +#: model:ir.model.fields,help:partner_risk_insurance.field_res_users_insurance_credit_limit msgid "Credit limit granted by the insurance company." msgstr "Crédito concedido por la compañía aseguradora." #. module: partner_risk_insurance -#: help:res.partner,risk_insurance_grant_date:0 +#: model:ir.model.fields,help:partner_risk_insurance.field_res_partner_risk_insurance_grant_date +#: model:ir.model.fields,help:partner_risk_insurance.field_res_users_risk_insurance_grant_date msgid "Date when the insurance was granted by the insurance company." msgstr "Fecha en que se concedió el seguro." #. module: partner_risk_insurance -#: field:res.partner,risk_insurance_code:0 +#: model:ir.model.fields,field_description:partner_risk_insurance.field_res_partner_risk_insurance_code +#: model:ir.model.fields,field_description:partner_risk_insurance.field_res_users_risk_insurance_code msgid "Insurance Code" msgstr "Código del seguro" #. module: partner_risk_insurance -#: field:res.partner,risk_insurance_code_2:0 +#: model:ir.model.fields,field_description:partner_risk_insurance.field_res_partner_risk_insurance_code_2 +#: model:ir.model.fields,field_description:partner_risk_insurance.field_res_users_risk_insurance_code_2 msgid "Insurance Code 2" msgstr "Código del seguro 2" #. module: partner_risk_insurance -#: field:res.partner,risk_insurance_grant_date:0 +#: model:ir.model.fields,field_description:partner_risk_insurance.field_res_partner_risk_insurance_grant_date +#: model:ir.model.fields,field_description:partner_risk_insurance.field_res_users_risk_insurance_grant_date msgid "Insurance Grant Date" msgstr "Fecha de concesión del seguro" #. module: partner_risk_insurance -#: field:res.partner,risk_insurance_requested:0 +#: model:ir.model.fields,field_description:partner_risk_insurance.field_res_partner_risk_insurance_requested +#: model:ir.model.fields,field_description:partner_risk_insurance.field_res_users_risk_insurance_requested msgid "Insurance Requested" msgstr "Seguro solicitado" #. module: partner_risk_insurance -#: field:res.partner,risk_insurance_coverage_percent:0 +#: model:ir.model.fields,field_description:partner_risk_insurance.field_res_partner_risk_insurance_coverage_percent +#: model:ir.model.fields,field_description:partner_risk_insurance.field_res_users_risk_insurance_coverage_percent msgid "Insurance's Credit Coverage" msgstr "Cobertura de riesgo del seguro" #. module: partner_risk_insurance -#: field:res.partner,insurance_credit_limit:0 +#: model:ir.model.fields,field_description:partner_risk_insurance.field_res_partner_insurance_credit_limit +#: model:ir.model.fields,field_description:partner_risk_insurance.field_res_users_insurance_credit_limit msgid "Insurance's Credit Limit" msgstr "Crédito concedido por el seguro" #. module: partner_risk_insurance -#: help:res.partner,risk_insurance_requested:0 -msgid "" -"Mark this field if an insurance was requested for the credit of this " -"partner." +#: model:ir.model.fields,help:partner_risk_insurance.field_res_partner_risk_insurance_requested +#: model:ir.model.fields,help:partner_risk_insurance.field_res_users_risk_insurance_requested +msgid "Mark this field if an insurance was requested for the credit of this partner." msgstr "Marque este campo si se ha pedido un seguro para el crédito de esta empresa." #. module: partner_risk_insurance @@ -91,11 +100,13 @@ msgid "Partner" msgstr "Empresa" #. module: partner_risk_insurance -#: help:res.partner,risk_insurance_coverage_percent:0 +#: model:ir.model.fields,help:partner_risk_insurance.field_res_partner_risk_insurance_coverage_percent +#: model:ir.model.fields,help:partner_risk_insurance.field_res_users_risk_insurance_coverage_percent msgid "Percentage of the credit covered by the insurance." msgstr "Porcentaje de crédito cubierto por el seguro." #. module: partner_risk_insurance -#: help:res.partner,risk_insurance_code_2:0 +#: model:ir.model.fields,help:partner_risk_insurance.field_res_partner_risk_insurance_code_2 +#: model:ir.model.fields,help:partner_risk_insurance.field_res_users_risk_insurance_code_2 msgid "Secondary code assigned to this partner by the risk insurance company." -msgstr "" +msgstr "Secondary code assigned to this partner by the risk insurance company." diff --git a/partner_risk_insurance/i18n/es_ES.po b/partner_risk_insurance/i18n/es_ES.po deleted file mode 100644 index 0cf95d08e..000000000 --- a/partner_risk_insurance/i18n/es_ES.po +++ /dev/null @@ -1,101 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * partner_risk_insurance -# -# Translators: -# Albert Cervera i Areny , 2009 -msgid "" -msgstr "" -"Project-Id-Version: odoomrp-wip (8.0)\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-10-07 10:44+0000\n" -"PO-Revision-Date: 2015-09-10 16:43+0000\n" -"Last-Translator: OCA Transbot \n" -"Language-Team: Spanish (Spain) (http://www.transifex.com/oca/odoomrp-wip-8-0/language/es_ES/)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Language: es_ES\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" - -#. module: partner_risk_insurance -#: help:res.partner,risk_insurance_code:0 -msgid "Code assigned to this partner by the risk insurance company." -msgstr "" - -#. module: partner_risk_insurance -#: field:res.partner,company_credit_limit:0 -msgid "Company's Credit Limit" -msgstr "Crédito concedido por la companyía" - -#. module: partner_risk_insurance -#: view:res.partner:partner_risk_insurance.view_partner_form -msgid "Credit Insurance" -msgstr "Seguro de riesgo" - -#. module: partner_risk_insurance -#: help:res.partner,company_credit_limit:0 -msgid "Credit limit granted by the company." -msgstr "Crédito concedido por la companyía." - -#. module: partner_risk_insurance -#: help:res.partner,insurance_credit_limit:0 -msgid "Credit limit granted by the insurance company." -msgstr "Crédito concedido por la compañía aseguradora." - -#. module: partner_risk_insurance -#: help:res.partner,risk_insurance_grant_date:0 -msgid "Date when the insurance was granted by the insurance company." -msgstr "Fecha en que se concedió el seguro." - -#. module: partner_risk_insurance -#: field:res.partner,risk_insurance_code:0 -msgid "Insurance Code" -msgstr "Código del seguro" - -#. module: partner_risk_insurance -#: field:res.partner,risk_insurance_code_2:0 -msgid "Insurance Code 2" -msgstr "Código del seguro 2" - -#. module: partner_risk_insurance -#: field:res.partner,risk_insurance_grant_date:0 -msgid "Insurance Grant Date" -msgstr "Fecha de concesión del seguro" - -#. module: partner_risk_insurance -#: field:res.partner,risk_insurance_requested:0 -msgid "Insurance Requested" -msgstr "Seguro solicitado" - -#. module: partner_risk_insurance -#: field:res.partner,risk_insurance_coverage_percent:0 -msgid "Insurance's Credit Coverage" -msgstr "Cobertura de riesgo del seguro" - -#. module: partner_risk_insurance -#: field:res.partner,insurance_credit_limit:0 -msgid "Insurance's Credit Limit" -msgstr "Crédito concedido por el seguro" - -#. module: partner_risk_insurance -#: help:res.partner,risk_insurance_requested:0 -msgid "" -"Mark this field if an insurance was requested for the credit of this " -"partner." -msgstr "Marque este campo si se ha pedido un seguro para el crédito de esta empresa." - -#. module: partner_risk_insurance -#: model:ir.model,name:partner_risk_insurance.model_res_partner -msgid "Partner" -msgstr "" - -#. module: partner_risk_insurance -#: help:res.partner,risk_insurance_coverage_percent:0 -msgid "Percentage of the credit covered by the insurance." -msgstr "Porcentage de crédito cubierto por el seguro." - -#. module: partner_risk_insurance -#: help:res.partner,risk_insurance_code_2:0 -msgid "Secondary code assigned to this partner by the risk insurance company." -msgstr "" diff --git a/partner_risk_insurance/i18n/partner_risk_insurance.pot b/partner_risk_insurance/i18n/partner_risk_insurance.pot deleted file mode 100644 index 4987a0c34..000000000 --- a/partner_risk_insurance/i18n/partner_risk_insurance.pot +++ /dev/null @@ -1,112 +0,0 @@ -# Translation of OpenERP Server. -# This file contains the translation of the following modules: -# * nan_partner_risk_insurance -# -msgid "" -msgstr "" -"Project-Id-Version: OpenERP Server 5.0.6\n" -"Report-Msgid-Bugs-To: support@openerp.com\n" -"POT-Creation-Date: 2009-09-23 18:14:48+0000\n" -"PO-Revision-Date: 2009-09-23 18:14:48+0000\n" -"Last-Translator: <>\n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: \n" - -#. module: nan_partner_risk_insurance -#: field:res.partner,risk_insurance_code_2:0 -msgid "Insurance Code 2" -msgstr "" - -#. module: nan_partner_risk_insurance -#: constraint:ir.ui.view:0 -msgid "Invalid XML for View Architecture!" -msgstr "" - -#. module: nan_partner_risk_insurance -#: help:res.partner,company_credit_limit:0 -msgid "Credit limit granted by the company." -msgstr "" - -#. module: nan_partner_risk_insurance -#: field:res.partner,risk_insurance_code:0 -msgid "Insurance Code" -msgstr "" - -#. module: nan_partner_risk_insurance -#: field:res.partner,company_credit_limit:0 -msgid "Company's Credit Limit" -msgstr "" - -#. module: nan_partner_risk_insurance -#: help:res.partner,risk_insurance_requested:0 -msgid "Mark this field if an insurance was requested for the credit of this partner." -msgstr "" - -#. module: nan_partner_risk_insurance -#: help:res.partner,risk_insurance_coverage_percent:0 -msgid "Percentage of the credit covered by the insurance." -msgstr "" - -#. module: nan_partner_risk_insurance -#: field:res.partner,risk_insurance_grant_date:0 -msgid "Insurance Grant Date" -msgstr "" - -#. module: nan_partner_risk_insurance -#: field:res.partner,insurance_credit_limit:0 -msgid "Insurance's Credit Limit" -msgstr "" - -#. module: nan_partner_risk_insurance -#: field:res.partner,risk_insurance_requested:0 -msgid "Insurance Requested" -msgstr "" - -#. module: nan_partner_risk_insurance -#: help:res.partner,risk_insurance_grant_date:0 -msgid "Date when the insurance was granted by the insurance company." -msgstr "" - -#. module: nan_partner_risk_insurance -#: help:res.partner,risk_insurance_code_2:0 -msgid "This fields is needed because some risk insurance companies require a supplementary code for each partner." -msgstr "" - -#. module: nan_partner_risk_insurance -#: view:res.partner:0 -msgid "Credit Insurance" -msgstr "" - -#. module: nan_partner_risk_insurance -#: help:res.partner,risk_insurance_code:0 -msgid "This fields is used to store the code the risk insurance company assigns to this partner." -msgstr "" - -#. module: nan_partner_risk_insurance -#: view:res.partner:0 -msgid "Accounting" -msgstr "" - -#. module: nan_partner_risk_insurance -#: help:res.partner,insurance_credit_limit:0 -msgid "Credit limit granted by the insurance company." -msgstr "" - -#. module: nan_partner_risk_insurance -#: field:res.partner,risk_insurance_coverage_percent:0 -msgid "Insurance's Credit Coverage" -msgstr "" - -#. module: nan_partner_risk_insurance -#: model:ir.module.module,description:nan_partner_risk_insurance.module_meta_information -msgid "This module adds a new tab in the partner form to introduce risk insurance information." -msgstr "" - -#. module: nan_partner_risk_insurance -#: model:ir.module.module,shortdesc:nan_partner_risk_insurance.module_meta_information -msgid "Partner Risk Insurance" -msgstr "" - diff --git a/partner_risk_insurance/models/__init__.py b/partner_risk_insurance/models/__init__.py index 505f673bb..84d775d2b 100644 --- a/partner_risk_insurance/models/__init__.py +++ b/partner_risk_insurance/models/__init__.py @@ -1,24 +1,3 @@ # -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2009 Albert Cervera i Areny (http://www.nan-tic.com). -# All Rights Reserved -# Copyright (c) 2014 Factor Libre SL. All Rights Reserved -# -# 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 . -# -############################################################################## -from . import res_partner +from . import partner diff --git a/partner_risk_insurance/models/partner.py b/partner_risk_insurance/models/partner.py new file mode 100644 index 000000000..77f4819ef --- /dev/null +++ b/partner_risk_insurance/models/partner.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2014 AvancOSC - Daniel Campos +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class Partner(models.Model): + _inherit = 'res.partner' + + company_credit_limit = fields.Float( + string='Company\'s Credit Limit', + help='Credit limit granted by the company.', + ) + insurance_credit_limit = fields.Float( + string='Insurance\'s Credit Limit', + help='Credit limit granted by the insurance company.', + ) + risk_insurance_coverage_percent = fields.Float( + string='Insurance\'s Credit Coverage', + help='Percentage of the credit covered by the insurance.', + ) + risk_insurance_requested = fields.Boolean( + string='Insurance Requested', + help='Mark this field if an insurance was requested for the credit of ' + 'this partner.', + ) + risk_insurance_grant_date = fields.Date( + string='Insurance Grant Date', + help='Date when the insurance was granted by the insurance company.', + ) + risk_insurance_code = fields.Char( + string='Insurance Code', + help='Code assigned to this partner by the risk insurance company.', + ) + risk_insurance_code_2 = fields.Char( + string='Insurance Code 2', + help='Secondary code assigned to this partner by the risk insurance ' + 'company.', + ) + + @api.onchange('insurance_credit_limit', 'company_credit_limit') + def _onchage_insurance_credit_limit(self): + self.ensure_one() + self.credit_limit = (self.insurance_credit_limit + + self.company_credit_limit) diff --git a/partner_risk_insurance/models/res_partner.py b/partner_risk_insurance/models/res_partner.py deleted file mode 100644 index 133890938..000000000 --- a/partner_risk_insurance/models/res_partner.py +++ /dev/null @@ -1,57 +0,0 @@ - -# -*- encoding: utf-8 -*- -############################################################################## -# -# 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 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 models, fields, api - - -class ResPartner(models.Model): - _inherit = 'res.partner' - - @api.one - @api.depends('company_credit_limit', 'insurance_credit_limit') - def _credit_limit(self): - self.credit_limit = (self.company_credit_limit + - self.insurance_credit_limit) - - credit_limit = fields.Float('Credit Limit', store=True, - compute=_credit_limit) - company_credit_limit = fields.Float("Company's Credit Limit", - help='Credit limit granted by the ' - 'company.') - insurance_credit_limit = fields.Float("Insurance's Credit Limit", - help='Credit limit granted by the ' - 'insurance company.') - risk_insurance_coverage_percent = fields.Float( - "Insurance's Credit Coverage", help='Percentage of the credit covered ' - 'by the insurance.') - risk_insurance_requested = fields.Boolean( - 'Insurance Requested', help='Mark this field if an insurance was ' - 'requested for the credit of this partner.') - risk_insurance_grant_date = fields.Date('Insurance Grant Date', - help='Date when the insurance was ' - 'granted by the insurance company.' - ) - risk_insurance_code = fields.Char('Insurance Code', - help='Code assigned to this partner by ' - 'the risk insurance company.') - risk_insurance_code_2 = fields.Char('Insurance Code 2', - help='Secondary code assigned to this ' - 'partner by the risk insurance ' - 'company.') diff --git a/partner_risk_insurance/tests/__init__.py b/partner_risk_insurance/tests/__init__.py new file mode 100644 index 000000000..8c3b75068 --- /dev/null +++ b/partner_risk_insurance/tests/__init__.py @@ -0,0 +1,3 @@ +# -*- encoding: utf-8 -*- + +from . import test_partner_risk_insurance diff --git a/partner_risk_insurance/tests/test_partner_risk_insurance.py b/partner_risk_insurance/tests/test_partner_risk_insurance.py new file mode 100644 index 000000000..2155197d5 --- /dev/null +++ b/partner_risk_insurance/tests/test_partner_risk_insurance.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests import common + + +class TestPartnerRiskInsurance(common.SavepointCase): + + @classmethod + def setUpClass(cls): + super(TestPartnerRiskInsurance, cls).setUpClass() + cls.partner = cls.env['res.partner'].create({ + 'name': 'Mr. Odoo', + }) + + def test_compute_credit(self): + self.partner.company_credit_limit = 1000.0 + self.partner.insurance_credit_limit = 3000.0 + self.partner._onchage_insurance_credit_limit() + self.assertEqual(self.partner.credit_limit, 4000.0) + # Set credit limit manually: + self.partner.credit_limit = 1500.0 + self.assertEqual(self.partner.credit_limit, 1500.0) diff --git a/partner_risk_insurance/views/res_partner_view.xml b/partner_risk_insurance/views/res_partner_view.xml index d7a17fc96..76a3de9ad 100644 --- a/partner_risk_insurance/views/res_partner_view.xml +++ b/partner_risk_insurance/views/res_partner_view.xml @@ -1,35 +1,28 @@ - - - - + + + res.partner.form.risk_insurance res.partner form - + - - + + - - - - - + + - - - - - + + - - + +