I have a problem how can I show prescribing doctor field value inside physician in account.move.
Here the model acs.lab.request physician_id field value I want to show in account.move. How can I do that please help me.
from odoo import api,fields,models,_
class AccountMove(models.Model):
_inherit = 'account.move'
patient_id = fields.Many2one('hms.patient', string='Patient', index=True, readonly=True, states={'draft': [('readonly', False)]})
physician_id = fields.Many2one('hms.physician', string='Physician', index=True, readonly=True, states={'draft': [('readonly', False)]})
hospital_invoice_type = fields.Selection([
('patient','Patient')], string="Hospital Invoice Type")
@api.onchange('patient_id')
def onchange_patient(self):
if self.patient_id and not self.partner_id:
self.partner_id = self.patient_id.partner_id.id
This is the laboratory create invoice function
def create_invoice(self):
if not self.line_ids:
raise UserError(_("Please add lab Tests first."))
product_data = []
for line in self.line_ids:
product_data.append({
'product_id': line.test_id.product_id,
'price_unit': line.sale_price,
})
pricelist_context = {}
if self.pricelist_id:
pricelist_context = {'acs_pricelist_id': self.pricelist_id.id}
invoice = self.with_context(pricelist_context).acs_create_invoice(partner=self.patient_id.partner_id, patient=self.patient_id, product_data=product_data, inv_data={'hospital_invoice_type': 'laboratory'})
self.invoice_id = invoice.id
invoice.request_id = self.id