Skip to content

Commit

Permalink
[17.0][UPD] deltatech_business_process
Browse files Browse the repository at this point in the history
  • Loading branch information
VoicuStefan2001 committed Oct 29, 2024
1 parent 854c293 commit 633f59b
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 32 deletions.
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": "17.0.1.2.7",
"version": "17.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 @@ -82,11 +84,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

Check warning on line 96 in deltatech_business_process/models/business_development.py

View check run for this annotation

Codecov / codecov/patch

deltatech_business_process/models/business_development.py#L96

Added line #L96 was not covered by tests

def write(self, vals):
result = super().write(vals)

Check warning on line 99 in deltatech_business_process/models/business_development.py

View check run for this annotation

Codecov / codecov/patch

deltatech_business_process/models/business_development.py#L99

Added line #L99 was not covered by tests
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)

Check warning on line 109 in deltatech_business_process/models/business_development.py

View check run for this annotation

Codecov / codecov/patch

deltatech_business_process/models/business_development.py#L106-L109

Added lines #L106 - L109 were not covered by tests

return result

def _compute_display_name(self):
Expand Down
5 changes: 5 additions & 0 deletions deltatech_business_process/models/business_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class BusinessProcess(models.Model):
copy=True,
)

module_ids = fields.Many2many(
comodel_name="ir.module.module",
string="Modules",
)

responsible_id = fields.Many2one(
string="Implementation Responsible",
domain="[('is_company', '=', False)]",
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 @@ -43,6 +43,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 All @@ -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)])

Check warning on line 82 in deltatech_business_process/models/business_project.py

View check run for this annotation

Codecov / codecov/patch

deltatech_business_process/models/business_project.py#L82

Added line #L82 was not covered by tests
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 = [

Check warning on line 96 in deltatech_business_process/models/business_project.py

View check run for this annotation

Codecov / codecov/patch

deltatech_business_process/models/business_project.py#L96

Added line #L96 was not covered by tests
"|",
"|",
"&",
("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

Check warning on line 109 in deltatech_business_process/models/business_project.py

View check run for this annotation

Codecov / codecov/patch

deltatech_business_process/models/business_project.py#L109

Added line #L109 was not covered by tests

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)

Check warning on line 114 in deltatech_business_process/models/business_project.py

View check run for this annotation

Codecov / codecov/patch

deltatech_business_process/models/business_project.py#L113-L114

Added lines #L113 - L114 were not covered by tests

def attachment_tree_view(self):
domain = self.get_attachment_domain()
return {

Check warning on line 118 in deltatech_business_process/models/business_project.py

View check run for this annotation

Codecov / codecov/patch

deltatech_business_process/models/business_project.py#L117-L118

Added lines #L117 - L118 were not covered by tests
"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

Check warning on line 160 in deltatech_business_process/models/business_project.py

View check run for this annotation

Codecov / codecov/patch

deltatech_business_process/models/business_project.py#L160

Added line #L160 was not covered by tests
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
decoration-danger="approved == 'rejected' "
decoration-success="approved == 'approved' "
/>
<field name="state" widget="badge" />
<field name="state" widget="badge" />
<field name="responsible_id" optional="show" />
<field name="date_start_fs" optional="show" />
<field name="date_end_fs" optional="show" />
Expand Down Expand Up @@ -64,7 +64,9 @@
<group>
<field name="area_id" />
<field name="type_id" />
<field name="development_duration" widget="float_time" />
<field name="approved" />
<!-- readonly="approved=='approved'"-->
</group>

<group string="Specification">
Expand All @@ -87,6 +89,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
28 changes: 22 additions & 6 deletions deltatech_business_process/views/business_process_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@
string="Reset to Draft"
invisible="state not in ('design','test','ready')"
/>
<!-- <button-->
<!-- name="start_user_acceptance_test"-->
<!-- type="object"-->
<!-- string="Start Acceptance Test"-->
<!-- invisible="state not in ('design','test','ready')"-->
<!-- />-->
<!-- <button-->
<!-- name="start_user_acceptance_test"-->
<!-- type="object"-->
<!-- string="Start Acceptance Test"-->
<!-- invisible="state not in ('design','test','ready')"-->
<!-- />-->
<field name="state" widget="statusbar" statusbar_visible="draft,design,test,ready,production" />

</header>
Expand Down Expand Up @@ -206,6 +206,22 @@
</tree>
</field>
</page>
<page string="Modules" name="modules">
<field name="module_ids">
<tree editable="bottom">
<field name="shortdesc" />
<field name="name" />
<field name="installed_version" />
<field
name="state"
widget="badge"
decoration-muted="state == 'uninstallable'"
decoration-info="state == 'uninstalled'"
decoration-success="state == 'installed'"
/>
</tree>
</field>
</page>
<page string="Description" name="description">
<label for="description" string="Description" />
<field name="description" />
Expand Down
36 changes: 20 additions & 16 deletions deltatech_business_process/views/business_project_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@
<field name="count_steps" widget="statinfo" string="Steps" />
</button>

<button class="oe_stat_button" type="object" name="action_view_developments" icon="fa-code">
<button class="oe_stat_button" type="object" name="action_view_developments" icon="fa-code">
<field name="count_developments" widget="statinfo" string="Developments" />
</button>
<button class="oe_stat_button" name="attachment_tree_view" type="object" icon="fa-file-text-o">
<field string="Documents" name="doc_count" widget="statinfo" />
</button>


<button
Expand All @@ -67,6 +70,7 @@
<group string="Identification">
<field name="code" />
<field name="customer_id" />
<field name="project_manager_id" />
<field name="total_project_duration" widget="float_time" />
</group>

Expand Down Expand Up @@ -136,23 +140,23 @@
</div>
</div>
<div class="o_kanban_record_bottom mt-3">
<div class="oe_kanban_bottom_left">
<div>
<a name="action_view_processes" type="object">
<div>
<span class="o_value"><t
t-esc="record.count_processes.value"
/></span>
<span class="o_label ms-1">Processes</span>
</div>
</a>
</div>

</div>
<div class="oe_kanban_bottom_right">
<field name="activity_ids" widget="kanban_activity" />
<div class="oe_kanban_bottom_left">
<div>
<a name="action_view_processes" type="object">
<div>
<span class="o_value">
<t t-esc="record.count_processes.value" />
</span>
<span class="o_label ms-1">Processes</span>
</div>
</a>
</div>

</div>
<div class="oe_kanban_bottom_right">
<field name="activity_ids" widget="kanban_activity" />
</div>
</div>
</div>
</t>
</templates>
Expand Down

0 comments on commit 633f59b

Please sign in to comment.