flectra/addons/stock_dropshipping/models/purchase.py
2018-01-16 02:34:37 -08:00

29 lines
923 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
from flectra import api, models, fields
class PurchaseOrderLine(models.Model):
_inherit = "purchase.order.line"
sale_line_id = fields.Many2one('sale.order.line')
@api.multi
def _prepare_stock_moves(self, picking):
res = super(PurchaseOrderLine, self)._prepare_stock_moves(picking)
for re in res:
re['sale_line_id'] = self.sale_line_id.id
return res
class ProcurementRule(models.Model):
_inherit = 'procurement.rule'
@api.model
def _prepare_purchase_order_line(self, product_id, product_qty, product_uom, values, po, supplier):
res = super(ProcurementRule, self)._prepare_purchase_order_line(product_id, product_qty, product_uom, values, po, supplier)
res['sale_line_id'] = values.get('sale_line_id', False)
return res