-
-
Notifications
You must be signed in to change notification settings - Fork 649
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] stock_picking_operation_quick_change: black, isort
- Loading branch information
1 parent
0f041b6
commit 7d9a32b
Showing
7 changed files
with
192 additions
and
164 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/stock_picking_operation_quick_change/odoo/addons/stock_picking_operation_quick_change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../stock_picking_operation_quick_change |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
201 changes: 106 additions & 95 deletions
201
stock_picking_operation_quick_change/tests/test_stock_picking_operation_quick_change.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,136 +1,147 @@ | ||
# © 2017 Sergio Teruel <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.tests.common import TransactionCase | ||
from odoo.exceptions import UserError | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestOperationQuickChange(TransactionCase): | ||
|
||
def setUp(self): | ||
super(TestOperationQuickChange, self).setUp() | ||
self.Location = self.env['stock.location'] | ||
self.PickingType = self.env['stock.picking.type'] | ||
self.Picking = self.env['stock.picking'] | ||
self.Product = self.env['product.template'] | ||
self.Wizard = self.env['stock.picking.operation.wizard'] | ||
self.warehouse = self.env['stock.warehouse'].create({ | ||
'name': 'warehouse - test', | ||
'code': 'WH-TEST', | ||
}) | ||
self.Location = self.env["stock.location"] | ||
self.PickingType = self.env["stock.picking.type"] | ||
self.Picking = self.env["stock.picking"] | ||
self.Product = self.env["product.template"] | ||
self.Wizard = self.env["stock.picking.operation.wizard"] | ||
self.warehouse = self.env["stock.warehouse"].create( | ||
{"name": "warehouse - test", "code": "WH-TEST",} | ||
) | ||
|
||
# self.warehouse.lot_stock_id.id | ||
self.product = self.Product.create({ | ||
'name': 'Product - Test', | ||
'type': 'product', | ||
'list_price': 100.00, | ||
'standard_price': 100.00, | ||
}) | ||
self.product = self.Product.create( | ||
{ | ||
"name": "Product - Test", | ||
"type": "product", | ||
"list_price": 100.00, | ||
"standard_price": 100.00, | ||
} | ||
) | ||
self.qty_on_hand(self.product.product_variant_ids[:1]) | ||
self.product2 = self.Product.create({ | ||
'name': 'Product2 - Test', | ||
'type': 'product', | ||
'list_price': 100.00, | ||
'standard_price': 100.00, | ||
}) | ||
self.product2 = self.Product.create( | ||
{ | ||
"name": "Product2 - Test", | ||
"type": "product", | ||
"list_price": 100.00, | ||
"standard_price": 100.00, | ||
} | ||
) | ||
self.qty_on_hand(self.product2.product_variant_ids[:1]) | ||
self.customer = self.env['res.partner'].create({ | ||
'name': 'Customer - test', | ||
'customer': True, | ||
}) | ||
self.picking_type = self.PickingType.search([ | ||
('warehouse_id', '=', self.warehouse.id), | ||
('code', '=', 'outgoing'), | ||
]) | ||
self.picking = self.Picking.create({ | ||
'name': 'picking - test 01', | ||
'location_id': self.warehouse.lot_stock_id.id, | ||
'location_dest_id': self.warehouse.wh_output_stock_loc_id.id, | ||
'picking_type_id': self.picking_type.id, | ||
'move_lines': [(0, 0, { | ||
'name': self.product.name, | ||
'product_id': self.product.product_variant_ids[:1].id, | ||
'product_uom_qty': 20.0, | ||
'product_uom': self.product.uom_id.id, | ||
}), (0, 0, { | ||
'name': self.product.name, | ||
'product_id': self.product2.product_variant_ids[:1].id, | ||
'product_uom_qty': 60.0, | ||
'product_uom': self.product.uom_id.id, | ||
})] | ||
}) | ||
self.customer = self.env["res.partner"].create( | ||
{"name": "Customer - test", "customer": True,} | ||
) | ||
self.picking_type = self.PickingType.search( | ||
[("warehouse_id", "=", self.warehouse.id), ("code", "=", "outgoing"),] | ||
) | ||
self.picking = self.Picking.create( | ||
{ | ||
"name": "picking - test 01", | ||
"location_id": self.warehouse.lot_stock_id.id, | ||
"location_dest_id": self.warehouse.wh_output_stock_loc_id.id, | ||
"picking_type_id": self.picking_type.id, | ||
"move_lines": [ | ||
( | ||
0, | ||
0, | ||
{ | ||
"name": self.product.name, | ||
"product_id": self.product.product_variant_ids[:1].id, | ||
"product_uom_qty": 20.0, | ||
"product_uom": self.product.uom_id.id, | ||
}, | ||
), | ||
( | ||
0, | ||
0, | ||
{ | ||
"name": self.product.name, | ||
"product_id": self.product2.product_variant_ids[:1].id, | ||
"product_uom_qty": 60.0, | ||
"product_uom": self.product.uom_id.id, | ||
}, | ||
), | ||
], | ||
} | ||
) | ||
|
||
def qty_on_hand(self, product): | ||
stock_change_obj = self.env['stock.change.product.qty'] | ||
stock_change_obj = self.env["stock.change.product.qty"] | ||
vals = { | ||
'product_id': product.id, | ||
'new_quantity': 200.0, | ||
'location_id': self.warehouse.lot_stock_id.id, | ||
"product_id": product.id, | ||
"new_quantity": 200.0, | ||
"location_id": self.warehouse.lot_stock_id.id, | ||
} | ||
wiz = stock_change_obj.create(vals) | ||
wiz.change_product_qty() | ||
|
||
def test_picking_operation_change_location_dest_all(self): | ||
self.picking.action_assign() | ||
new_location_dest_id = self.Location.create({ | ||
'name': 'New Test Customer Location', | ||
'location_id': self.picking.location_dest_id.location_id.id | ||
}) | ||
new_location_dest_id = self.Location.create( | ||
{ | ||
"name": "New Test Customer Location", | ||
"location_id": self.picking.location_dest_id.location_id.id, | ||
} | ||
) | ||
wiz = self.Wizard.with_context( | ||
active_model=self.picking._name, | ||
active_ids=self.picking.ids, | ||
).create({ | ||
'new_location_dest_id': new_location_dest_id.id, | ||
'change_all': True, | ||
}) | ||
move_lines = self.picking.mapped('move_line_ids') | ||
active_model=self.picking._name, active_ids=self.picking.ids, | ||
).create({"new_location_dest_id": new_location_dest_id.id, "change_all": True,}) | ||
move_lines = self.picking.mapped("move_line_ids") | ||
self.assertEqual(wiz.location_dest_id, self.picking.location_dest_id) | ||
self.assertEqual(wiz.old_location_dest_id, | ||
move_lines[:1].location_dest_id) | ||
self.assertEqual(wiz.old_location_dest_id, move_lines[:1].location_dest_id) | ||
wiz.action_apply() | ||
move_lines = self.picking.mapped( | ||
'move_line_ids.location_dest_id') | ||
move_lines = self.picking.mapped("move_line_ids.location_dest_id") | ||
self.assertEqual(len(move_lines), 1) | ||
|
||
def test_picking_operation_change_location_dest(self): | ||
new_location_dest_id = self.Location.create({ | ||
'name': 'New Test Customer Location', | ||
'location_id': self.picking.location_dest_id.location_id.id | ||
}) | ||
other_location_dest_id = self.Location.create({ | ||
'name': 'New Test Customer Location', | ||
'location_id': self.picking.location_dest_id.location_id.id | ||
}) | ||
new_location_dest_id = self.Location.create( | ||
{ | ||
"name": "New Test Customer Location", | ||
"location_id": self.picking.location_dest_id.location_id.id, | ||
} | ||
) | ||
other_location_dest_id = self.Location.create( | ||
{ | ||
"name": "New Test Customer Location", | ||
"location_id": self.picking.location_dest_id.location_id.id, | ||
} | ||
) | ||
self.picking.action_assign() | ||
move_lines = self.picking.mapped('move_line_ids') | ||
move_lines[:1].write({'location_dest_id': other_location_dest_id.id}) | ||
move_lines = self.picking.mapped("move_line_ids") | ||
move_lines[:1].write({"location_dest_id": other_location_dest_id.id}) | ||
wiz = self.Wizard.with_context( | ||
active_model=self.picking._name, | ||
active_ids=self.picking.ids, | ||
).create({ | ||
'old_location_dest_id': self.picking.location_dest_id.id, | ||
'new_location_dest_id': new_location_dest_id.id, | ||
}) | ||
active_model=self.picking._name, active_ids=self.picking.ids, | ||
).create( | ||
{ | ||
"old_location_dest_id": self.picking.location_dest_id.id, | ||
"new_location_dest_id": new_location_dest_id.id, | ||
} | ||
) | ||
wiz.action_apply() | ||
move_lines = self.picking.mapped( | ||
'move_line_ids.location_dest_id') | ||
move_lines = self.picking.mapped("move_line_ids.location_dest_id") | ||
self.assertEqual(len(move_lines), 2) | ||
|
||
def test_picking_operation_change_location_dest_failed(self): | ||
self.picking.action_assign() | ||
for move in self.picking.move_lines: | ||
move.quantity_done = 1 | ||
self.picking.action_done() | ||
new_location_dest_id = self.Location.create({ | ||
'name': 'New Test Customer Location', | ||
'location_id': self.picking.location_dest_id.location_id.id | ||
}) | ||
new_location_dest_id = self.Location.create( | ||
{ | ||
"name": "New Test Customer Location", | ||
"location_id": self.picking.location_dest_id.location_id.id, | ||
} | ||
) | ||
wiz = self.Wizard.with_context( | ||
active_model=self.picking._name, | ||
active_ids=self.picking.ids, | ||
).create({ | ||
'new_location_dest_id': new_location_dest_id.id, | ||
'change_all': True, | ||
}) | ||
active_model=self.picking._name, active_ids=self.picking.ids, | ||
).create({"new_location_dest_id": new_location_dest_id.id, "change_all": True,}) | ||
with self.assertRaises(UserError): | ||
wiz.action_apply() |
16 changes: 8 additions & 8 deletions
16
stock_picking_operation_quick_change/views/stock_picking_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2017 Sergio Teruel <[email protected]> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
|
||
<record id="view_picking_form" model="ir.ui.view"> | ||
<field name="model">stock.picking</field> | ||
<field name="inherit_id" ref="stock.view_picking_form"/> | ||
<field name="inherit_id" ref="stock.view_picking_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='move_ids_without_package']" position="before"> | ||
<button name="%(action_stock_picking_operation_change_location)d" | ||
type="action" | ||
string="Change Location" | ||
groups="stock.group_stock_user"> | ||
<button | ||
name="%(action_stock_picking_operation_change_location)d" | ||
type="action" | ||
string="Change Location" | ||
groups="stock.group_stock_user" | ||
> | ||
</button> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
Oops, something went wrong.