Skip to content

Commit 70169e7

Browse files
author
Laurent Stukkens (LTU)
committed
[REV] sale,sale_project : Avoid sending multiple email on upsell
This reverts commit f95356a. Revert unwanted r+ Original PR:odoo#78457 closes odoo#79275 Signed-off-by: Kevin Baptiste <[email protected]>
1 parent fb372fb commit 70169e7

File tree

5 files changed

+3
-87
lines changed

5 files changed

+3
-87
lines changed

addons/sale/models/sale.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -511,19 +511,13 @@ def create(self, vals):
511511
return result
512512

513513
def _compute_field_value(self, field):
514-
send_mail = True
515-
for record in self:
516-
if field.name == 'invoice_status' and record._origin.invoice_status == 'upselling':
517-
send_mail = False
518-
519514
super()._compute_field_value(field)
520-
if field.name != 'invoice_status' or self.env.context.get('mail_activity_automation_skip') or not send_mail:
515+
if field.name != 'invoice_status' or self.env.context.get('mail_activity_automation_skip'):
521516
return
522-
517+
523518
filtered_self = self.filtered(lambda so: so.user_id and so.invoice_status == 'upselling')
524519
if not filtered_self:
525520
return
526-
527521

528522
filtered_self.activity_unlink(['sale.mail_act_sale_upsell'])
529523
for order in filtered_self:

addons/sale_timesheet/tests/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@
1010
from . import test_reporting
1111
from . import test_project_overview
1212
from . import test_project_billing_multicompany
13-

addons/sale_timesheet/tests/common.py

-17
Original file line numberDiff line numberDiff line change
@@ -319,20 +319,3 @@ def setUpClass(cls, chart_template_ref=None):
319319
'taxes_id': False,
320320
'property_account_income_id': cls.account_sale.id,
321321
})
322-
323-
cls.service_prepaid = cls.env['product.product'].create({
324-
'name': "Service delivered, create task in new project",
325-
'standard_price': 10,
326-
'list_price': 20,
327-
'type': 'service',
328-
'invoice_policy': 'delivery',
329-
'uom_id': uom_hour.id,
330-
'uom_po_id': uom_hour.id,
331-
'default_code': 'SERV-DELI3',
332-
'service_type': 'manual',
333-
'service_tracking': 'task_in_project',
334-
'project_id': False, # will create a project
335-
'taxes_id': False,
336-
'property_account_income_id': cls.account_sale.id,
337-
'service_policy': 'ordered_timesheet'
338-
})

addons/sale_timesheet/tests/test_sale_service.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -596,4 +596,4 @@ def test_copy_billable_project_and_task(self):
596596

597597
# copy the task
598598
task_copy = task.copy()
599-
self.assertEqual(task_copy.sale_line_id, task.sale_line_id, "Duplicating task should keep its Sale line")
599+
self.assertEqual(task_copy.sale_line_id, task.sale_line_id, "Duplicating task should keep its Sale line")

addons/sale_timesheet/tests/test_sale_timesheet.py

-60
Original file line numberDiff line numberDiff line change
@@ -671,63 +671,3 @@ def test_change_customer_and_SOL_after_invoiced_timesheet(self):
671671
self.assertEqual(self.partner_b, task_so1_timesheet2.partner_id, "The Task's second Timesheet entry should have its partner changed, as it was not invoiced and the Task's partner/customer changed.")
672672
self.assertEqual(so1_product_global_project_so_line, task_so1_timesheet1.so_line, "The Task's first Timesheet entry should not have changed as it was already invoiced (its so_line should still be equal to the first Sales Order line).")
673673
self.assertEqual(so2_product_global_project_so_line, task_so1_timesheet2.so_line, "The Task's second Timesheet entry should have it's so_line changed, as the Sales Order Item of the Task changed, and this entry was not invoiced.")
674-
675-
def test_timesheet_upsell(self):
676-
""" Test timesheet upselling and email """
677-
678-
self.sale_order_with_user = self.env['sale.order'].with_context(mail_notrack=True, mail_create_nolog=True).create({
679-
'partner_id': self.partner_a.id,
680-
'partner_invoice_id': self.partner_a.id,
681-
'partner_shipping_id': self.partner_a.id,
682-
'user_id' : self.user_employee_company_B.id
683-
})
684-
# create SO and confirm it
685-
uom_days = self.env.ref('uom.product_uom_day')
686-
sale_order_line = self.env['sale.order.line'].create({
687-
'order_id': self.sale_order_with_user.id,
688-
'name': self.service_prepaid.name,
689-
'product_id': self.service_prepaid.id,
690-
'product_uom_qty': 1,
691-
'product_uom': uom_days.id,
692-
'price_unit': self.service_prepaid.list_price,
693-
})
694-
self.sale_order_with_user.action_confirm()
695-
task = self.env['project.task'].search([('sale_line_id', '=', sale_order_line.id)])
696-
697-
# let's log some timesheets
698-
self.env['account.analytic.line'].create({
699-
'name': 'Test Line',
700-
'project_id': task.project_id.id,
701-
'task_id': task.id,
702-
'unit_amount': 8,
703-
'employee_id': self.employee_manager.id,
704-
})
705-
706-
self.sale_order_with_user._create_invoices()
707-
id_max = self.env['mail.message'].search([], order='id desc', limit=1)
708-
if id_max:
709-
id_max = id_max[0].id
710-
else:
711-
id_max = 0
712-
self.env['account.analytic.line'].create({
713-
'name': 'Test Line',
714-
'project_id': task.project_id.id,
715-
'task_id': task.id,
716-
'unit_amount': 5,
717-
'employee_id': self.employee_user.id,
718-
})
719-
720-
self.assertEqual(self.sale_order_with_user.invoice_status, 'upselling', 'Sale Timesheet: "invoice on delivery" timesheets should not modify the invoice_status of the so')
721-
message_sent = self.env['mail.message'].search([('id', '>', id_max), ('subject', 'like', 'Upsell')])
722-
self.assertEqual(len(message_sent),1,'Sale Timesheet: An email should always be sent to the saleperson when the state of the sale order change to upselling')
723-
724-
self.env['account.analytic.line'].create({
725-
'name': 'Test Line',
726-
'project_id': task.project_id.id,
727-
'task_id': task.id,
728-
'unit_amount': 5,
729-
'employee_id': self.employee_user.id,
730-
})
731-
732-
message_sent = self.env['mail.message'].search([('id', '>', id_max), ('subject', 'like', 'Upsell')])
733-
self.assertEqual(len(message_sent),1,'Sale Timesheet: An email should only be sent to the saleperson when the state of the sale order change to upselling')

0 commit comments

Comments
 (0)