From 82aa558e973bfadc50ac6110edb784c72e09bcf6 Mon Sep 17 00:00:00 2001 From: VoicuStefan2001 Date: Tue, 29 Oct 2024 14:47:20 +0200 Subject: [PATCH] [16.0][UPD] deltatech_business_process --- README.md | 2 +- deltatech_business_process/README.rst | 2 +- deltatech_business_process/__manifest__.py | 3 +- .../data/email_templates.xml | 55 ++++++++++++++++++ .../models/business_development.py | 21 +++++++ .../models/business_process.py | 52 ++++++++++++++++- .../models/business_project.py | 58 ++++++++++++++++--- .../static/description/index.html | 2 +- .../views/business_development_view.xml | 3 + .../views/business_process_test_view.xml | 6 ++ .../views/business_process_view.xml | 24 ++++++++ .../views/business_project_view.xml | 4 ++ 12 files changed, 218 insertions(+), 14 deletions(-) create mode 100644 deltatech_business_process/data/email_templates.xml diff --git a/README.md b/README.md index a2ac7df859..d06a329020 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ addon | version | maintainers | summary | price [deltatech_average_payment_period](deltatech_average_payment_period/) | 16.0.1.0.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Computes average duration of cash accounting | Free [deltatech_backup_attachment](deltatech_backup_attachment/) | 16.0.1.0.1 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Backup attachments for selected file type | Free [deltatech_batch_transfer](deltatech_batch_transfer/) | 16.0.0.0.2 | [![danila12](https://github.com/danila12.png?size=30px)](https://github.com/danila12) | Batch transfer improvements | Free -[deltatech_business_process](deltatech_business_process/) | 16.0.1.2.4 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Business process | Free +[deltatech_business_process](deltatech_business_process/) | 16.0.1.2.8 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Business process | Free [deltatech_business_process_documentation](deltatech_business_process_documentation/) | 16.0.1.0.5 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Business process documentation | Free [deltatech_business_process_handover_document](deltatech_business_process_handover_document/) | 16.0.0.0.1 | [![VoicuStefan2001](https://github.com/VoicuStefan2001.png?size=30px)](https://github.com/VoicuStefan2001) | Business process verbal process | Free [deltatech_card_payment](deltatech_card_payment/) | 16.0.1.0.1 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Deltatech Payment Method Card | Free diff --git a/deltatech_business_process/README.rst b/deltatech_business_process/README.rst index 1cf321ded5..244ddf8420 100644 --- a/deltatech_business_process/README.rst +++ b/deltatech_business_process/README.rst @@ -7,7 +7,7 @@ Business process !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:55cc06f7ddea6bf434a6e8e771cf25c074164935ac51559e2411197af5fdb210 + !! source digest: sha256:447452d27b9f597f574a682424e5c5622e855f8c48ccf9e85bbc9e4290623786 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/deltatech_business_process/__manifest__.py b/deltatech_business_process/__manifest__.py index e0d50a92ab..684d6d1951 100644 --- a/deltatech_business_process/__manifest__.py +++ b/deltatech_business_process/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Business process", "summary": "Business process", - "version": "16.0.1.2.4", + "version": "16.0.1.2.8", "author": "Terrabit, Dorin Hongu", "website": "https://www.terrabit.ro", "license": "OPL-1", @@ -29,6 +29,7 @@ "report/business_process_report_view.xml", "report/business_process_test_report_view.xml", "data/ir_sequence_data.xml", + "data/email_templates.xml", "wizard/export_business_process_view.xml", "wizard/import_business_process_view.xml", ], diff --git a/deltatech_business_process/data/email_templates.xml b/deltatech_business_process/data/email_templates.xml new file mode 100644 index 0000000000..8049a089a3 --- /dev/null +++ b/deltatech_business_process/data/email_templates.xml @@ -0,0 +1,55 @@ + + + Development Approved + + Development Approved + {{object.project_id.project_manager_id.partner_id.id}} + +
+

+ Dear , +
+ The development + of + has been approved on + . +
+ Please check and inform colleagues of the current development. + + +

+
+
+ {{object.project_id.project_manager_id.lang}} + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/deltatech_business_process/models/business_development.py b/deltatech_business_process/models/business_development.py index 3b0e07fe7a..236156d93f 100644 --- a/deltatech_business_process/models/business_development.py +++ b/deltatech_business_process/models/business_development.py @@ -1,6 +1,8 @@ # © 2023 Deltatech # See README.rst file on addons root folder for license details +from datetime import date + from odoo import api, fields, models @@ -69,11 +71,30 @@ class BusinessDevelopment(models.Model): customer_id = fields.Many2one(string="Customer", comodel_name="res.partner") + development_duration = fields.Float(string="Development duration") + note = fields.Html(string="Note") + @api.model def create(self, vals): if not vals.get("code", False): vals["code"] = self.env["ir.sequence"].next_by_code(self._name) result = super().create(vals) + + return result + + def write(self, vals): + result = super().write(vals) + if ( + "approved" in vals + and vals["approved"] == "approved" + and self.project_id + and self.project_id.project_manager_id + ): + today = date.today().strftime("%Y-%m-%d") + self.sudo().message_post(body=f"Date of approval: {today}") + template = self.env.ref("deltatech_business_process.email_template_development_approved") + self.env["mail.template"].browse(template.id).send_mail(self.id, force_send=True) + return result def name_get(self): diff --git a/deltatech_business_process/models/business_process.py b/deltatech_business_process/models/business_process.py index 06f15a8dde..577c3f65d0 100644 --- a/deltatech_business_process/models/business_process.py +++ b/deltatech_business_process/models/business_process.py @@ -48,6 +48,11 @@ class BusinessProcess(models.Model): states={"draft": [("readonly", False)], "design": [("readonly", False)]}, ) + module_ids = fields.Many2many( + comodel_name="ir.module.module", + string="Modules", + ) + responsible_id = fields.Many2one( string="Implementation Responsible", domain="[('is_company', '=', False)]", @@ -63,6 +68,7 @@ class BusinessProcess(models.Model): readonly=True, states={"draft": [("readonly", False)], "design": [("readonly", False)]}, ) + customer_id = fields.Many2one( string="Customer Responsible", domain="[('is_company', '=', False)]", @@ -92,6 +98,7 @@ class BusinessProcess(models.Model): count_steps = fields.Integer(string="Count Steps", compute="_compute_count_steps") count_tests = fields.Integer(string="Count Tests", compute="_compute_count_tests") + count_acceptance_tests = fields.Integer(string="Count Acceptance Tests", compute="_compute_count_acceptance_tests") count_developments = fields.Integer(string="Count Developments", compute="_compute_count_developments") doc_count = fields.Integer( @@ -190,6 +197,10 @@ def _compute_count_tests(self): for process in self: process.count_tests = len(process.test_ids) + def _compute_count_acceptance_tests(self): + for process in self: + process.count_acceptance_tests = len(process.test_ids.filtered(lambda x: x.scope == "user_acceptance")) + def _compute_duration_for_completion(self): for process in self: process.duration_for_completion = ( @@ -219,6 +230,35 @@ def action_view_tests(self): action.update({"domain": domain, "context": context}) return action + def action_view_acceptance_tests(self): + if not self.count_acceptance_tests: + self.start_user_acceptance_test() + domain = [("process_id", "=", self.id), ("scope", "=", "user_acceptance")] + context = { + "default_process_id": self.id, + } + tests = self.env["business.process.test"].search(domain) + if len(tests) == 1: + action = self.env.ref("deltatech_business_process.business_process_test_action_form").sudo().read()[0] + action.update( + { + "res_id": tests.id, + "view_mode": "form", + "context": context, + } + ) + else: + action = self.env["ir.actions.actions"]._for_xml_id( + "deltatech_business_process.action_business_process_test" + ) + action.update( + { + "domain": domain, + "context": context, + } + ) + return action + def action_view_developments(self): domain = [("id", "=", self.development_ids.ids)] context = { @@ -229,7 +269,15 @@ def action_view_developments(self): return action def get_attachment_domain(self): - domain = [("res_model", "=", "business.process"), ("res_id", "=", self.id)] + domain = [ + "|", + "&", + ("res_model", "=", "business.process"), + ("res_id", "=", self.id), + "&", + ("res_model", "=", "business.process.test"), + ("res_id", "in", self.test_ids.ids), + ] return domain def _compute_attached_docs_count(self): @@ -289,7 +337,7 @@ def _start_test(self, scope): { "name": _("Test %s") % process.code if process.code else process.name, "process_id": process.id, - "tester_id": process.responsible_id.id, + "tester_id": self.env.user.partner_id.id, "scope": scope, } ) diff --git a/deltatech_business_process/models/business_project.py b/deltatech_business_process/models/business_project.py index 3c127e3c71..15d3ef4c3d 100644 --- a/deltatech_business_process/models/business_project.py +++ b/deltatech_business_process/models/business_project.py @@ -1,7 +1,7 @@ # © 2023 Deltatech # See README.rst file on addons root folder for license details -from odoo import api, fields, models +from odoo import _, api, fields, models class BusinessProject(models.Model): @@ -41,6 +41,16 @@ class BusinessProject(models.Model): ) team_member_ids = fields.Many2many(string="Team members", comodel_name="res.partner") total_project_duration = fields.Float(string="Total project duration") + doc_count = fields.Integer( + string="Count Documents", + help="Number of documents attached", + compute="_compute_attached_docs_count", + ) + project_manager_id = fields.Many2one( + string="Project Manager", + comodel_name="res.users", + domain="[('is_company', '=', False)]", + ) @api.model def create(self, vals): @@ -69,9 +79,7 @@ def _compute_count_steps(self): def _compute_count_developments(self): for project in self: - developments = self.env["business.development"] - for process in project.process_ids: - developments |= process.development_ids + developments = self.env["business.development"].search([("project_id", "=", self.id)]) project.count_developments = len(developments) def action_view_processes(self): @@ -84,6 +92,39 @@ def action_view_processes(self): action.update({"domain": domain, "context": context}) return action + def get_attachment_domain(self): + domain = [ + "|", + "|", + "&", + ("res_model", "=", "business.project"), + ("res_id", "=", self.id), + "&", + ("res_model", "=", "business.process"), + ("res_id", "in", self.process_ids.ids), + "&", + ("res_model", "=", "business.process.test"), + ("res_id", "in", self.process_ids.test_ids.ids), + ] + return domain + + def _compute_attached_docs_count(self): + for order in self: + domain = order.get_attachment_domain() + order.doc_count = self.env["ir.attachment"].search_count(domain) + + def attachment_tree_view(self): + domain = self.get_attachment_domain() + return { + "name": _("Attachments"), + "domain": domain, + "res_model": "ir.attachment", + "type": "ir.actions.act_window", + "view_id": False, + "view_mode": "kanban,tree,form", + "context": f"{{'default_res_model': '{self._name}','default_res_id': {self.id}}}", + } + def action_view_issue(self): domain = [("project_id", "=", self.id)] context = { @@ -103,10 +144,7 @@ def action_view_step(self): return action def action_view_developments(self): - developments = self.env["business.development"] - for process in self.process_ids: - developments |= process.development_ids - + developments = self.env["business.development"].search([("project_id", "=", self.id)]) domain = [("id", "=", developments.ids)] context = {"default_project_id": self.id} action = self.env["ir.actions.actions"]._for_xml_id("deltatech_business_process.action_business_development") @@ -116,3 +154,7 @@ def action_view_developments(self): def calculate_total_project_duration(self): for project in self: project.total_project_duration = sum(process.duration_for_completion for process in project.process_ids) + for development in self.env["business.development"].search( + [("project_id", "=", project.id), ("approved", "not in", ("draft", "rejected"))] + ): + project.total_project_duration += development.development_duration diff --git a/deltatech_business_process/static/description/index.html b/deltatech_business_process/static/description/index.html index ebc5fe3214..72a708c1f1 100644 --- a/deltatech_business_process/static/description/index.html +++ b/deltatech_business_process/static/description/index.html @@ -14,7 +14,7 @@

Business process

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:55cc06f7ddea6bf434a6e8e771cf25c074164935ac51559e2411197af5fdb210 +!! source digest: sha256:447452d27b9f597f574a682424e5c5622e855f8c48ccf9e85bbc9e4290623786 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: OPL-1 dhongu/deltatech

diff --git a/deltatech_business_process/views/business_development_view.xml b/deltatech_business_process/views/business_development_view.xml index 7f36112640..64c8f6708c 100644 --- a/deltatech_business_process/views/business_development_view.xml +++ b/deltatech_business_process/views/business_development_view.xml @@ -64,6 +64,7 @@ + @@ -87,6 +88,8 @@ +