Skip to Content
Menu
This question has been flagged
1 Reply
3338 Views
# -*- coding: utf-8 -*- 
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
from datetime import datetime

class dha(models.Model):
_name = 'vanphongpham.dha'


ds_vpp = fields.One2many(comodel_name="vanphongpham.dha.detail", inverse_name="dsdmvpp", string="Required")

@api.onchange("ds_vpp")
def summoney(self):
for line in self.ds_vpp:
print line.amount
tada = line.dsdmvpp # not show result
for oke in tada:
print oke.gia_ca_vpp

class dhadtl(models.Model):
_name = 'vanphongpham.dha.detail'

#book_load = fields.Many2one("vanphongpham.dha", "Phieu muon", required=True)

    dsdmvpp = fields.Many2one("product.product", "List stationery", required=True)
    amount = fields.Integer(string='Amount', required=True, default='1')
   
How to get value sale price from  in "summoney"?
Thanks in advance!
Avatar
Discard

Relationship of One2Many is not correctly defined, You need to define the Many2one field of the model (Where One2Many is defined) into co-model (In your case co-model is vanphongapham.dha.detail).

Best Answer

Hi DHA, 
I notice that you declared a O2M with comodel_name="vanphongpham.dha.detail"  and inverse_name = 'dsdmvpp'. That means in  ''vanphongpham.dha.detail'' object, you need to have dsdmvpp=M2O('vanphongpham.dha', ...) 
and not to ''product.product''.

Avatar
Discard
Related Posts Replies Views Activity
2
Sep 22
7896
2
Apr 22
2462
0
Jul 21
5330
1
Mar 21
3344
5
Aug 20
16307