[IMP] stock: default sequence for picking types

This commit is contained in:
Arnaud Baes
2019-08-14 12:27:04 +00:00
parent 9410e0ce00
commit 062ad598bf
8 changed files with 51 additions and 6 deletions
+6 -3
View File
@@ -205,7 +205,8 @@ class StockWarehouse(models.Model):
'use_existing_lots': True,
'default_location_src_id': self.lot_stock_id.id,
'default_location_dest_id': self.pbm_loc_id.id,
'sequence': next_sequence + 1
'sequence': next_sequence + 1,
'sequence_code': 'PC',
},
'sam_type_id': {
'name': _('Store Finished Product'),
@@ -214,14 +215,16 @@ class StockWarehouse(models.Model):
'use_existing_lots': True,
'default_location_src_id': self.sam_loc_id.id,
'default_location_dest_id': self.lot_stock_id.id,
'sequence': next_sequence + 3
'sequence': next_sequence + 3,
'sequence_code': 'SFP',
},
'manu_type_id': {
'name': _('Manufacturing'),
'code': 'mrp_operation',
'use_create_lots': True,
'use_existing_lots': True,
'sequence': next_sequence + 2
'sequence': next_sequence + 2,
'sequence_code': 'MO',
},
})
return data, max_sequence + 4
+1
View File
@@ -68,6 +68,7 @@ class TestBoM(TestMrpCommon):
tmp_picking_type = self.env['stock.picking.type'].create({
'name': 'Manufacturing',
'code': 'mrp_operation',
'sequence_code': 'TMP',
'sequence_id': self.env['ir.sequence'].create({
'code': 'mrp.production',
'name': 'tmp_production_sequence',
@@ -109,7 +109,8 @@ class StockWarehouse(models.Model):
'code': 'mrp_operation',
'use_create_lots': True,
'use_existing_lots': True,
'sequence': next_sequence + 2
'sequence': next_sequence + 2,
'sequence_code': 'SBC',
},
})
return data, max_sequence + 4
@@ -36,6 +36,7 @@ class Warehouse(models.Model):
'default_location_src_id': self.lot_stock_id.id,
'default_location_dest_id': self.env.ref('stock.stock_location_customers').id,
'sequence': max_sequence + 1,
'sequence_code': 'POS',
}
})
return picking_type_create_values, max_sequence + 2
+30 -1
View File
@@ -28,7 +28,8 @@ class PickingType(models.Model):
name = fields.Char('Operation Type', required=True, translate=True)
color = fields.Integer('Color')
sequence = fields.Integer('Sequence', help="Used to order the 'All Operations' kanban view")
sequence_id = fields.Many2one('ir.sequence', 'Reference Sequence', required=True)
sequence_id = fields.Many2one('ir.sequence', 'Reference Sequence')
sequence_code = fields.Char('Code', required=True)
default_location_src_id = fields.Many2one(
'stock.location', 'Default Source Location',
help="This is the default source location when you create a picking manually with this operation type. It is possible however to change it or that the routes put another location. If it is empty, it will check for the supplier location on the partner. ")
@@ -68,6 +69,34 @@ class PickingType(models.Model):
barcode = fields.Char('Barcode', copy=False)
company_id = fields.Many2one('res.company', 'Company', related='warehouse_id.company_id', store=True)
@api.model
def create(self, vals):
if 'sequence_id' not in vals or not vals['sequence_id']:
if vals['warehouse_id']:
wh = self.env['stock.warehouse'].browse(vals['warehouse_id'])
vals['sequence_id'] = self.env['ir.sequence'].create({
'name': wh.name + ' ' + _('Sequence') + ' ' + vals['sequence_code'],
'prefix': wh.code + '/' + vals['sequence_code'] + '/', 'padding': 5,
'company_id': wh.company_id.id,
}).id
else:
vals['sequence_id'] = self.env['ir.sequence'].create({
'name': _('Sequence') + ' ' + vals['sequence_code'],
'prefix': vals['sequence_code'], 'padding': 5,
'company_id': self.env.company.id,
}).id
picking_type = super(PickingType, self).create(vals)
return picking_type
@api.onchange('sequence_code')
def _onchange_sequence_code(self):
if self.sequence_id:
if self.warehouse_id:
self.sequence_id.prefix = self.warehouse_id.code + '/' + self.sequence_code
else:
self.sequence_id.prefix = self.sequence_code
def _compute_picking_count(self):
# TDE TODO count picking can be done using previous two
domains = {
+5
View File
@@ -824,6 +824,7 @@ class Warehouse(models.Model):
'sequence': max_sequence + 1,
'barcode': self.code.replace(" ", "").upper() + "-RECEIPTS",
'show_reserved': False,
'sequence_code': 'IN',
}, 'out_type_id': {
'name': _('Delivery Orders'),
'code': 'outgoing',
@@ -832,6 +833,7 @@ class Warehouse(models.Model):
'default_location_dest_id': False,
'sequence': max_sequence + 5,
'barcode': self.code.replace(" ", "").upper() + "-DELIVERY",
'sequence_code': 'OUT',
}, 'pack_type_id': {
'name': _('Pack'),
'code': 'internal',
@@ -841,6 +843,7 @@ class Warehouse(models.Model):
'default_location_dest_id': output_loc.id,
'sequence': max_sequence + 4,
'barcode': self.code.replace(" ", "").upper() + "-PACK",
'sequence_code': 'PACK',
}, 'pick_type_id': {
'name': _('Pick'),
'code': 'internal',
@@ -849,6 +852,7 @@ class Warehouse(models.Model):
'default_location_src_id': self.lot_stock_id.id,
'sequence': max_sequence + 3,
'barcode': self.code.replace(" ", "").upper() + "-PICK",
'sequence_code': 'PICK',
}, 'int_type_id': {
'name': _('Internal Transfers'),
'code': 'internal',
@@ -859,6 +863,7 @@ class Warehouse(models.Model):
'active': self.reception_steps != 'one_step' or self.delivery_steps != 'ship_only' or self.user_has_groups('stock.group_stock_multi_locations'),
'sequence': max_sequence + 2,
'barcode': self.code.replace(" ", "").upper() + "-INTERNAL",
'sequence_code': 'INT',
},
}, max_sequence + 6
+5 -1
View File
@@ -40,7 +40,8 @@
<group>
<field name="active" invisible="1"/>
<field name="name"/>
<field name="sequence_id"/>
<field name="sequence_id" groups="base.group_no_one"/>
<field name="sequence_code"/>
<field name="warehouse_id" groups="stock.group_stock_multi_warehouses"/>
</group>
<group>
@@ -58,6 +59,9 @@
<group attrs='{"invisible": [("code", "not in", ["incoming", "outgoing", "internal"])]}' string="Packages" groups="stock.group_tracking_lot">
<field name="show_entire_packs"/>
</group>
<!-- As this group will be hidden without multi_loccation, you will not be able to create a
picking type with the code 'Internal', which make sense, but as the field 'code' on picking
types can't be partially hidden, you can still select the code internal in the form view -->
<group string="Locations" groups="stock.group_stock_multi_locations">
<field name="default_location_src_id" options="{'no_create': True}" attrs="{'required': [('code', 'in', ('internal', 'outgoing'))]}"/>
<field name="default_location_dest_id" options="{'no_create': True}" attrs="{'required': [('code', 'in', ('internal', 'incoming'))]}"/>
@@ -10,6 +10,7 @@
<record id="picking_type_dropship" model="stock.picking.type">
<field name="name">Dropship</field>
<field name="sequence_code">DS</field>
<field name="sequence_id" ref="seq_picking_type_dropship"/>
<field name="code">incoming</field>
<field name="warehouse_id" eval="False"/>