在这里我很多很多一个领域。我已经为many2one字段“ issue_line_id”设置了onchange,但是未调用onchange函数。我该如何解决此问题??
class TptMaterialReturnRequestLine(models.Model):
_name = 'tpt.material.return.request.line'
return_request_id = fields.Many2one(comodel_name='tpt.material.return.request', string='Return Request')
issue_line_id = fields.Many2one(comodel_name='tpt.material.issue.line', string='Material Code',required=True)
name = fields.Char(string='Material Description',readonly=True,related = 'issue_line_id.dec_material')
requested_qty = fields.Float(string='Requested Qty',readonly=True)
issued_qty = fields.Float(string='Issued Qty',readonly=True)
return_request_qty = fields.Float(string='Return Request Qty')
state = fields.Selection([('draft', 'Draft'),
('confirmed', 'Confirmed'),
('approved', 'Approved'),
('accepted', 'Accepted'),
('rejected', 'Rejected'),
], string='Status', readonly=True,default='draft')
reason_reject = fields.Text(string='Reason for Rejection')
department_id = fields.Many2one(comodel_name='hr.department',string='Department',readonly=True)
section_id = fields.Many2one(comodel_name='arul.hr.section',string='Section',readonly=True)
return_request_no = fields.Char(string='Return Request No',readonly=True)
return_request_date = fields.Date(string='Return Request Date',readonly=True)
maintenance_id = fields.Many2one(comodel_name='tpt.maintenance.oder',string='Maintenance Order No',readonly=True)
issue_id = fields.Many2one(comodel_name='tpt.material.issue',string='Issue No',readonly=True)
@api.onchange('issue_line_id')
def onchange_issue_line_id(self):
print ("onchange_issue_line_id")
self.name = self.issue_line_id.dec_material
self.requested_qty = self.issue_line_id.product_uom_qty
self.issued_qty = self.issue_line_id.product_isu_qty