Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ilyasProgrammer/5cf31d5da3e1c5059e0f30d6fbdcd926 to your computer and use it in GitHub Desktop.
Save ilyasProgrammer/5cf31d5da3e1c5059e0f30d6fbdcd926 to your computer and use it in GitHub Desktop.
@api.model
def default_get(self, fields):
res = super(Report, self).default_get(fields)
if self._context.get('task_id', False):
res['task_id'] = self._context['task_id']
task = self.env['project.task'].browse(res['task_id'])
brl = self.env['bm.report.lines']
report_lines = []
for l in task.pricing_ids:
report_line = brl.create({
'pricing_id': l.pricing_id.id,
'amount': l.amount,
'labor_vol': l.labor_vol,
'mech_vol': l.mech_vol,
})
report_lines.append(report_line.id)
res['lines_ids'] = report_lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment