'problem whit the new orm method AttributeError: 'sale.order.line' object has no attribute 'get' odoo

i want to add lines to the order_line from other sale order but it giveme an error AttributeError: 'sale.order.line' object has no attribute 'get' odoo

my code below

from odoo import fields, models, api

class InvoiceOrder(models.Model):
    _inherit = "sale.order"

    container_id=fields.Many2one(comodel_name="container.shipment",string="Container")

    @api.onchange("container_id")
    def _onchange_lines_conatiner(self):

        

        if self.container_id != None:

            container=self.env["container.shipment"].search(
                [
                    ("name", "=", self.container_id.name),                      
                ], limit=1
            )
            order_line_def= self.order_line
            
            dict_order={}
            vals=[]
            
            for bulk in container.bulk_ids:
                for order in bulk.line_ids:
                    order_id=order.order_id
                    order_line1=order_id.order_line
                    
                    order_line_def= order_line1 + order_line_def
                    for record in order_line_def:
                        dict_order.update({
                                'product_id': record.product_id.id,
                                'name': record.name,
                                'product_uom_qty':record.product_uom_qty,
                                'product_uom': record.product_uom,
                                'price_unit': record.price_unit,
                                'order_id': self.id,
                                
                            })
                        vals.append(dict_order)

                        for line1 in vals:
                            order1 = self.env['sale.order.line'].new(line1)
                
                            return order1


Solution 1:[1]

Odoo expects the onchange method to return a dictionary

The odoo documentation says that the method may return a dictionary for changing field domains and pop up a warning message, like in the old API:

return {
    'domain': {'other_id': [('partner_id', '=', partner_id)]},
    'warning': {'title': "Warning", 'message': "What is this?"},
}

To fix that error, do not return a sale.order.line record

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kenly