I'm trying to fill customer and order_line information in the order view, Odoo always creates a new record. I simply want to fill it out so it can be edited by the user before creating record. please help me.
Below is my code.
from odoo import fields, models, apiclass SaleOrder(models.Model):
_inherit = 'sale.order'
shopee_id = fields.Char(string='Shopee Id')
def test_button_function(self):
dump_name = "Contacts_name_test_FULL" # in feature, it get from api
val = self.env['res.partner'].search_read([('name', '=ilike', dump_name)])
for record in self:
record.partner_id = val[0]['id']
self.onchange_partner_id()
dump_id = 1 # in feature, it can be replace by search by name get from api
order_line_item = self.env['sale.order.line'].browse([dump_id])
record.order_line = order_line_item
No way bro!
instead of doing it using button, try via onchange