Skip to content

Commit

Permalink
[T-6536][FIX]: Pre-commit of all modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Tisho99 committed Sep 25, 2024
1 parent da8db9c commit 4858ab3
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 35 deletions.
4 changes: 2 additions & 2 deletions crm_autoassign/README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
:target: http://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

==============
CRM Autoassign
Expand Down
1 change: 0 additions & 1 deletion crm_autoassign/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@

from .post_install import post_init_hook
from . import models
from . import tests
7 changes: 4 additions & 3 deletions crm_autoassign/models/crm_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ def action_autoassign_opportunities(self):
action_id = self.env.ref("crm_autoassign.crm_autoassign_cron")
try:
self._cr.execute(
f"SELECT id FROM ir_cron WHERE id in ({action_id.id}) FOR UPDATE NOWAIT"
"SELECT id FROM ir_cron WHERE id IN %s FOR UPDATE NOWAIT",
(tuple([action_id.id])),
)
except psycopg2.OperationalError:
raise UserError(
_(
"Odoo is currently executing the planned action of opportunity"
" allocation. Please try again later."
)
)
) from UserError
for sel in self:
sel.env["crm.team.member"].action_autoassign_opportunities(sel)

Expand All @@ -58,7 +59,7 @@ def checks_team_leader(self):
"""
for sel in self.filtered(lambda x: x.user_id in x.member_ids):
if sel.crm_team_member_ids.filtered(
lambda x: x.user_id == sel.user_id
lambda x, sel=sel: x.user_id == sel.user_id
).autoassign_opportunities:
raise ValidationError(
_(
Expand Down
20 changes: 12 additions & 8 deletions crm_autoassign/models/crm_team_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ class CrmTeamMember(models.Model):
_inherit = "crm.team.member"

assignment_optout = fields.Boolean(default=True)
autoassign_opportunities = fields.Boolean(
string="Autoassign Opportunities", default=False
)
assignment_days = fields.Integer(string="Assignement Days", default=0)
autoassign_opportunities = fields.Boolean(default=False)
assignment_days = fields.Integer(default=0)
max_assignment = fields.Integer(
string="Maximum number of assignments",
help="Maximum number of assignments in the last 'Assignment days'",
Expand Down Expand Up @@ -133,6 +131,11 @@ def action_autoassign_opportunities(self, team_id=None):
vals["stage_id"] = opportunity.team_id.stage_after_autoassign.id
opportunity.write(vals)
if auto_commit:
# cr.commit() is performed because:
# the changes are needed in the next iteration
# you can't wait for the system to do the save

# pylint: disable=invalid-commit
self._cr.commit()

@api.constrains("autoassign_opportunities")
Expand All @@ -145,8 +148,9 @@ def checks_team_manager(self):
):
raise ValidationError(
_(
"Member {} cannot autoassign opportunities because he is the "
"leader of team {}. The team leader's opportunities must be "
"assigned manually."
).format(sel.user_id.name, sel.crm_team_id.name)
"Member %(member_name)s cannot autoassign opportunities "
"because he is the leader of team %(team_name)s. "
"The team leader's opportunities must be assigned manually."
)
% {"member_name": sel.user_id.name, "team_name": sel.crm_team_id.name}
)
2 changes: 1 addition & 1 deletion crm_autoassign/tests/test_crm_atoassign.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class TestCrmAutoassign(common.TransactionCase):

@classmethod
def setUpClass(cls):
super(TestCrmAutoassign, cls).setUpClass()
super().setUpClass()
cls.user_ids = cls.env["res.users"]
cls.team_ids = cls.env["crm.team"]
cls.member_ids = cls.env["crm.team.member"]
Expand Down
4 changes: 2 additions & 2 deletions crm_group_sale_salesman_extension/README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
:target: http://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

=================================
CRM Group Sale Salesman Extension
Expand Down
2 changes: 2 additions & 0 deletions crm_group_sale_salesman_extension/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright 2023 Ángel García de la Chica <angel.garcia@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3 changes: 3 additions & 0 deletions crm_group_sale_salesman_extension/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
4 changes: 2 additions & 2 deletions crm_sale_automatic_quotation/README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
:target: http://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

============================
CRM Sale Automatic Quotation
Expand Down
5 changes: 1 addition & 4 deletions crm_sale_automatic_quotation/data/mail_activity_type.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
<!-- Copyright 2024 Alberto Martínez <alberto.martinez@sygel.es>
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo noupdate="1">
<record
id="crm_sale_automatic_quotation.review_activity"
model="mail.activity.type"
>
<record id="review_activity" model="mail.activity.type">
<field name="name">Review Automatic Quotation</field>
<field name="summary">Review Automatic Quotation</field>
<field name="category">default</field>
Expand Down
2 changes: 1 addition & 1 deletion crm_sale_automatic_quotation/models/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _action_generate_automatic_quotation(self, from_wizard=False):
quotation_id = res.create(vals_list)
# To update the quotation template fields in the quotation
quotation_id.with_context(
dict(self._context, is_crm_automatic_quotation=True)
**dict(self._context, is_crm_automatic_quotation=True)
).onchange_sale_order_template_id()
self._recompute_quotation_lines(quotation_id.order_line)
res |= quotation_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class CrmSaleAutomaticQuotationWizard(models.TransientModel):
_name = "crm.sale.automatic.quotation.wizard"

skip_quoted_leads = fields.Boolean(
string="Skip Quoted Leads",
default=True,
)
force_user_id = fields.Boolean(
Expand All @@ -26,11 +25,9 @@ class CrmSaleAutomaticQuotationWizard(models.TransientModel):
help="User that will send the email and have the quotation assigned",
)
send_mail = fields.Boolean(
string="Send Mail",
default=True,
)
email_template = fields.Many2one(
string="Email Template",
comodel_name="mail.template",
domain=lambda self: [
("model_id", "=", self.env.ref("sale.model_sale_order").id)
Expand Down Expand Up @@ -92,18 +89,22 @@ def _create_failed_lead_lines(self, lead_ids, error):
def _get_error_types(self):
# Filter Function, # Condition, # Error MSG
return [
(lambda l: not l.partner_id, True, _("The lead does not have a partner")),
(lambda li: not li.partner_id, True, _("The lead does not have a partner")),
(
lambda l: not l.partner_id.email,
lambda li: not li.partner_id.email,
self.send_mail,
_("The partner does not have an email"),
),
(
lambda l: l.order_ids.filtered(lambda o: o.state != "cancel"),
lambda li: li.order_ids.filtered(lambda o: o.state != "cancel"),
self.skip_quoted_leads,
_("The lead already has quotations"),
),
(lambda l: l.type in ["lead", False], True, _("The lead is in lead state")),
(
lambda li: li.type in ["lead", False],
True,
_("The lead is in lead state"),
),
]

def _filter_leads_and_classify_errors(self, lead_ids):
Expand Down Expand Up @@ -216,6 +217,5 @@ class CrmSaleAutomaticQuotationWizardLine(models.TransientModel):
comodel_name="crm.lead",
)
error = fields.Char(
string="Error",
readonly=True,
)
4 changes: 2 additions & 2 deletions crm_sale_automatic_quotation_asynchronous_wizard/README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
:target: http://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

================================================
CRM Sale Automatic Quotation Asynchronous Wizard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def _send_mail(self, template, quote_ids):
channel="root.crm_sale_automatic_quotation_wizard_email"
)._delay_send_mail(template, quote_ids)
else:
super()._send_mail(template, quote_ids)
return super()._send_mail(template, quote_ids)

@api.model
def _delay_send_mail(self, template, quote_ids):
Expand Down

0 comments on commit 4858ab3

Please sign in to comment.