Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
4089 Lượt xem

Ive created some delivery methods which I want to assign to my sale order records. Manually this can be done by clicking on "Add Shipping" button from sale order create view. but How can I do this using ORM? I know I can create a sale record object using record = self.env['sale.order'].create({}). How can I assign a delivery method to it?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

if you have just one shipping method you can create Shipping method in data.xml folder with( noupdate="1") option and then you can use it in your create function like this

data.xml file :

<record id="record_in_xml_id" model="delivery.carrier">

            <field name="name"></field>

            <field name="type"></field>

            all necessary fields 

        </record>


in python file 

shipping_id = self.env.ref('module_name.record_in_xml_id')

sale_order_obj.create({

            all necessary fields 

    'shipping_id' : shipping_id.id
})

Ảnh đại diện
Huỷ bỏ
Tác giả

I don't want to create a shipping method manually. Odoo already has a shipping method and it can be added to the sale order using the 'Add Shipping' button. I want to do this process using odoo ORM and assign a shipping method to an existing sale order object. any ideas?

Câu trả lời hay nhất

Hello, 

Maybe my answer to another question would help?

https://www.odoo.com/forum/help-1/odoov13-how-to-assign-a-delivery-carrier-object-to-a-sale-order-object-using-orm-179786#answer-180349

Wait, you are the same person... Never mind.

Thanks, 

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 24
6161
1
thg 8 21
2259
0
thg 11 20
2210
0
thg 10 20
2620
1
thg 12 22
3291