Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
4996 มุมมอง

i want to create a task for each order line after creating sales order, the task title should contain  product name and quantity how can i do this?

i am using odoo online version 13

note that the product type is not service.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello Aseel,

@api.model

    def create(self, vals):

        res = super(SaleOrder, self).create(vals)

        task_obj = self.env['project.task']

        for order_line in res.order_line:

            task_obj.create({

                'name': order_line.product_id.name + '-' + str(order_line.product_uom_qty)

                })

        return res

Regards,




Email:   odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   

อวตาร
ละทิ้ง
ผู้เขียน

can you expain your answer with more details?

sorry but i am abeginner i have followed the procedure assinged in this screenshot but it doesn't work

https://drive.google.com/file/d/17elLvPOibGDmjAOb92VBBls_UfnQi7tL/view?usp=sharing

thanks

คำตอบที่ดีที่สุด

Hope this helps!  Enable Developer Mode and navigate to Settings / Technical / (Automation) / Automated Actions:

Data to Write:

The above example will write the Sales Order Number and Product Name.  For your specific requirement, change the Python expression as follows:

record.product_id.name + ' / ' + str(record.product_uom_qty)
อวตาร
ละทิ้ง
ผู้เขียน

thanks for your help it works well,but when i am tried to add a field for a customer it doesn't work and i get an error. i couldn't know where is the problem please see this screenshot

https://drive.google.com/file/d/17elLvPOibGDmjAOb92VBBls_UfnQi7tL/view?usp=sharing

I think you need to use order_partner_id because you are writing the ID of the record. order_partner_id.name is a text field.