Skip to content
Permalink
Browse files

[IMP] stock: assign someone to picking

purpose is allow to assign picking to users
- add field responsible on the picking that allows to select a user
- Now we assign responsible to several picking at once
- add default filter 'My Transfers' and 'Unassigned Transfers'

Related task : 1938107
  • Loading branch information...
jip-odoo committed Feb 15, 2019
1 parent 5028507 commit c63211a17ff075965febd1896a22cd1167ac5370
@@ -803,6 +803,7 @@ def create_picking(self):
picking_vals = {
'origin': order.name,
'partner_id': address.get('delivery', False),
'user_id': False,
'date_done': order.date_order,
'picking_type_id': picking_type.id,
'company_id': order.company_id.id,
@@ -187,6 +187,7 @@ def _prepare_picking(self):
return {
'picking_type_id': self.picking_type_id.id,
'partner_id': self.partner_id.id,
'user_id': False,
'date': self.date_order,
'origin': self.name,
'location_dest_id': self._get_destination_location(),
@@ -52,6 +52,7 @@
'wizard/product_replenish_views.xml',
'wizard/stock_track_confirmation_views.xml',
'wizard/stock_package_destination_views.xml',
'wizard/stock_picking_responsible.xml',

'views/res_partner_views.xml',
'views/product_strategy_views.xml',
@@ -69,6 +69,7 @@
<record id="outgoing_shipment_main_warehouse" model="stock.picking">
<field name="picking_type_id" ref="stock.picking_type_out"/>
<field name="origin">outgoing shipment main_warehouse</field>
<field name="user_id"></field>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="date" eval="DateTime.today()"/>
<field name="location_id" ref="stock.stock_location_stock"/>
@@ -87,6 +88,7 @@
<record id="outgoing_shipment_main_warehouse1" model="stock.picking">
<field name="picking_type_id" ref="stock.picking_type_out"/>
<field name="origin">outgoing shipment</field>
<field name="user_id"></field>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="date" eval="DateTime.today() - timedelta(days=15)"/>
<field name="location_id" ref="stock.stock_location_stock"/>
@@ -112,6 +114,7 @@
<record id="outgoing_shipment_main_warehouse2" model="stock.picking">
<field name="picking_type_id" ref="stock.picking_type_out"/>
<field name="origin">outgoing shipment your_company warehouse</field>
<field name="user_id"></field>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="date" eval="DateTime.today() - timedelta(days=5)"/>
<field name="location_id" ref="stock.stock_location_stock"/>
@@ -129,6 +132,7 @@

<record id="outgoing_shipment_main_warehouse3" model="stock.picking">
<field name="picking_type_id" ref="stock.picking_type_out"/>
<field name="user_id"></field>
<field name="origin">your company warehouse</field>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="date" eval="DateTime.today()"/>
@@ -148,6 +152,7 @@
<record id="outgoing_shipment_main_warehouse4" model="stock.picking">
<field name="picking_type_id" ref="stock.picking_type_out"/>
<field name="origin">outgoing shipment</field>
<field name="user_id"></field>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="date" eval="DateTime.today() - timedelta(days=7)"/>
<field name="location_id" ref="stock.stock_location_stock"/>
@@ -173,6 +178,7 @@
<record id="outgoing_shipment_main_warehouse5" model="stock.picking">
<field name="picking_type_id" ref="stock.picking_type_out"/>
<field name="origin">outgoing shipment</field>
<field name="user_id"></field>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="date" eval="DateTime.today() - timedelta(days=12)"/>
<field name="location_id" ref="stock.stock_location_stock"/>
@@ -198,6 +204,7 @@
<record id="outgoing_shipment_main_warehouse6" model="stock.picking">
<field name="picking_type_id" ref="stock.picking_type_out"/>
<field name="origin">outgoing shipment</field>
<field name="user_id"></field>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="date" eval="DateTime.today() - timedelta(days=20)"/>
<field name="location_id" ref="stock.stock_location_stock"/>
@@ -222,6 +229,7 @@

<!-- Create STOCK_PICKING for IN -->
<record id="incomming_shipment" model="stock.picking">
<field name="user_id"></field>
<field name="picking_type_id" ref="stock.picking_type_in"/>
<field name="location_id" ref="stock.stock_location_suppliers"/>
<field name="location_dest_id" ref="stock.stock_location_stock"/>
@@ -237,6 +245,7 @@
</record>

<record id="incomming_shipment1" model="stock.picking">
<field name="user_id"></field>
<field name="picking_type_id" ref="stock.picking_type_in"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="date" eval="DateTime.today() - timedelta(days=5)"/>
@@ -254,6 +263,7 @@
</record>

<record id="incomming_shipment2" model="stock.picking">
<field name="user_id"></field>
<field name="picking_type_id" ref="stock.picking_type_in"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="location_id" ref="stock.stock_location_suppliers"/>
@@ -270,6 +280,7 @@
</record>

<record id="incomming_shipment3" model="stock.picking">
<field name="user_id"></field>
<field name="picking_type_id" ref="stock.picking_type_in"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="location_id" ref="stock.stock_location_suppliers"/>
@@ -286,6 +297,7 @@
</record>

<record id="incomming_shipment4" model="stock.picking">
<field name="user_id"></field>
<field name="picking_type_id" ref="stock.picking_type_in"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="location_id" ref="stock.stock_location_suppliers"/>
@@ -305,6 +317,7 @@
<record id="incomming_chicago_warehouse" model="stock.picking">
<field name="picking_type_id" ref="stock.chi_picking_type_in"/>
<field name="origin">incoming_chicago_warehouse</field>
<field name="user_id"></field>
<field name="date" eval="DateTime.today()"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="location_id" ref="stock.stock_location_suppliers"/>
@@ -321,6 +334,7 @@
</record>

<record id="incomming_chicago_warehouse1" model="stock.picking">
<field name="user_id"></field>
<field name="picking_type_id" ref="stock.chi_picking_type_in"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="date" eval="DateTime.today() - timedelta(days=5)"/>
@@ -345,6 +359,7 @@
</record>

<record id="incomming_chicago_warehouse2" model="stock.picking">
<field name="user_id"></field>
<field name="picking_type_id" ref="stock.chi_picking_type_in"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="location_id" ref="stock.stock_location_suppliers"/>
@@ -361,6 +376,7 @@
</record>

<record id="incomming_chicago_warehouse3" model="stock.picking">
<field name="user_id"></field>
<field name="picking_type_id" ref="stock.chi_picking_type_in"/>
<field name="origin">chicago_warehouse</field>
<field name="partner_id" ref="base.res_partner_1"/>
@@ -381,6 +397,7 @@
<!-- Create STOCK_PICKING_OUT for Chicago Warehouse -->
<record id="outgoing_chicago_warehouse" model="stock.picking">
<field name="picking_type_id" ref="stock.chi_picking_type_out"/>
<field name="user_id"></field>
<field name="origin">outgoing_chicago_warehouse</field>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="date" eval="DateTime.today()"/>
@@ -398,6 +415,7 @@
</record>

<record id="outgoing_chicago_warehouse1" model="stock.picking">
<field name="user_id"></field>
<field name="picking_type_id" ref="stock.chi_picking_type_out"/>
<field name="origin">outgoing_shipment_chicago_warehouse</field>
<field name="partner_id" ref="base.res_partner_1"/>
@@ -423,6 +441,7 @@
</record>

<record id="outgoing_chicago_warehouse2" model="stock.picking">
<field name="user_id"></field>
<field name="picking_type_id" ref="stock.chi_picking_type_out"/>
<field name="origin">chicago_warehouse</field>
<field name="partner_id" ref="base.res_partner_1"/>
@@ -441,6 +460,7 @@
</record>

<record id="outgoing_chicago_warehouse3" model="stock.picking">
<field name="user_id"></field>
<field name="picking_type_id" ref="stock.chi_picking_type_out"/>
<field name="origin">outgoing chicago warehouse</field>
<field name="partner_id" ref="base.res_partner_1"/>
@@ -735,6 +735,7 @@ def _get_new_picking_values(self):
return {
'origin': origin,
'company_id': self.mapped('company_id').id,
'user_id': False,
'move_type': self.mapped('group_id').move_type or 'direct',
'partner_id': partner,
'picking_type_id': self.mapped('picking_type_id').id,
@@ -265,6 +265,10 @@ class Picking(models.Model):
default=lambda self: self.env['res.company']._company_default_get('stock.picking'),
index=True, required=True,
states={'done': [('readonly', True)], 'cancel': [('readonly', True)]})
user_id = fields.Many2one(
'res.users', 'Responsible', tracking=True,
domain=lambda self: [('groups_id', 'in', self.env.ref('stock.group_stock_user').id)],
default=lambda self: self.env.user)

move_line_ids = fields.One2many('stock.move.line', 'picking_id', 'Operations')
move_line_ids_without_package = fields.One2many('stock.move.line', 'picking_id', 'Operations without package', domain=['|',('package_level_id', '=', False), ('picking_type_entire_packs', '=', False)])
@@ -333,6 +333,7 @@
<field name="picking_type_code" invisible="1"/>
<field name="move_type" attrs="{'invisible': [('picking_type_code', '=', 'incoming')]}"/>
<field name="priority"/>
<field name="user_id"/>
<field name="group_id" groups="base.group_no_one"/>
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
</group>
@@ -358,6 +359,9 @@
<field name="arch" type="xml">
<search string="Picking Lists">
<field name="name" string="Picking List" filter_domain="['|',('name','ilike', self),('origin','ilike',self)]"/>
<filter name="my_transfers" string="My Transfers" domain="[('user_id','=',uid)]"/>
<filter name="unassigned_transfers" string="Unassigned Transfers" domain="[('user_id','=',False)]"/>
<separator/>
<filter name="draft" string="Draft" domain="[('state','=','draft')]" help="Draft Moves"/>
<filter name="waiting" string="Waiting" domain="[('state','in', ('confirmed', 'waiting'))]" help="Waiting Moves"/>
<filter name="available" string="Ready" domain="[('state','in',('assigned', 'partially_available'))]" help="Assigned Moves"/>
@@ -394,6 +398,22 @@
</field>
</record>

<!--
'Assign a Responsible' in action dropdown
-->
<record id="action_assign_a_responsible" model="ir.actions.server">
<field name="name">Assign a Responsible</field>
<field name="model_id" ref="model_stock_picking"/>
<field name="binding_model_id" ref="stock.model_stock_picking"/>
<field name="state">code</field>
<field name="code">
if record:
action_values = env.ref('stock.stock_assign_responsible_action').read()[0]
action_values.update({'context': env.context})
action = action_values
</field>
</record>

<record id="action_picking_tree_all" model="ir.actions.act_window">
<field name="name">Transfers</field>
<field name="res_model">stock.picking</field>
@@ -13,3 +13,4 @@
from . import product_replenish
from . import stock_track_confirmation
from . import stock_package_destination
from . import stock_picking_responsible
@@ -0,0 +1,17 @@
from odoo import api, fields, models


class PickingResponsible(models.TransientModel):
_name = 'stock.picking.responsible'
_description = 'Assign Responsible'

user_id = fields.Many2one(
'res.users', 'Responsible',
domain=lambda self: [('groups_id', 'in', self.env.ref('stock.group_stock_user').id)],
default=lambda self: self.env.user)

@api.multi
def assign_responsible(self):
Pickings = self.env['stock.picking'].browse(self.env.context.get('active_ids'))
for picking in Pickings:
picking.user_id = self.user_id
@@ -0,0 +1,31 @@
<odoo>
<record id="view_stock_picking_responsible_form" model="ir.ui.view">
<field name="name">stock.picking.responsible.form</field>
<field name="model">stock.picking.responsible</field>
<field name="arch" type="xml">
<form string="Assign a Responsible">
<group>
<field name="user_id"/>
</group>
<footer>
<button name="assign_responsible"
string="Assign"
type="object"
class="btn-primary"/>
<button string="Cancel"
class="btn-secondary"
special="cancel" />
</footer>
</form>
</field>
</record>

<record id="stock_assign_responsible_action" model="ir.actions.act_window">
<field name="name">Assign a Responsible</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.picking.responsible</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_stock_picking_responsible_form"/>
<field name="target">new</field>
</record>
</odoo>

0 comments on commit c63211a

Please sign in to comment.
You can’t perform that action at this time.