2018-01-16 06:58:15 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2018-01-16 11:34:37 +01:00
|
|
|
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
|
2018-01-16 06:58:15 +01:00
|
|
|
|
2018-01-16 11:34:37 +01:00
|
|
|
from flectra import api, models, fields
|
2018-01-16 06:58:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|