def _get_initial_value(cls, invoice): init_date = Config.get_value( 'year_sequence_init_date', default=None, type_=date, ) init_value = Config.get_value( 'year_sequence_init_value', default=None, type_=int, ) if init_date and init_value and init_date.year == invoice.date.year: return init_value
def _get_initial_value(cls, invoice): init_date = Config.get_value( 'month_sequence_init_date', None, type_=date, ) init_value = Config.get_value( 'month_sequence_init_value', default=None, type_=int, ) if (init_date and init_value and init_date.year == invoice.date.year and init_date.month == invoice.date.month): return init_value else: return None
def migrate_datas(): logger = logging.getLogger("alembic.autonomie") from autonomie_base.models.base import DBSESSION session = DBSESSION() from autonomie.models.config import Config import json from autonomie.models.files import ( File, FileType, ) json_str = Config.get_value("attached_filetypes", "[]") try: configured_filetypes = json.loads(json_str) except: logger.exception(u"Error in json str : %s" % json_str) configured_filetypes = [] if configured_filetypes: result = [] for filetype_label in configured_filetypes: if filetype_label: filetype = FileType(label=filetype_label) session.add(filetype) session.flush() result.append(filetype) for typ_ in result: query = File.query().filter_by(label=typ_.label) for file_ in query: file_.file_type_id = typ_.id session.merge(file_) session.flush()
def migrate_datas(): from autonomie.models.project.types import BusinessType from autonomie.models.config import Config from autonomie.models.task.mentions import TaskMention from autonomie.models.project.mentions import BusinessTypeTaskMention from autonomie_base.models.base import DBSESSION from alembic.context import get_bind session = DBSESSION() conn = get_bind() # Collect business type ids business_type_ids = [b[0] for b in session.query(BusinessType.id)] # for each fixed config key we now use mentions for index, (doctype, key, label, title) in enumerate((( 'estimation', 'coop_estimationfooter', u"Informations sur l'acceptation des devis", u"Acceptation du devis", ), ( "invoice", "coop_invoicepayment", u"Informations de paiement pour les factures", u"Mode de paiement", ), ( "invoice", "coop_invoicelate", u"Informations sur les retards de paiement", u"Retard de paiement", ))): # We retrieve the configurated value value = Config.get_value(key, "") mention = TaskMention( order=index, label=label, title=title, full_text=value.replace('%IBAN%', "{IBAN}").replace( '%RIB%', "{RIB}").replace('%ENTREPRENEUR%', '{name}')) session.add(mention) session.flush() for btype_id in business_type_ids: rel = BusinessTypeTaskMention( task_mention_id=mention.id, business_type_id=btype_id, doctype=doctype, mandatory=True, ) session.add(rel) session.flush() op.execute( u"INSERT INTO mandatory_task_mention_rel (task_id, mention_id) \ SELECT task.id, {mention_id} from task join node on task.id=node.id where \ node.type_='{type_}'".format(mention_id=mention.id, type_=doctype))
def help_text_libelle_comptable(*args): """ Hack to allow dynamic content in a description field description. """ base = u"Les variables disponibles \ pour la génération des écritures sont décrites en haut de page." maxlength = Config.get_value('accounting_label_maxlength', None) if maxlength: return u"{} NB : les libellés sont tronqués à ".format(base) + \ u"{} caractères au moment de l'export.".format(maxlength) + \ u"Il est possible de changer cette taille dans " +\ u"Configuration → Logiciel de comptabilité." else: return base
def help_text_libelle_comptable(): """ Hack to allow dynamic content in a description field description. """ base = u"Les variables disponibles \ pour la génération des écritures sont décrites en haut de page." maxlength = Config.get_value('accounting_label_maxlength', None) if maxlength: return u"{} NB : les libellés sont tronqués à ".format(base) + \ u"{} caractères au moment de l'export.".format(maxlength) + \ u"Il est possible de changer cette taille dans " +\ u"Configuration → Logiciel de comptabilité." else: return base
def _set_invoice_number(request, task, **kw): """ Set a official number on invoices (or cancelinvoices) :param obj request: The current pyramid request :param obj task: The current context """ template = Config.get_value('invoice_number_template', None) assert template is not None, \ 'invoice_number_template setting should be set' if task.official_number is None: InvoiceNumberService.assign_number( task, template, ) return task
def _get_common_invoice(self, user): """ Return an invoice object with common args for all the generated invoices """ inv = Invoice(self.company, self.customer, self.project, self.phase, user) inv.estimation = self # Common args inv.payment_conditions = self.payment_conditions inv.description = self.description inv.course = self.course inv.address = self.address inv.workplace = self.workplace inv.mentions = self.mentions inv.prefix = Config.get_value('invoice_prefix', '') return inv
def populate_invoice_number_template(session): from autonomie.models.config import Config if not Config.get_value("invoice_number_template"): Config.set("invoice_number_template", "{SEQGLOBAL}") session.flush()
def _get_initial_value(cls, invoice): return Config.get_value('global_sequence_init_value', None, type_=int)
def migrate_datas(): from autonomie.models.project.types import BusinessType from autonomie.models.config import Config from autonomie.models.task.mentions import TaskMention from autonomie.models.project.mentions import BusinessTypeTaskMention from autonomie_base.models.base import DBSESSION from alembic.context import get_bind session = DBSESSION() conn = get_bind() # Collect business type ids business_type_ids = [b[0] for b in session.query(BusinessType.id)] # for each fixed config key we now use mentions for index, (doctype, key, label, title) in enumerate(( ( 'estimation', 'coop_estimationfooter', u"Informations sur l'acceptation des devis", u"Acceptation du devis", ), ( "invoice", "coop_invoicepayment", u"Informations de paiement pour les factures", u"Mode de paiement", ), ( "invoice", "coop_invoicelate", u"Informations sur les retards de paiement", u"Retard de paiement", ) )): # We retrieve the configurated value value = Config.get_value(key, "") mention = TaskMention( order=index, label=label, title=title, full_text=value.replace( '%IBAN%', "{IBAN}").replace( '%RIB%', "{RIB}").replace( '%ENTREPRENEUR%', '{name}') ) session.add(mention) session.flush() for btype_id in business_type_ids: rel = BusinessTypeTaskMention( task_mention_id=mention.id, business_type_id=btype_id, doctype=doctype, mandatory=True, ) session.add(rel) session.flush() op.execute( u"INSERT INTO mandatory_task_mention_rel (task_id, mention_id) \ SELECT task.id, {mention_id} from task join node on task.id=node.id where \ node.type_='{type_}'".format(mention_id=mention.id, type_=doctype) )