Skip to Content
Menu
This question has been flagged
3641 Views

hi all,

I have activated track serial number option and purchased a product by adding a serial number to that products.

Now i sold one product to a customer. I can see all the details of a particular product in stock.move like product name, source location, destination location etc. 

But i cant see much information in stock.production.lot(Serial Number/Lots) menu. There we can see only Serial Number, product and One2many table stock.quant. 

My requirement is: When i sale the particular Product to a Customer. His name should be printed with that product name in stock.production.lot(Serial Number/Lots). How can we get that name from sale.order to stock.production.lot

I tried below code.

.py

class WMSStockProductionLot(models.Model):
_inherit = "stock.production.lot"
_description = "WMS Stock Production Lot is used too call customer name"
@api.one
def get_customer(self):
res = self.env['stock.move'].search([], limit=[])
_logger.info("asdadasdasd %s",res)
for a in res:
self.partner_id=a.partner_id.id
return res
partner_id = fields.Many2one('res.partner',compute="get_customer", string='Customer')

.xml

<record id="view_stock_production_form_inherite" model="ir.ui.view">
<field name="name">Stock Production Lot</field>
<field name="model">stock.production.lot</field>
<field name="inherit_id" ref="stock.view_production_lot_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='ref']" position="after">
<field name="partner_id"/>
</xpath>
</field>
</record>

i am getting customer name but it will be written for all the products in (Serial Number/Lots)

Avatar
Discard