Skip to Content
Menu
This question has been flagged
1 Reply
2112 Views

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

 

 

Avatar
Discard
Author

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

Best Answer

Hi  nzangon,

Guess Invoice is generated when a button is clicked from Lab Request.
Find the function that creates invoice from Lab Request and pass the physician_id.

Avatar
Discard
Author

brother I find the button function but here I can not pass the physician_id

can you please share that function

Author

def view_invoice(self):
invoices = self.mapped('invoice_id')
action = self.acs_action_view_invoice(invoices)
return action

This one is for viewing the invoice, Check the function to create the invoice

Author

def create_invoice(self):
product_id = self.registration_product_id or self.env.user.company_id.treatment_registration_product_id
if not product_id:
raise UserError(_("Please Configure Registration Product in Configuration first."))
invoice = self.acs_create_invoice(partner=self.patient_id.partner_id, patient=self.patient_id, product_data=[{'product_id': product_id}], inv_data={'hospital_invoice_type': 'treatment'})
self.invoice_id = invoice.id

Author

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

Author

The 2nd one is lab test invoice create 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

//This will update physician_id in invoice

invoice.physician_id = self.physician_id.id if self.physician_id else False

Author

Thank you brother. Its worked