diff --git a/models/res_partner.py b/models/res_partner.py index aedbe0c087d6f59a60668f3434b2c0a9a5124cec..ebcda5cdf9a4b51f793cf18e209f44c7063ef39a 100644 --- a/models/res_partner.py +++ b/models/res_partner.py @@ -58,6 +58,9 @@ class ScopPartner(models.Model): string="Année dossier adhésion", related='lm_adhesion_id.year' ) + invoice_adhesion_id = fields.Many2one( + comodel_name='account.invoice', + string='Facture d\'adhésion') # Dossier UE file_fse_open = fields.Boolean("Dossier FSE ouvert Oui/Non") @@ -490,13 +493,14 @@ class ScopPartner(models.Model): - create period adhesion CG - create period adhesion Fédé if needed - create invoice adhesion - - send email to coop (letter and invoice adhesion on extranet) + - set liasse_fiscale_adhesion as qualified """ - # Important to call get_lm_adhesion() first so we can use specific - # adhesion process to create lm if needed instead of process define - # in cgscop_liste_ministere module - lm_adhesion = self.get_lm_adhesion() - super(ScopPartner, self).scop_valid_cg() + + if not self.lm_adhesion_id: + raise ValidationError( + 'Cette coopérative n\'a pas de dossier d\'inscription') + + res = super(ScopPartner, self).scop_valid_cg() # Create period adhésions with num adherent num_adherent = self.create_num_adherent() @@ -505,8 +509,15 @@ class ScopPartner(models.Model): # TODO : check pour fede CAE si coop is CAE ? # Create invoice adhésion - invoice = self.create_invoice_adhesion(lm_adhesion) - return invoice + invoice = self.create_invoice_adhesion(self.lm_adhesion_id) + self.invoice_adhesion_id = invoice + + # set liasse_fiscale_adhesion as qualified + self.lm_adhesion_id.scop_liasse_fiscale_id.write({ + 'is_qualified': True + }) + + return res class ResPartnerPrescriberCanal(models.Model):