class invoiceextendtask(models.Model):
_inherit = 'account.invoice'
date_invoice = fields.Date(string='Invoice Date',readonly=True, states={'draft': [('readonly', False)]}, index=True, help="Keep empty to use the current date", default=datetime.today(), copy=False)
is_consult = fields.Boolean(string='Consult')
is_session = fields.Boolean(string='Session')
prod_price = fields.Selection([('member', 'Member Pricelist'), ('non-member', 'Non-Member Pricelist'), ('cigna', 'Cigna Pricelist')], string='Product Pricelist')
referred_to = fields.Many2one('llw.employee', string='Referred To',)
payment_type = fields.Selection([('cash', 'Cash'), ('card', 'Card'), ('hmo', 'HMO'), ('others', 'Others')], string='Payment Type')
session_last = fields.Integer(string='Last session no.', size="10")
session_nextno = fields.Integer(string="Session Number", size="10")
partner_id = fields.Many2one('res.partner', string='Partner', change_default=True,required=True, readonly=True, states={'draft': [('readonly', False)]},track_visibility='always', help="Choose patient name")
@api.onchange('is_session')
def _onchange_partner(self):
part = self.partner_id
if not part:
warning = {
'title': _('Warning!'),
'message': _('You must first select a partner!'),
}
return {'warning': warning}
else:
self.env.cr.execute("SELECT account_invoice.session_last FROM account_invoice where account_invoice.is_session = 't' ")
result = self.env.cr.fetchone()