From 1defb616fc647da18f37504ea4049d18852818f4 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Wed, 3 Sep 2014 13:05:30 +0200 Subject: [PATCH] [FIX] #688, partner_relations: creating equal but non-overlapping relations was not allowed Conflicts: partner_relations/model/res_partner_relation_all.py --- partner_relations/i18n/nl.po | 37 ++++++++++++++----- .../model/res_partner_relation.py | 31 ++++++++++------ 2 files changed, 46 insertions(+), 22 deletions(-) diff --git a/partner_relations/i18n/nl.po b/partner_relations/i18n/nl.po index 30f9f8b47..0997a6345 100644 --- a/partner_relations/i18n/nl.po +++ b/partner_relations/i18n/nl.po @@ -68,6 +68,11 @@ msgstr "Heeft koppeling" msgid "Has relation with" msgstr "Heeft koppeling met" +#. module: partner_relations +#: field:res.partner,search_relation_partner_category_id:0 +msgid "Has relation with a partner in category" +msgstr "Heeft koppeling met relatie van de categorie" + #. module: partner_relations #: field:res.partner.relation.type,name_inverse:0 msgid "Inverse name" @@ -82,17 +87,17 @@ msgstr "Inverse type" #. module: partner_relations #: field:res.partner.relation,left_partner_id:0 msgid "Left partner" -msgstr "Linker relatie" +msgstr "Linkerrelatie" #. module: partner_relations #: field:res.partner.relation.type,partner_category_left:0 msgid "Left partner category" -msgstr "Linker relatielabel" +msgstr "Linker-relatielabel" #. module: partner_relations #: field:res.partner.relation.type,contact_type_left:0 msgid "Left partner type" -msgstr "Linker relatietype" +msgstr "Linker-relatietype" #. module: partner_relations #: view:res.partner.relation.type:0 @@ -120,6 +125,12 @@ msgstr "Categorie andere record" msgid "Other record's partner type" msgstr "Type andere record" +#. module: partner_relations +#: code:addons/partner_relations/model/res_partner_relation.py:259 +#, python-format +msgid "Overlapping relation" +msgstr "Overlappende koppeling" + #. module: partner_relations #: model:ir.model,name:partner_relations.model_res_partner_relation_type #: model:ir.model,name:partner_relations.model_res_partner_relation_type_inverse @@ -135,7 +146,7 @@ msgstr "Relatie" #. module: partner_relations #: model:ir.model,name:partner_relations.model_res_partner_category msgid "Partner Categories" -msgstr "Relatie Categorieƫn" +msgstr "Relatielabels" #. module: partner_relations #: model:ir.model,name:partner_relations.model_res_partner_relation @@ -169,7 +180,7 @@ msgstr "Koppeling" #. module: partner_relations #: field:res.partner.relation,is_relation_expired:0 msgid "Relation is expired" -msgstr "Koppeling is afgelopen" +msgstr "Koppeling is beƫindigd" #. module: partner_relations #: field:res.partner.relation,is_relation_future:0 @@ -195,17 +206,17 @@ msgstr "Koppelingen" #. module: partner_relations #: field:res.partner.relation,right_partner_id:0 msgid "Right partner" -msgstr "Rechter relatie" +msgstr "Rechterrelatie" #. module: partner_relations #: field:res.partner.relation.type,partner_category_right:0 msgid "Right partner category" -msgstr "Rechter relatielabel" +msgstr "Rechter-relatielabel" #. module: partner_relations #: field:res.partner.relation.type,contact_type_right:0 msgid "Right partner type" -msgstr "Rechter relatietype" +msgstr "Rechter-relatietype" #. module: partner_relations #: view:res.partner.relation.type:0 @@ -221,18 +232,24 @@ msgstr "Begindatum" #. module: partner_relations #: constraint:res.partner.relation:0 msgid "The left partner is not applicable for this relation type." -msgstr "De linker relatie is niet geldig voor dit type koppeling." +msgstr "De linkerrelatie is niet geldig voor dit type koppeling." #. module: partner_relations #: constraint:res.partner.relation:0 msgid "The right partner is not applicable for this relation type." -msgstr "De rechter relatie is niet geldig voor dit type koppeling." +msgstr "De rechterrelatie is niet geldig voor dit type koppeling." #. module: partner_relations #: constraint:res.partner.relation:0 msgid "The starting date cannot be after the ending date." msgstr "De begindatum mag niet na de einddatum liggen." +#. module: partner_relations +#: code:addons/partner_relations/model/res_partner_relation.py:260 +#, python-format +msgid "There is already a similar relation with overlapping dates" +msgstr "Er is al een soortgelijke, overlappende koppeling." + #. module: partner_relations #: field:res.partner.relation,type_id:0 #: field:res.partner.relation,type_selection_id:0 diff --git a/partner_relations/model/res_partner_relation.py b/partner_relations/model/res_partner_relation.py index 515f64a6b..0c2733eb3 100644 --- a/partner_relations/model/res_partner_relation.py +++ b/partner_relations/model/res_partner_relation.py @@ -19,7 +19,7 @@ # along with this program. If not, see . # ############################################################################## -from openerp.osv.orm import Model +from openerp.osv.orm import Model, except_orm from openerp.osv import fields from openerp.tools.translate import _ @@ -241,17 +241,24 @@ class ResPartnerRelation(Model): for this in self.browse(cr, uid, ids, context=context): if not this.active: continue - if self.search( - cr, uid, - [ - ('type_id', '=', this.type_id.id), - ('active', '=', True), - ('id', '!=', this.id), - ('left_partner_id', '=', this.left_partner_id.id), - ('right_partner_id', '=', this.right_partner_id.id), - ], - context=context): - return False + domain = [ + ('type_id', '=', this.type_id.id), + ('active', '=', True), + ('id', '!=', this.id), + ('left_partner_id', '=', this.left_partner_id.id), + ('right_partner_id', '=', this.right_partner_id.id), + ] + if this.date_start: + domain += ['|', ('date_end', '=', False), + ('date_end', '>=', this.date_start)] + if this.date_end: + domain += ['|', ('date_start', '=', False), + ('date_start', '<=', this.date_end)] + if self.search(cr, uid, domain, context=context): + raise except_orm( + _('Overlapping relation'), + _('There is already a similar relation ' + 'with overlapping dates')) return True