跳至内容
菜单
此问题已终结
1582 查看

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, api
class 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