Odoo Help


filling a one2many

Segun Adesanya
on 5/4/16, 10:39 AM 875 views

My code runs, but it doesnt fill anything on my one2many list

class fido_reporting(models.Model):
_name = 'fido.reporting'
date = fields.Date(default=fields.Date.today(), string='Date')
incedent = fields.Text(string='Incident')
fido_reporting_ids = fields.One2many('fido.line.report', 'line_report_id', compute="compute_report")

def compute_report(self):
report_data = self.env['account.invoice'].search([('date_invoice','=',self.date),('journal_id','=',"Customer Invoices"),('state','!=',"Draft")])
for reports in report_data:
for line_records in reports.invoice_line_ids:
params = {'line_report_id':self.id, 'name': reports.partner_id.name, 'product': line_records.product_id.name, 'quantity': 10, 'price' : 10.0, 'amount': 10.0}
# print params
print params
Segun Adesanya
On 5/19/16, 11:23 AM

this is my solution to it 

for reports in report_data: 
for line_records in reports.invoice_line_ids:
params = {'line_report_id':self.id, 'name': reports.partner_id.name, 'product': line_records.product_id.name, 'quantity': line_records.quantity, 'price' : line_records.price_unit, 'amount': line_records.price_subtotal}
#print params
self.fido_reporting_ids |= self.env['fido.line.report'].create(params)

Prakash Sharma

--Prakash Sharma--
--Prakash Sharma--

I like to surround myself with brave, creative people.

My motivation for learning different technologies and algos drive me. I love challenges of a steep learning curve which I believe makes me a better learner. I have a strong desire to learn different technologies, which would enable me to become a full stack developer.

Prakash Sharma
On 5/4/16, 11:12 AM

instead of write just use create here , the foreign key line_report_id    automatically link this  record with the current id 

ayman mohammed adam
On 5/19/16, 8:51 AM
try this:

fido_obj= self.env['fido.line.report']

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 5/4/16, 10:39 AM
Seen: 875 times
Last updated: 5/19/16, 11:24 AM