Odoo Help

Welcome!

This community 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.

0

filling a one2many

By
Segun Adesanya
on 5/4/16, 10:39 AM 242 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")

@api.one
@api.depends('date')
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
self.fido_reporting_ids.write(params)
1
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)
0

Prakash Sharma

--Prakash Sharma--
815
| 2 1 4
Delhi, India
--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 

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

fido_obj= self.env['fido.line.report']
fido_obj.create(params)

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!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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