Skip to content

Commit

Permalink
Merge pull request #1816 from VoicuStefan2001/16.0
Browse files Browse the repository at this point in the history
[16.0][UPD] deltatech_business_process
  • Loading branch information
VoicuStefan2001 authored Oct 29, 2024
2 parents 013bdda + 82aa558 commit 951a383
Show file tree
Hide file tree
Showing 12 changed files with 218 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deltatech_business_process/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion deltatech_business_process/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
],
Expand Down
55 changes: 55 additions & 0 deletions deltatech_business_process/data/email_templates.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<odoo>
<record id="email_template_development_approved" model="mail.template">
<field name="name">Development Approved</field>
<field name="model_id" ref="model_business_development" />
<field name="subject">Development Approved</field>
<field name="partner_to">{{object.project_id.project_manager_id.partner_id.id}}</field>
<field name="body_html" type="html">
<div style="margin: 0px; padding: 0px;">
<p>
Dear <t t-out="object.project_id.project_manager_id.name" />,
<br />
The development
<t t-out="object.name" /> of <t t-out="object.project_id.name" />
has been approved on
<t t-esc="datetime.date.today().strftime('%d-%m-%Y')" />.
<br />
Please check and inform colleagues of the current development.


</p>
</div>
</field>
<field name="lang">{{object.project_id.project_manager_id.lang}}</field>
<field name="auto_delete" eval="False" />
</record>
</odoo>
<!--<odoo noupdate="1">-->
<!-- <record id="mail_template_negative_stock" model="mail.template">-->
<!-- <field name="name">Location: send negative stock</field>-->
<!-- <field name="model_id" ref="stock.model_stock_location" />-->
<!-- <field name="subject">Negative stock for location {{object.complete_name}}</field>-->
<!-- <field name="partner_to">{{object.user_id.partner_id.id}}</field>-->
<!-- <field name="body_html" type="html">-->
<!-- <div style="margin: 0px; padding: 0px;">-->
<!-- <p style="margin: 0px; padding: 0px; font-size: 12px;">-->
<!-- Negative quantity products:-->
<!-- </p>-->
<!-- <p>-->
<!-- <t t-foreach="object.get_negative_products()" t-as="line">-->
<!-- <t t-foreach="line.items()" t-as="prod">-->
<!-- [<t t-out="prod[0].default_code" />]<t-->
<!-- t-out="prod[0].with_context(lang=object.user_id.lang).name"-->
<!-- />:-->
<!-- <t t-out="prod[1]" />-->
<!-- <t t-out="prod[0].with_context(lang=object.user_id.lang).uom_id.name" />-->
<!-- <br />-->
<!-- </t>-->
<!-- </t>-->
<!-- </p>-->
<!-- </div>-->
<!-- </field>-->
<!-- <field name="lang">{{object.user_id.partner_id.lang}}</field>-->
<!-- <field name="auto_delete" eval="False" />-->
<!-- </record>-->
<!--</odoo>-->
21 changes: 21 additions & 0 deletions deltatech_business_process/models/business_development.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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):
Expand Down
52 changes: 50 additions & 2 deletions deltatech_business_process/models/business_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]",
Expand All @@ -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)]",
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 = (
Expand Down Expand Up @@ -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 = {
Expand All @@ -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):
Expand Down Expand Up @@ -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,
}
)
Expand Down
58 changes: 50 additions & 8 deletions deltatech_business_process/models/business_project.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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 = {
Expand All @@ -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")
Expand All @@ -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
2 changes: 1 addition & 1 deletion deltatech_business_process/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1 class="title">Business process</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:55cc06f7ddea6bf434a6e8e771cf25c074164935ac51559e2411197af5fdb210
!! source digest: sha256:447452d27b9f597f574a682424e5c5622e855f8c48ccf9e85bbc9e4290623786
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="https://www.odoo.com/documentation/master/legal/licenses.html"><img alt="License: OPL-1" src="https://img.shields.io/badge/licence-OPL--1-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/dhongu/deltatech/tree/16.0/deltatech_business_process"><img alt="dhongu/deltatech" src="https://img.shields.io/badge/github-dhongu%2Fdeltatech-lightgray.png?logo=github" /></a></p>
<dl class="docutils">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<group>
<field name="area_id" />
<field name="type_id" />
<field name="development_duration" widget="float_time" />
<field name="approved" />
</group>

Expand All @@ -87,6 +88,8 @@
</group>

</group>
<label for="note" string="note" />
<field name="note" />
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@
<field name="res_model">business.process.test</field>
<field name="view_mode">tree,form,calendar,pivot,graph</field>
</record>
<record id="business_process_test_action_form" model="ir.actions.act_window">
<field name="name">Business Process Test Form</field>
<field name="res_model">business.process.test</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_business_process_test_form" />
</record>
<menuitem
name="Process Tests"
id="menu_business_process_test"
Expand Down
Loading

0 comments on commit 951a383

Please sign in to comment.