[FIX] stock: assign partner

- Create a SO with a stockable product, validate
- On the corresponding picking, change the partner
- Print the 'Picking Operations' or 'Delivery Slip'

The partner printed is the partner of the SO, not of the picking.

This was reported many times in the past, and is quite confusing. It
happens because the partner on the `stock.move` remains the partner set
on the SO.

We shouldn't change the reports, nor automatically propagate the change
since it might cause issues, e.g. in case on dropshipping or manual
creation of the picking.

Therefore, we add an action which allows to set the partner on the stock
move manually.

opw-1917851

closes odoo/odoo#29939
This commit is contained in:
Nicolas Martinelli
2019-01-08 13:41:07 +00:00
parent c07b7200b2
commit 3929e419ff
3 changed files with 17 additions and 0 deletions
+10
View File
@@ -716,6 +716,16 @@ msgstr ""
msgid "Assign Owner"
msgstr ""
#. module: stock
#: model:ir.ui.view,arch_db:stock.view_picking_form
msgid "Assign Partner"
msgstr ""
#. module: stock
#: model:ir.ui.view,arch_db:stock.view_picking_form
msgid "Assign the partner to the Operations. Use only if the partner is manually changed!"
msgstr ""
#. module: stock
#: model:ir.ui.view,arch_db:stock.view_picking_internal_search
msgid "Assigned Moves"
+4
View File
@@ -547,6 +547,10 @@ class Picking(models.Model):
def action_assign_owner(self):
self.move_line_ids.write({'owner_id': self.owner_id.id})
def action_assign_partner(self):
for picking in self:
picking.move_lines.write({'partner_id': picking.partner_id.id})
@api.multi
def do_print_picking(self):
self.write({'printed': True})
@@ -242,6 +242,9 @@
<group>
<group>
<field name="partner_id" attrs="{'invisible': [('picking_type_code', '=', 'internal')]}"/>
<button name="action_assign_partner" string="Assign Partner" type="object" help="Assign the partner to the Operations. Use only if the partner is manually changed!"
attrs="{'invisible': ['|', '|', ('move_line_exist', '=', False), ('state', 'not in', ('draft', 'assigned', 'confirmed')), ('picking_type_code', '=', 'internal')]}"
class="oe_link oe_edit_only"/>
<field name="location_id" groups="stock.group_stock_multi_locations" attrs="{'invisible': [('picking_type_code', '=', 'incoming')]}"/>
<field name="location_dest_id" groups="stock.group_stock_multi_locations" attrs="{'invisible': [('picking_type_code', '=', 'outgoing')]}"/>
<field name="backorder_id" readonly="1" attrs="{'invisible': [('backorder_id','=',False)]}"/>