[REF] stock: default warehouse

In a bunch of places, a default warehouse is selected to make an operation:
- default warehouse on a sale order
- default location of an unbuild order
- default location of an inventory adjustment

Before this commit, the warehouse that was created first was always selected.
Now, we introduce a sequence field and a widget handle so that the user can
chose the default one as he wishes.

Task- 2001671

closes odoo/odoo#34085

Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
This commit is contained in:
Jinal Patel
2019-06-25 04:48:43 +00:00
parent 3520220268
commit faf67303b3
2 changed files with 4 additions and 0 deletions
+3
View File
@@ -19,6 +19,7 @@ _logger = logging.getLogger(__name__)
class Warehouse(models.Model):
_name = "stock.warehouse"
_description = "Warehouse"
_order = 'sequence,id'
# namedtuple used in helper methods generating values for routes
Routing = namedtuple('Routing', ['from_loc', 'dest_loc', 'picking_type', 'action'])
@@ -69,6 +70,8 @@ class Warehouse(models.Model):
'stock.location.route', 'supplied_wh_id', 'Resupply Routes',
help="Routes will be created for these resupply warehouses and you can select them on products and product categories")
show_resupply = fields.Boolean(compute="_compute_show_resupply")
sequence = fields.Integer(default=10,
help="Gives the sequence of this line when displaying the warehouses.")
_sql_constraints = [
('warehouse_name_uniq', 'unique(name, company_id)', 'The name of the warehouse must be unique per company!'),
('warehouse_code_uniq', 'unique(code, company_id)', 'The code of the warehouse must be unique per company!'),
@@ -82,6 +82,7 @@
<field name="model">stock.warehouse</field>
<field name="arch" type="xml">
<tree string="Warehouse" create="false">
<field name="sequence" widget="handle"/>
<field name="name"/>
<field name="active" invisible="1"/>
<field name="lot_stock_id" groups="stock.group_stock_multi_locations"/>