Files
odoo_source/addons/stock/tests/common2.py
T
Aline Preillon 2950ffaa86 [IMP] mail: improve notification management, either email either inbox
Currently partners have a boolean field to choose whether to receive
notifications only in their Odoo inbox or to receive them in their inbox
and by email. This leads to several issues :

 * if a customer is configured to not receive emails he will not receive
   any notification on sales orders, leads, ... This is not clearly
   indicated to the salesman and it is not easy to know how to change
   that behavior
 * if an user chooses to receive emails and does not use its inbox a lot
   of notifications stay in Odoo. The user has to manually set them as
   done to make them disappear which is redundant.

This commit changes that behavior. From now on customers will always
receive all notifications by email. Indeed Odoo is not a customer oriented
mailbox. Moreover sales orders or discussions on leads send to customers
should always be sent by email as it is the standard communication
mechanism. Users will be able to choose to receive notifications in Odoo
or by email. The choice is no longer inbox or inbox + email, but inbox
or email. Choosing one option or the other one depends on the way the
user wants to work.

Technically the field is moved on the users model and selection keys
are renamed. Notification process is modified

 * notified_partner_ids contains as before specified recipients as well
   as followers matching the subtype
 * customers and users working with emails are notified. During that
   process customers notifications are marked as done to be able to
   track the email state without having needaction. Users notifications
   are currently deleted as we do not track their email state.

The removal of partner field implies changes in various addons that
define partner data with this field set in the values.
2017-02-21 16:42:11 +01:00

96 lines
3.8 KiB
Python

# -*- coding: utf-8 -*-
from odoo.addons.product.tests import common
class TestStockCommon(common.TestProductCommon):
def _create_pack_operation(self, product, product_qty, picking_id, **values):
PackOperation = self.env['stock.pack.operation'].sudo(self.user_stock_manager)
vals = {
'picking_id': picking_id.id,
'product_id': product.id,
'product_qty': product_qty,
'qty_done': product_qty}
vals.update(**values)
pack_operation = PackOperation.new(vals)
pack_operation.onchange_product_id()
return PackOperation.create(pack_operation._convert_to_write(pack_operation._cache))
def _create_picking_in(self, warehouse):
Picking = self.env['stock.picking']
picking_values = {
'picking_type_id': warehouse.in_type_id.id,
'location_id': self.env.ref('stock.stock_location_suppliers').id,
'location_dest_id': warehouse.lot_stock_id.id,
}
return Picking.create(picking_values)
def _create_move(self, product, src_location, dst_location, **values):
# TDE FIXME: user as parameter
Move = self.env['stock.move'].sudo(self.user_stock_manager)
# simulate create + onchange
move = Move.new({'product_id': product.id, 'location_id': src_location.id, 'location_dest_id': dst_location.id})
move.onchange_product_id()
move_values = move._convert_to_write(move._cache)
move_values.update(**values)
return Move.create(move_values)
def _create_move_in(self, product, warehouse, picking=None, create_picking=False, **values):
if not picking and create_picking:
picking = self._create_picking_in(warehouse)
if picking:
values['picking_id'] = picking.id
# TDE FIXME: shouldn't location come from picking ??
return self._create_move(product, self.env.ref('stock.stock_location_suppliers'), warehouse.lot_stock_id, **values)
@classmethod
def setUpClass(cls):
super(TestStockCommon, cls).setUpClass()
# Fetch stock-related user groups
user_group_employee = cls.env.ref('base.group_user')
user_group_stock_user = cls.env.ref('stock.group_stock_user')
user_group_stock_manager = cls.env.ref('stock.group_stock_manager')
# User Data: stock user and stock manager
Users = cls.env['res.users'].with_context({'no_reset_password': True, 'mail_create_nosubscribe': True})
cls.user_stock_user = Users.create({
'name': 'Pauline Poivraisselle',
'login': 'pauline',
'email': 'p.p@example.com',
'notification_type': 'inbox',
'groups_id': [(6, 0, [user_group_stock_user.id])]})
cls.user_stock_manager = Users.create({
'name': 'Julie Tablier',
'login': 'julie',
'email': 'j.j@example.com',
'notification_type': 'inbox',
'groups_id': [(6, 0, [user_group_stock_manager.id])]})
# Warehouses
cls.warehouse_1 = cls.env['stock.warehouse'].create({
'name': 'Base Warehouse',
'reception_steps': 'one_step',
'delivery_steps': 'ship_only',
'code': 'BWH'})
# Locations
cls.location_1 = cls.env['stock.location'].create({
'name': 'TestLocation1',
'posx': 3,
'location_id': cls.warehouse_1.lot_stock_id.id,
})
# Existing data
cls.existing_inventories = cls.env['stock.inventory'].search([])
cls.existing_quants = cls.env['stock.quant'].search([])
# Inventory
inventory_wizard = cls.env['stock.change.product.qty'].create({
'product_id': cls.product_1.id,
'new_quantity': 50.0,
'location_id': cls.warehouse_1.lot_stock_id.id,
})
inventory_wizard.change_product_qty()