bagaimana cara get value dari model lain?
saya mempunya modul batch dan modul seleksi , dan saya mempunyai model untuk report. jadi setiap batch_ids dan selection_ids ingin saya tarik datanya ke model report. bagaimana cara menarik data dari2 model lain ke satu model, ?
class ReportPlantation(models.Model):
_name = 'estate.nursery.reportplantation'
names=fields.Char("Report Plantation Name ")
report_date = fields.Datetime("Report Date",compute="_report_date",readonly=True)
report_ids = fields.One2many('estate.nursery.batch', 'reportplan_id', "Report Lines",)
saya menghubungkan dengan model batch , yang terjadi hanya menarik modelnya saja, data yang ada di dalam batch tidak terambil, bagaimana cara mengambil datanya?
Field apa yang mau diambil? Bagaimana struktur estate.nursery.batch nya?
--
Andhitia Rama
Sent by OpenSynergy Indonesia using Odoo , access directly to Forum Post bagaimana cara get value dari model lain?
Akses untuk field estate.nursery.batch dapat diakses via dot notation. Contoh
#1 Browse terlebih dahulua data report
obj_report = self.pool.get('estate.nursery.reportplantation')
report = obj_report.browse(cr, uid, [id_report_yang_diinginkan])[0]
#2 Loop report_ids
for batch in report.report_ids:
# contoh mau mengakses field batch_number
some_var = batch.batch_number
Your answer
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
Ikuti Berita
Tujuan Forum
Forum ini bertujuan untuk membahas masalah teknikal Odoo
Baca PanduanQuestion tools
Stats
Asked: 11/26/15, 3:49 AM |
Seen: 1627 times |
Last updated: 11/27/15, 2:30 AM |
Field apa yang mau diambil? Bagaimana struktur estate.nursery.batch nya?