Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
3777 Vizualizări
datas = safe_eval(self.datas)
 domain = [('quatation_id', '=', self.id)]
 shoes = self.env['shoes.order'].search(domain, limit=1)
 for line in datas['lines']:
                    line = line and line[2]
                    vals = {
                        u'product_id': line.get('product_id'),
                        u'amount_total': line.get('price'),

                    }

                shoes.service_ids.write(vals)



class ShoesOrderService(models.Model):
    _name = 'shoes.order.service'
    _rec_name = 'product_id'

    product_id = fields.Many2one(
        'product.product', 'Service',
        domain=[('type', '=', 'service')],
    )
    price = fields.Float()
    order_id = fields.Many2one(
        'shoes.order', 'Shoes Order')

 class ShoesOrder(models.Model):

_name = 'shoes.order'

 service_ids = fields.One2many(
    'shoes.order.service', 'order_id', string='Additional Services',
    copy=True

For example, i have DICT datas with some lines in there. I want to update record lines in other model and i use this code. Other models record have some lines init and i want to add new lines from DATAS. my code just overwrites lines that already there. how can i add to existing lines, and not overwriting?

Imagine profil
Abandonează
Cel mai bun răspuns

Try the below link. This will help you.

https://stackoverflow.com/questions/46850831/adding-lines-without-overwriting-existing


Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
9
mar. 20
41588
2
oct. 18
3551
1
mar. 15
4302
2
mar. 15
6335
2
apr. 23
3673