Skip to Content
Menu
This question has been flagged
2 Replies
3479 Views
from odoo import models, fields, api

class StockMove(models.Model):

@api.multi
    def get_data(self):
        data = self.env['sale.order.line'].search([])
        print("Get Data Function")
        for rec in data:
            print(rec.x_serialnumber)
            for record in self:
                record.x_serialnumber = rec.x_serialnumber

    _inherit = 'stock.move'
    x_serialnumber = fields.Text(string="Serial Number", compute='get_data')"

On Sale order line it shows like this:

Serial Number: in both lines

112233

445566

But in stock move:

Serial Number: in both lines

445566

445566

Avatar
Discard
Best Answer

Dear Aurangzaib,

There is already one field sale_line_id in the model stock.move.

You can get the related sale order line from this field.

Regards


Global Creative Concepts Tech Co Ltd.

Avatar
Discard
Best Answer

Hi,

Try the code below

@api.multi
def get_data(self):
data = self.env['sale.order.line'].search([])
serialnumber = ""
for rec in data:
serialnumber += rec.x_serialnumber
for record in self:
record.x_serialnumber = serialnumber

Regards

Avatar
Discard
Related Posts Replies Views Activity
3
Jul 23
24339
2
Jun 22
4591
1
Nov 20
6784
2
Mar 19
4976
1
Apr 18
3357