采购单关联产品
This commit is contained in:
@@ -31,3 +31,13 @@ class PurchaseOrder(models.Model):
|
|||||||
class PurchaseOrderLine(models.Model):
|
class PurchaseOrderLine(models.Model):
|
||||||
_inherit = 'purchase.order.line'
|
_inherit = 'purchase.order.line'
|
||||||
part_number = fields.Char('零件图号', related='product_id.part_number', readonly=True)
|
part_number = fields.Char('零件图号', related='product_id.part_number', readonly=True)
|
||||||
|
related_product = fields.Many2one('product.product',compute='_compute_related_product', string='关联产品',help='经此产品工艺加工成的成品')
|
||||||
|
@api.depends('order_id.origin')
|
||||||
|
def _compute_related_product(self):
|
||||||
|
for record in self:
|
||||||
|
if record.product_id.detailed_type:
|
||||||
|
production_id = self.env['mrp.production'].search([('name', '=', record.order_id.origin)])
|
||||||
|
record.related_product = production_id.product_id if production_id else False
|
||||||
|
else:
|
||||||
|
record.related_product = False
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
<field name="inherit_id" ref="purchase.purchase_order_form"/>
|
<field name="inherit_id" ref="purchase.purchase_order_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="after">
|
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="after">
|
||||||
|
<field name="related_product" optional="show"/>
|
||||||
<field name="part_number" optional="show"/>
|
<field name="part_number" optional="show"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
Reference in New Issue
Block a user