def _get_account_period(self, date=None): if not date: date = time.strftime('%Y-%m-%d') ids = self.env['account.period'].search([('date_start', '<=', date), ('date_stop', '>=', date)]) if not ids: raise exceptions('Error !','No period defined for this date !\nPlease create a' ' fiscal year.') return ids
def action_cancel(self): """ Verify first in the invoice have a fiscal book associated and if the state of the book is in cancel. """ for inv_brw in self.browse(): if not (not inv_brw.fb_id or (inv_brw.fb_id and inv_brw.fb_id.state == 'cancel')): raise exceptions( "Error!", "You can't cancel an invoice that is loaded in a" " processed Fiscal Book (%s). You need to go to" " Fiscal Book and set the book to Cancel. Then you" " could be able to cancel the invoice." % (inv_brw.fb_id.state, )) return super(AccountInvoice, self).action_cancel()
def decrease_amount(self): """ Change the amount petty cash """ context = self._context or {} ids = isinstance(self.ids, (int, int)) and [self.ids] or self.ids petc_obj = self.env['account.petty.cash'] petc_ids = context.get('active_ids', []) data = self.browse(ids[0]) if not data.sure: raise exceptions("Error!", "Please confirm that you want to do this by checking the option") if petc_ids: pass self.validate_petty_cash(petc_ids) #petc_obj.write(petc_ids, {'sin_cred': data.sin_cred}) return {}
def sin_fiscal_book(self): """ Change the sin cred field in the invoice @return """ context = self._context or {} ids = isinstance(self.ids, (int, int)) and [self.ids] or self.ids inv_obj = self.env['account.invoice'] inv_ids = context.get('active_ids', []) data = self.browse(ids[0]) invoice = inv_obj.browse(self._context['active_id']) if not data.sure: raise exceptions( "Error!, Please confirm that you want to do this by checking the option" ) if inv_ids: invoice.write({'sin_cred': self.sin_cred}) return {}