From cb7d2dd1e5a233dabe7bd6b1c70e8588b791496b Mon Sep 17 00:00:00 2001 From: benjamin <benjamin@le-filament.com> Date: Thu, 24 Aug 2023 15:17:54 +0200 Subject: [PATCH] [fix] errors registration --- models/res_partner.py | 16 +++++++++++++++- views/res_partner.xml | 2 +- wizard/scop_compulsory_fields_suivi_wizard.py | 10 +++++----- wizard/scop_registration_wizard.py | 10 +++++++++- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/models/res_partner.py b/models/res_partner.py index 92f2468..0cc8d73 100644 --- a/models/res_partner.py +++ b/models/res_partner.py @@ -161,9 +161,23 @@ class ScopPartner(models.Model): "target": "new", } + def set_registration(self): + self.ensure_one() + wizard = self.env["scop.registration.wizard"].create( + {"partner_id": self.id,} + ) + return { + "name": "Immatriculation", + "type": "ir.actions.act_window", + "view_mode": "form", + "res_model": "scop.registration.wizard", + "res_id": wizard.id, + "target": "new", + } + def scop_cancel_membership(self): for partner in self: - partner.update({"member_status": "not_member"}) + partner.update({"membership_status": "not_member"}) # ------------------------------------------------------ # Business methods diff --git a/views/res_partner.xml b/views/res_partner.xml index 5bd7b3d..9366c99 100644 --- a/views/res_partner.xml +++ b/views/res_partner.xml @@ -67,7 +67,7 @@ <button string="Immatriculation" type="object" - name="scop_cancel_membership" + name="set_registration" attrs="{'invisible': [('is_registration_in_progress', '!=', True)]}" /> </xpath> diff --git a/wizard/scop_compulsory_fields_suivi_wizard.py b/wizard/scop_compulsory_fields_suivi_wizard.py index f275328..7a5f049 100644 --- a/wizard/scop_compulsory_fields_suivi_wizard.py +++ b/wizard/scop_compulsory_fields_suivi_wizard.py @@ -71,12 +71,12 @@ class ScopCompulsoryFieldsSuiviWizard(models.TransientModel): { "extranet_access": True, "extranet_update_company": True, - "tag_ids": [ + "category_id": [ ( 4, self.env.ref( "__export__.res_partner_category_6_a5b5dca7" - ), + ).id, 0, ), ], @@ -93,19 +93,19 @@ class ScopCompulsoryFieldsSuiviWizard(models.TransientModel): for director in self.partner_id.director_ids: director.update( { - "tag_ids": [ + "category_id": [ ( 4, self.env.ref( "__export__.res_partner_category_4_eb133182" - ), + ).id, 0, ), ( 4, self.env.ref( "__export__.res_partner_category_6_a5b5dca7" - ), + ).id, 0, ), ] diff --git a/wizard/scop_registration_wizard.py b/wizard/scop_registration_wizard.py index 9a38a78..4f38283 100644 --- a/wizard/scop_registration_wizard.py +++ b/wizard/scop_registration_wizard.py @@ -24,5 +24,13 @@ class ScopRegistrationWizard(models.TransientModel): """ Passe la coop en statut "4_suivi" """ - self.partner_id.sudo()._create_period(self.partner_id) + last_period = self.partner_id.scop_period_ids.filtered(lambda p: not p.end) + if last_period: + last_period.ensure_one() + last_period.update({ + "end": self.registration_date, + "end_reason": "registration", + }) + self.partner_id.sudo()._add_period(self.partner_id) + self.partner_id.update({"is_registration_in_progress": False}) return {"type": "ir.actions.act_window_close"} -- GitLab