diff --git a/models/account.py b/models/account.py index 7bb4d72a6d8aa313d28a12204aab958cdccc5e82..b7d3f74cee0516b3235078ab5d99e425874bde27 100644 --- a/models/account.py +++ b/models/account.py @@ -54,6 +54,8 @@ class AccountInvoice(models.Model): ) file.delete() self.proof_file = False + if self.type == "in_invoice": + self.state = "draft" except: self.proof_file = False diff --git a/wizard/upload_file_wizard.py b/wizard/upload_file_wizard.py index f7eb67e462f90a7bf7c4112134b57de1993127d7..408d265d3d79e1c7a629e31b41cdcfdedf2df763 100644 --- a/wizard/upload_file_wizard.py +++ b/wizard/upload_file_wizard.py @@ -26,10 +26,12 @@ class UploadFileWizard(models.TransientModel): Ajoute un fichier sur la GED Alfresco @return: fonction get_partner_files() de res.partner """ + is_in_invoice = False if self.env.context["active_model"] == "account.invoice": account_id = self.env["account.invoice"].browse(self.env.context["active_id"]) if account_id.type == "in_invoice": proof_folder = self.env.user.company_id.proof_invoice_cmis + is_in_invoice = True else: proof_folder = self.env.user.company_id.proof_invoice_customer_cmis else: @@ -74,6 +76,14 @@ class UploadFileWizard(models.TransientModel): ) file_id = file.getProperties().get('cmis:objectId') obj.proof_file = file.getObjectId() + if is_in_invoice == True: + obj.state = "paid" + if obj.task_ids: + for task in obj.task_ids: + task.stage_id = self.env.ref( + "adefpat_project.project_stage_paye" + ).id + except Exception as e: raise UserError(json.loads(e.details).get('message'))