diff --git a/stock_request_purchase/__init__.py b/stock_request_purchase/__init__.py index a9e337226..0650744f6 100644 --- a/stock_request_purchase/__init__.py +++ b/stock_request_purchase/__init__.py @@ -1,2 +1 @@ - from . import models diff --git a/stock_request_purchase/__manifest__.py b/stock_request_purchase/__manifest__.py index e9ca322ae..98e1fb114 100644 --- a/stock_request_purchase/__manifest__.py +++ b/stock_request_purchase/__manifest__.py @@ -7,13 +7,9 @@ "version": "12.0.1.1.2", "license": "LGPL-3", "website": "https://github.com/stock-logistics-warehouse", - "author": "Eficent, " - "Odoo Community Association (OCA)", + "author": "Eficent, " "Odoo Community Association (OCA)", "category": "Warehouse Management", - "depends": [ - "stock_request", - "purchase_stock", - ], + "depends": ["stock_request", "purchase_stock"], "data": [ "security/ir.model.access.csv", "views/stock_request_views.xml", @@ -21,5 +17,5 @@ "views/purchase_order_views.xml", ], "installable": True, - 'auto_install': True, + "auto_install": True, } diff --git a/stock_request_purchase/models/__init__.py b/stock_request_purchase/models/__init__.py index c7cdbaa77..8e8f649b0 100644 --- a/stock_request_purchase/models/__init__.py +++ b/stock_request_purchase/models/__init__.py @@ -1,4 +1,3 @@ - from . import purchase_order from . import purchase_order_line from . import stock_rule diff --git a/stock_request_purchase/models/purchase_order.py b/stock_request_purchase/models/purchase_order.py index 38be3f17f..4c5fb343d 100644 --- a/stock_request_purchase/models/purchase_order.py +++ b/stock_request_purchase/models/purchase_order.py @@ -5,33 +5,35 @@ from odoo import api, fields, models class PurchaseOrder(models.Model): - _inherit = 'purchase.order' + _inherit = "purchase.order" - stock_request_ids = fields.Many2many(comodel_name='stock.request', - string='Stock Requests', - compute='_compute_stock_request_ids') - stock_request_count = fields.Integer('Stock Request #', - compute='_compute_stock_request_ids') + stock_request_ids = fields.Many2many( + comodel_name="stock.request", + string="Stock Requests", + compute="_compute_stock_request_ids", + ) + stock_request_count = fields.Integer( + "Stock Request #", compute="_compute_stock_request_ids" + ) - @api.depends('order_line') + @api.depends("order_line") def _compute_stock_request_ids(self): for rec in self: - rec.stock_request_ids = rec.order_line.mapped('stock_request_ids') + rec.stock_request_ids = rec.order_line.mapped("stock_request_ids") rec.stock_request_count = len(rec.stock_request_ids) def action_view_stock_request(self): """ :return dict: dictionary value for created view """ - action = self.env.ref( - 'stock_request.action_stock_request_form').read()[0] + action = self.env.ref("stock_request.action_stock_request_form").read()[0] - requests = self.mapped('stock_request_ids') + requests = self.mapped("stock_request_ids") if len(requests) > 1: - action['domain'] = [('id', 'in', requests.ids)] + action["domain"] = [("id", "in", requests.ids)] elif requests: - action['views'] = [ - (self.env.ref('stock_request.view_stock_request_form').id, - 'form')] - action['res_id'] = requests.id + action["views"] = [ + (self.env.ref("stock_request.view_stock_request_form").id, "form") + ] + action["res_id"] = requests.id return action diff --git a/stock_request_purchase/models/purchase_order_line.py b/stock_request_purchase/models/purchase_order_line.py index 6c4193465..461f9b8f8 100644 --- a/stock_request_purchase/models/purchase_order_line.py +++ b/stock_request_purchase/models/purchase_order_line.py @@ -1,33 +1,45 @@ # Copyright 2017 Eficent Business and IT Consulting Services, S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from odoo import api, fields, models, _ +from odoo import _, api, fields, models from odoo.exceptions import ValidationError class PurchaseOrderLine(models.Model): - _inherit = 'purchase.order.line' + _inherit = "purchase.order.line" - stock_request_ids = fields.Many2many(comodel_name='stock.request', - string='Stock Requests', copy=False) + stock_request_ids = fields.Many2many( + comodel_name="stock.request", string="Stock Requests", copy=False + ) @api.multi def _prepare_stock_moves(self, picking): res = super(PurchaseOrderLine, self)._prepare_stock_moves(picking) for re in res: - re['allocation_ids'] = [ - (0, 0, { - 'stock_request_id': request.id, - 'requested_product_uom_qty': request.product_qty, - }) for request in self.stock_request_ids] + re["allocation_ids"] = [ + ( + 0, + 0, + { + "stock_request_id": request.id, + "requested_product_uom_qty": request.product_qty, + }, + ) + for request in self.stock_request_ids + ] return res - @api.constrains('stock_request_ids') + @api.constrains("stock_request_ids") def _check_purchase_company_constrains(self): - if any(any(req.company_id != pol.company_id for - req in pol.stock_request_ids) for pol in self): + if any( + any(req.company_id != pol.company_id for req in pol.stock_request_ids) + for pol in self + ): raise ValidationError( - _('You cannot link a purchase order line ' - 'to a stock request that belongs to ' - 'another company.')) + _( + "You cannot link a purchase order line " + "to a stock request that belongs to " + "another company." + ) + ) diff --git a/stock_request_purchase/models/stock_request.py b/stock_request_purchase/models/stock_request.py index a3c58888f..7569744d1 100644 --- a/stock_request_purchase/models/stock_request.py +++ b/stock_request_purchase/models/stock_request.py @@ -1,47 +1,55 @@ # Copyright 2017 Eficent Business and IT Consulting Services, S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from odoo import api, fields, models, _ +from odoo import _, api, fields, models from odoo.exceptions import ValidationError class StockRequest(models.Model): _inherit = "stock.request" - purchase_ids = fields.One2many('purchase.order', - compute='_compute_purchase_ids', - string='Purchase Orders', readonly=True) - purchase_count = fields.Integer(string='Purchase count', - compute='_compute_purchase_ids', - readonly=True) - purchase_line_ids = fields.Many2many('purchase.order.line', - string='Purchase Order Lines', - readonly=True, copy=False) + purchase_ids = fields.One2many( + "purchase.order", + compute="_compute_purchase_ids", + string="Purchase Orders", + readonly=True, + ) + purchase_count = fields.Integer( + string="Purchase count", compute="_compute_purchase_ids", readonly=True + ) + purchase_line_ids = fields.Many2many( + "purchase.order.line", string="Purchase Order Lines", readonly=True, copy=False + ) - @api.depends('purchase_line_ids') + @api.depends("purchase_line_ids") def _compute_purchase_ids(self): for request in self: - request.purchase_ids = request.purchase_line_ids.mapped('order_id') + request.purchase_ids = request.purchase_line_ids.mapped("order_id") request.purchase_count = len(request.purchase_ids) - @api.constrains('purchase_line_ids', 'company_id') + @api.constrains("purchase_line_ids", "company_id") def _check_purchase_company_constrains(self): - if any(any(line.company_id != req.company_id for - line in req.purchase_line_ids) for req in self): + if any( + any(line.company_id != req.company_id for line in req.purchase_line_ids) + for req in self + ): raise ValidationError( - _('You have linked to a purchase order line ' - 'that belongs to another company.')) + _( + "You have linked to a purchase order line " + "that belongs to another company." + ) + ) @api.multi def action_view_purchase(self): - action = self.env.ref( - 'purchase.purchase_order_action_generic').read()[0] + action = self.env.ref("purchase.purchase_order_action_generic").read()[0] - purchases = self.mapped('purchase_ids') + purchases = self.mapped("purchase_ids") if len(purchases) > 1: - action['domain'] = [('id', 'in', purchases.ids)] + action["domain"] = [("id", "in", purchases.ids)] elif purchases: - action['views'] = [ - (self.env.ref('purchase.purchase_order_form').id, 'form')] - action['res_id'] = purchases.id + action["views"] = [ + (self.env.ref("purchase.purchase_order_form").id, "form") + ] + action["res_id"] = purchases.id return action diff --git a/stock_request_purchase/models/stock_request_order.py b/stock_request_purchase/models/stock_request_order.py index 22795008d..b7a25ee0c 100644 --- a/stock_request_purchase/models/stock_request_order.py +++ b/stock_request_purchase/models/stock_request_order.py @@ -5,40 +5,45 @@ from odoo import api, fields, models class StockRequestOrder(models.Model): - _inherit = 'stock.request.order' + _inherit = "stock.request.order" - purchase_ids = fields.One2many('purchase.order', - compute='_compute_purchase_ids', - string='Purchase Orders', readonly=True) - purchase_count = fields.Integer(string='Purchase count', - compute='_compute_purchase_ids', - readonly=True) - purchase_line_ids = fields.Many2many('purchase.order.line', - compute='_compute_purchase_ids', - string='Purchase Order Lines', - readonly=True, copy=False) + purchase_ids = fields.One2many( + "purchase.order", + compute="_compute_purchase_ids", + string="Purchase Orders", + readonly=True, + ) + purchase_count = fields.Integer( + string="Purchase count", compute="_compute_purchase_ids", readonly=True + ) + purchase_line_ids = fields.Many2many( + "purchase.order.line", + compute="_compute_purchase_ids", + string="Purchase Order Lines", + readonly=True, + copy=False, + ) - @api.depends('stock_request_ids') + @api.depends("stock_request_ids") def _compute_purchase_ids(self): for req in self: - req.purchase_ids = req.stock_request_ids.mapped('purchase_ids') - req.purchase_line_ids = req.stock_request_ids.mapped( - 'purchase_line_ids') + req.purchase_ids = req.stock_request_ids.mapped("purchase_ids") + req.purchase_line_ids = req.stock_request_ids.mapped("purchase_line_ids") req.purchase_count = len(req.purchase_ids) @api.multi def action_view_purchase(self): - action = self.env.ref( - 'purchase.purchase_order_action_generic').read()[0] - purchases = self.mapped('purchase_ids') + action = self.env.ref("purchase.purchase_order_action_generic").read()[0] + purchases = self.mapped("purchase_ids") if len(purchases) > 1: - action['domain'] = [('id', 'in', purchases.ids)] - action['views'] = [ - (self.env.ref('purchase.purchase_order_tree').id, 'tree'), - (self.env.ref('purchase.purchase_order_form').id, 'form'), + action["domain"] = [("id", "in", purchases.ids)] + action["views"] = [ + (self.env.ref("purchase.purchase_order_tree").id, "tree"), + (self.env.ref("purchase.purchase_order_form").id, "form"), ] elif purchases: - action['views'] = [ - (self.env.ref('purchase.purchase_order_form').id, 'form')] - action['res_id'] = purchases.id + action["views"] = [ + (self.env.ref("purchase.purchase_order_form").id, "form") + ] + action["res_id"] = purchases.id return action diff --git a/stock_request_purchase/models/stock_rule.py b/stock_request_purchase/models/stock_rule.py index 182428fd8..500840e49 100644 --- a/stock_request_purchase/models/stock_rule.py +++ b/stock_request_purchase/models/stock_rule.py @@ -5,20 +5,24 @@ from odoo import models class StockRule(models.Model): - _inherit = 'stock.rule' + _inherit = "stock.rule" - def _prepare_purchase_order_line(self, product_id, product_qty, - product_uom, values, po, supplier): + def _prepare_purchase_order_line( + self, product_id, product_qty, product_uom, values, po, supplier + ): vals = super(StockRule, self)._prepare_purchase_order_line( - product_id, product_qty, product_uom, values, po, supplier) - if 'stock_request_id' in values: - vals['stock_request_ids'] = [(4, values['stock_request_id'])] + product_id, product_qty, product_uom, values, po, supplier + ) + if "stock_request_id" in values: + vals["stock_request_ids"] = [(4, values["stock_request_id"])] return vals - def _update_purchase_order_line(self, product_id, product_qty, product_uom, - values, line, partner): + def _update_purchase_order_line( + self, product_id, product_qty, product_uom, values, line, partner + ): vals = super(StockRule, self)._update_purchase_order_line( - product_id, product_qty, product_uom, values, line, partner) - if 'stock_request_id' in values: - vals['stock_request_ids'] = [(4, values['stock_request_id'])] + product_id, product_qty, product_uom, values, line, partner + ) + if "stock_request_id" in values: + vals["stock_request_ids"] = [(4, values["stock_request_id"])] return vals diff --git a/stock_request_purchase/tests/__init__.py b/stock_request_purchase/tests/__init__.py index 403f05396..114d97f1c 100644 --- a/stock_request_purchase/tests/__init__.py +++ b/stock_request_purchase/tests/__init__.py @@ -1,2 +1 @@ - from . import test_stock_request_purchase diff --git a/stock_request_purchase/tests/test_stock_request_purchase.py b/stock_request_purchase/tests/test_stock_request_purchase.py index 517827922..07c2984cb 100644 --- a/stock_request_purchase/tests/test_stock_request_purchase.py +++ b/stock_request_purchase/tests/test_stock_request_purchase.py @@ -1,102 +1,120 @@ # Copyright 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0). -from odoo.tests import common from odoo import fields +from odoo.tests import common class TestStockRequestPurchase(common.TransactionCase): - def setUp(self): super(TestStockRequestPurchase, self).setUp() # common models - self.stock_request = self.env['stock.request'] + self.stock_request = self.env["stock.request"] # refs - self.stock_request_user_group = \ - self.env.ref('stock_request.group_stock_request_user') - self.stock_request_manager_group = \ - self.env.ref('stock_request.group_stock_request_manager') - self.main_company = self.env.ref('base.main_company') - self.warehouse = self.env.ref('stock.warehouse0') - self.categ_unit = self.env.ref('uom.product_uom_categ_unit') + self.stock_request_user_group = self.env.ref( + "stock_request.group_stock_request_user" + ) + self.stock_request_manager_group = self.env.ref( + "stock_request.group_stock_request_manager" + ) + self.main_company = self.env.ref("base.main_company") + self.warehouse = self.env.ref("stock.warehouse0") + self.categ_unit = self.env.ref("uom.product_uom_categ_unit") # common data - self.company_2 = self.env['res.company'].create({ - 'name': 'Comp2', - }) - self.wh2 = self.env['stock.warehouse'].search( - [('company_id', '=', self.company_2.id)], limit=1) + self.company_2 = self.env["res.company"].create({"name": "Comp2"}) + self.wh2 = self.env["stock.warehouse"].search( + [("company_id", "=", self.company_2.id)], limit=1 + ) self.stock_request_user = self._create_user( - 'stock_request_user', + "stock_request_user", [self.stock_request_user_group.id], - [self.main_company.id, self.company_2.id]) + [self.main_company.id, self.company_2.id], + ) self.stock_request_manager = self._create_user( - 'stock_request_manager', + "stock_request_manager", [self.stock_request_manager_group.id], - [self.main_company.id, self.company_2.id]) + [self.main_company.id, self.company_2.id], + ) self.route_buy = self.warehouse.buy_pull_id.route_id - self.supplier = self.env['res.partner'].create({ - 'name': 'Supplier', - 'supplier': True, - }) - self.product = self._create_product('SH', 'Shoes', False) + self.supplier = self.env["res.partner"].create( + {"name": "Supplier", "supplier": True} + ) + self.product = self._create_product("SH", "Shoes", False) - self.uom_dozen = self.env['uom.uom'].create({ - 'name': 'Test-DozenA', - 'category_id': self.categ_unit.id, - 'factor_inv': 12, - 'uom_type': 'bigger', - 'rounding': 0.001}) + self.uom_dozen = self.env["uom.uom"].create( + { + "name": "Test-DozenA", + "category_id": self.categ_unit.id, + "factor_inv": 12, + "uom_type": "bigger", + "rounding": 0.001, + } + ) def _create_user(self, name, group_ids, company_ids): - return self.env['res.users'].with_context( - {'no_reset_password': True}).create( - {'name': name, - 'password': 'demo', - 'login': name, - 'email': '@'.join([name, '@test.com']), - 'groups_id': [(6, 0, group_ids)], - 'company_ids': [(6, 0, company_ids)] - }) + return ( + self.env["res.users"] + .with_context({"no_reset_password": True}) + .create( + { + "name": name, + "password": "demo", + "login": name, + "email": "@".join([name, "@test.com"]), + "groups_id": [(6, 0, group_ids)], + "company_ids": [(6, 0, company_ids)], + } + ) + ) def _create_product(self, default_code, name, company_id): - return self.env['product.product'].create({ - 'name': name, - 'default_code': default_code, - 'uom_id': self.env.ref('uom.product_uom_unit').id, - 'company_id': company_id, - 'type': 'product', - 'route_ids': [(6, 0, self.route_buy.ids)], - 'seller_ids': [(0, 0, {'name': self.supplier.id, 'delay': 5})] - }) + return self.env["product.product"].create( + { + "name": name, + "default_code": default_code, + "uom_id": self.env.ref("uom.product_uom_unit").id, + "company_id": company_id, + "type": "product", + "route_ids": [(6, 0, self.route_buy.ids)], + "seller_ids": [(0, 0, {"name": self.supplier.id, "delay": 5})], + } + ) def test_create_request_01(self): """Single Stock request with buy rule""" expected_date = fields.Datetime.now() vals = { - 'company_id': self.main_company.id, - 'warehouse_id': self.warehouse.id, - 'location_id': self.warehouse.lot_stock_id.id, - 'expected_date': expected_date, - 'stock_request_ids': [(0, 0, { - 'product_id': self.product.id, - 'product_uom_id': self.product.uom_id.id, - 'product_uom_qty': 5.0, - 'company_id': self.main_company.id, - 'warehouse_id': self.warehouse.id, - 'location_id': self.warehouse.lot_stock_id.id, - 'expected_date': expected_date, - })] + "company_id": self.main_company.id, + "warehouse_id": self.warehouse.id, + "location_id": self.warehouse.lot_stock_id.id, + "expected_date": expected_date, + "stock_request_ids": [ + ( + 0, + 0, + { + "product_id": self.product.id, + "product_uom_id": self.product.uom_id.id, + "product_uom_qty": 5.0, + "company_id": self.main_company.id, + "warehouse_id": self.warehouse.id, + "location_id": self.warehouse.lot_stock_id.id, + "expected_date": expected_date, + }, + ) + ], } - order = self.env['stock.request.order'].sudo( - self.stock_request_user).create(vals) + order = ( + self.env["stock.request.order"].sudo(self.stock_request_user).create(vals) + ) order.action_confirm() - self.assertEqual(order.state, 'open') - self.assertEqual(order.stock_request_ids.state, 'open') + self.assertEqual(order.state, "open") + self.assertEqual(order.stock_request_ids.state, "open") order.refresh() @@ -109,8 +127,7 @@ class TestStockRequestPurchase(common.TransactionCase): self.assertEqual(order.stock_request_ids.qty_in_progress, 0.0) purchase = order.sudo().purchase_ids[0] - self.assertEqual(purchase.company_id, - order.stock_request_ids[0].company_id) + self.assertEqual(purchase.company_id, order.stock_request_ids[0].company_id) purchase.button_confirm() picking = purchase.picking_ids[0] picking.action_confirm() @@ -124,35 +141,38 @@ class TestStockRequestPurchase(common.TransactionCase): picking.action_done() self.assertEqual(order.stock_request_ids.qty_in_progress, 0.0) - self.assertEqual(order.stock_request_ids.qty_done, - order.stock_request_ids.product_uom_qty) - self.assertEqual(order.stock_request_ids.state, 'done') - self.assertEqual(order.state, 'done') + self.assertEqual( + order.stock_request_ids.qty_done, order.stock_request_ids.product_uom_qty + ) + self.assertEqual(order.stock_request_ids.state, "done") + self.assertEqual(order.state, "done") def test_create_request_02(self): """Multiple Stock requests with buy rule""" vals = { - 'product_id': self.product.id, - 'product_uom_id': self.product.uom_id.id, - 'product_uom_qty': 5.0, - 'company_id': self.main_company.id, - 'warehouse_id': self.warehouse.id, - 'location_id': self.warehouse.lot_stock_id.id, + "product_id": self.product.id, + "product_uom_id": self.product.uom_id.id, + "product_uom_qty": 5.0, + "company_id": self.main_company.id, + "warehouse_id": self.warehouse.id, + "location_id": self.warehouse.lot_stock_id.id, } - stock_request_1 = self.stock_request.sudo( - self.stock_request_user).create(vals) - stock_request_2 = self.stock_request.sudo( - self.stock_request_manager).create(vals) + stock_request_1 = self.stock_request.sudo(self.stock_request_user).create(vals) + stock_request_2 = self.stock_request.sudo(self.stock_request_manager).create( + vals + ) stock_request_1.action_confirm() - self.assertEqual(sum(stock_request_1.sudo().purchase_line_ids.mapped( - 'product_qty')), 5) + self.assertEqual( + sum(stock_request_1.sudo().purchase_line_ids.mapped("product_qty")), 5 + ) stock_request_2.action_confirm() - self.assertEqual(sum(stock_request_2.sudo().purchase_line_ids.mapped( - 'product_qty')), 10) + self.assertEqual( + sum(stock_request_2.sudo().purchase_line_ids.mapped("product_qty")), 10 + ) stock_request_1.refresh() stock_request_2.refresh() @@ -161,10 +181,13 @@ class TestStockRequestPurchase(common.TransactionCase): self.assertEqual(len(stock_request_2.sudo().purchase_ids), 1) self.assertEqual(len(stock_request_1.sudo().purchase_ids), 1) self.assertEqual(len(stock_request_2.sudo().purchase_line_ids), 1) - self.assertEqual(stock_request_1.sudo().purchase_ids, - stock_request_2.sudo().purchase_ids) - self.assertEqual(stock_request_1.sudo().purchase_line_ids, - stock_request_2.sudo().purchase_line_ids) + self.assertEqual( + stock_request_1.sudo().purchase_ids, stock_request_2.sudo().purchase_ids + ) + self.assertEqual( + stock_request_1.sudo().purchase_line_ids, + stock_request_2.sudo().purchase_line_ids, + ) purchase = stock_request_1.sudo().purchase_ids[0] @@ -183,32 +206,36 @@ class TestStockRequestPurchase(common.TransactionCase): picking.action_done() self.assertEqual(stock_request_1.qty_in_progress, 0.0) - self.assertEqual(stock_request_1.qty_done, - stock_request_1.product_uom_qty) + self.assertEqual(stock_request_1.qty_done, stock_request_1.product_uom_qty) self.assertEqual(stock_request_2.qty_in_progress, 0.0) - self.assertEqual(stock_request_2.qty_done, - stock_request_2.product_uom_qty) + self.assertEqual(stock_request_2.qty_done, stock_request_2.product_uom_qty) def test_view_actions(self): expected_date = fields.Datetime.now() vals = { - 'company_id': self.main_company.id, - 'warehouse_id': self.warehouse.id, - 'location_id': self.warehouse.lot_stock_id.id, - 'expected_date': expected_date, - 'stock_request_ids': [(0, 0, { - 'product_id': self.product.id, - 'product_uom_id': self.product.uom_id.id, - 'product_uom_qty': 5.0, - 'company_id': self.main_company.id, - 'warehouse_id': self.warehouse.id, - 'location_id': self.warehouse.lot_stock_id.id, - 'expected_date': expected_date, - })] + "company_id": self.main_company.id, + "warehouse_id": self.warehouse.id, + "location_id": self.warehouse.lot_stock_id.id, + "expected_date": expected_date, + "stock_request_ids": [ + ( + 0, + 0, + { + "product_id": self.product.id, + "product_uom_id": self.product.uom_id.id, + "product_uom_qty": 5.0, + "company_id": self.main_company.id, + "warehouse_id": self.warehouse.id, + "location_id": self.warehouse.lot_stock_id.id, + "expected_date": expected_date, + }, + ) + ], } - order = self.env['stock.request.order'].sudo().create(vals) + order = self.env["stock.request.order"].sudo().create(vals) order.action_confirm() @@ -216,17 +243,16 @@ class TestStockRequestPurchase(common.TransactionCase): action = stock_request.action_view_purchase() - self.assertEqual(action['domain'], '[]') - self.assertEqual('views' in action.keys(), True) - self.assertEqual(action['res_id'], - stock_request.purchase_ids[0].id) + self.assertEqual(action["domain"], "[]") + self.assertEqual("views" in action.keys(), True) + self.assertEqual(action["res_id"], stock_request.purchase_ids[0].id) action = stock_request.purchase_ids[0].action_view_stock_request() - self.assertEqual(action['type'], 'ir.actions.act_window') - self.assertEqual(action['res_id'], stock_request.id) + self.assertEqual(action["type"], "ir.actions.act_window") + self.assertEqual(action["res_id"], stock_request.id) action = order.action_view_purchase() - self.assertEqual(action['domain'], '[]') - self.assertEqual('views' in action.keys(), True) - self.assertEqual(action['res_id'], order.purchase_ids[0].id) + self.assertEqual(action["domain"], "[]") + self.assertEqual("views" in action.keys(), True) + self.assertEqual(action["res_id"], order.purchase_ids[0].id)