You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1.1 KiB
26 lines
1.1 KiB
# -*- coding: utf-8 -*-
|
|
from odoo import api, fields, models, _
|
|
|
|
|
|
class PurchaseOrder(models.Model):
|
|
_inherit = "purchase.order"
|
|
|
|
@api.multi
|
|
def _create_picking(self):
|
|
StockPicking = self.env['stock.picking']
|
|
for order in self:
|
|
if any([ptype in ['product', 'consu'] for ptype in order.order_line.mapped('product_id.type')]):
|
|
pickings = order.picking_ids.filtered(lambda x: x.state not in ('done','cancel'))
|
|
if not pickings:
|
|
res = order._prepare_picking()
|
|
picking = StockPicking.create(res)
|
|
else:
|
|
picking = pickings[0]
|
|
moves = order.order_line._create_stock_moves(picking)
|
|
moves = moves.filtered(lambda x: x.state not in ('done', 'cancel')).action_confirm()
|
|
moves.force_assign()
|
|
picking.generate_quality_alert()
|
|
picking.message_post_with_view('mail.message_origin_link',
|
|
values={'self': picking, 'origin': order},
|
|
subtype_id=self.env.ref('mail.mt_note').id)
|
|
return True
|