Skip to Content
Menu
This question has been flagged
1 Reply
3387 Views

Hi,

We use odoo 11,

Form sale order and custom form Communicate via field x_field.
I want click button in sale order, all product_id in order_line , append to custom Form lines.

Please help me.


class SaleOrder(models.Model):
    _name = "sale.order"

    x_field =  fields.Many2one('custom.model',string='relation field')

    @api.multi
    def sent_to_delivery(self):        
        ??????

xml:
<button name="sent_to_delivery" class="oe_highlight"  type="object" string="Delivery"/>



class custom(models.Model):

    _name = 'custom.model'
    c_items = fields.One2many('con.item''t_field'string='Items')  

class con_item(models.Model):
    _name = con.item'


    product = fields.Many2one('product.product'string='Product Name' ,change_default=True,required=True)
    saleorder_number = fields.Many2one('sale.order'string='Sale Order Number'
    t_field = fields.Many2one('custom.model')




How write function sent_to_delivery?

Avatar
Discard
Best Answer

Hi,

You can write like this

line_vals = []
for line in self.order_line:
line.append([(0, 0, {'product': line.product_id.id,'saleorder_number': self.id})])

record = self.env['custom.model'].create({
'c_items': line_vals
})

self.x_field = record.id


Regards


Global Creative Concepts Tech Co Ltd.


Avatar
Discard