示例#1
0
def _customize_schema(schema):
    """
    Add common widgets configuration for the customer forms schema

    :param obj schema: The Customer form schema
    """
    schema['civilite'].widget = forms.get_radio(
        CIVILITE_OPTIONS[1:],
        inline=True,
    )
    schema['civilite'].validator = colander.OneOf(
        [a[0] for a in CIVILITE_OPTIONS])
    schema['address'].widget = deform.widget.TextAreaWidget(
        cols=25,
        row=1,
    )
    schema['email'].validator = forms.mail_validator()
    schema['comments'].widget = deform.widget.TextAreaWidget(
        css_class="col-md-10")
    return schema
示例#2
0
abandons de créance dans les notes de dépense",
        "section": u"Abandon de créance",
    },
    "code_tva_ndf": {
        "title": u"Code TVA utilisé pour les décaissements",
        "description": u"Le code TVA utilisé pour l'export des décaissements",
        "section": u"Paiement des notes de dépenses",
    },
    "treasury_measure_ui": {
        "title": u"Indicateur à mettre en évidence",
        "description": u"Indicateur qui sera mis en évidence dans l'interface "
        u"entrepreneur",
        "widget": forms.get_radio(
            values=(
                ('1', u"Trésorerie du jour"),
                ("4", u"Trésorerie de référence"),
                ("8", u"Trésorerie future"),
                ("10", u"Résultat de l'entreprise"),
            )
        )
    },
    "invoice_number_template": {
        "title": u"Gabarit du numéro de facture",
        "description": u"Peut contenir des caractères (préfixes, \
séparateurs… etc), ainsi que des variables et séquences. Ex: {YYYY}-{SEQYEAR}.",
        "missing": colander.required,
        "validator": invoice_number_template_validator,
    },
    "global_sequence_init_value": {
        "title": u"Valeur à laquelle on initialise de la séquence globale",
        "section": u"Séquence globale (SEQGLOBAL)",
        "type": colander.Int(),
示例#3
0
class Customer(DBBASE, PersistentACLMixin):
    """
        Customer model
        Stores the company and its main contact
        :param name: name of the company
        :param code: internal code of the customer (unique regarding the owner)
        :param multiline address: address of the company
        :param zip_code: zipcode of the company
        :param city: city
        :param country: country, default France
        :param lastname: lastname of the contact
        :param firstname: firstname of the contact
        :param function: function of the contact
    """
    __tablename__ = 'customer'
    __table_args__ = default_table_args
    __colanderalchemy_config__ = {
        'after_bind': customer_after_bind,
    }
    id = Column(
        'id',
        Integer,
        primary_key=True,
        info={
            'colanderalchemy': {
                'exclude': True,
                'title': u"Identifiant Autonomie",
            }
        },
    )
    type_ = Column('type_',
                   String(10),
                   default='company',
                   info={
                       'colanderalchemy': {
                           'exclude': True
                       },
                       'export': {
                           'exclude': True
                       },
                   })

    created_at = deferred(
        Column(
            Date(),
            default=datetime.date.today,
            info={
                'export': {
                    'exclude': True
                },
                'colanderalchemy': forms.EXCLUDED,
            },
            nullable=False,
        ),
        group='all',
    )

    updated_at = deferred(
        Column(
            Date(),
            default=datetime.date.today,
            onupdate=datetime.date.today,
            info={
                'export': {
                    'exclude': True
                },
                'colanderalchemy': forms.EXCLUDED,
            },
            nullable=False,
        ),
        group='all',
    )

    company_id = Column(
        "company_id",
        Integer,
        ForeignKey('company.id'),
        info={
            'export': {
                'exclude': True
            },
            'colanderalchemy': forms.EXCLUDED,
        },
        nullable=False,
    )

    name = Column(
        "name",
        String(255),
        info={
            "colanderalchemy": {
                'title': u'Nom de la structure',
            },
        },
        default='',
    )

    code = Column(
        'code',
        String(4),
        info={'colanderalchemy': {
            'title': u"Code client"
        }},
    )

    civilite = deferred(
        Column('civilite',
               String(10),
               info={
                   'colanderalchemy': {
                       'title':
                       u"Civilité",
                       'widget':
                       forms.get_radio(CIVILITE_OPTIONS[1:], inline=True),
                   }
               }),
        group='edit',
    )

    lastname = deferred(
        Column(
            "lastname",
            String(255),
            info={"colanderalchemy": {
                'title': u"Nom du contact principal",
            }},
            nullable=False,
        ),
        group='edit',
    )

    firstname = deferred(
        Column(
            "firstname",
            String(255),
            info={
                'colanderalchemy': {
                    'title': u"Prénom du contact principal",
                }
            },
            default="",
        ),
        group='edit',
    )

    function = deferred(
        Column(
            "function",
            String(255),
            info={
                'colanderalchemy': {
                    'title': u"Fonction du contact principal",
                }
            },
            default='',
        ),
        group="edit",
    )

    address = deferred(Column(
        "address",
        String(255),
        info={
            'colanderalchemy': {
                'title': u'Adresse',
                'widget': deform.widget.TextAreaWidget(
                    cols=25,
                    row=1,
                )
            }
        },
        nullable=False,
    ),
                       group='edit')

    zip_code = deferred(
        Column(
            "zip_code",
            String(20),
            info={
                'colanderalchemy': {
                    'title': u'Code postal',
                },
            },
            nullable=False,
        ),
        group='edit',
    )

    city = deferred(
        Column(
            "city",
            String(255),
            info={'colanderalchemy': {
                'title': u'Ville',
            }},
            nullable=False,
        ),
        group='edit',
    )

    country = deferred(
        Column(
            "country",
            String(150),
            info={
                'colanderalchemy': {
                    'title': u'Pays'
                },
            },
            default=u'France',
        ),
        group='edit',
    )

    email = deferred(
        Column(
            "email",
            String(255),
            info={
                'colanderalchemy': {
                    'title': u"Adresse de messagerie",
                    'validator': forms.mail_validator(),
                },
            },
            default='',
        ),
        group='edit',
    )
    mobile = deferred(
        Column(
            "mobile",
            String(20),
            info={
                'colanderalchemy': {
                    'title': u"Téléphone portable",
                },
            },
            default='',
        ),
        group='edit',
    )

    phone = deferred(
        Column(
            "phone",
            String(50),
            info={
                'colanderalchemy': {
                    'title': u'Téléphone fixe',
                },
            },
            default='',
        ),
        group='edit',
    )

    fax = deferred(Column(
        "fax",
        String(50),
        info={'colanderalchemy': {
            'title': u'Fax',
        }},
        default='',
    ),
                   group="edit")

    tva_intracomm = deferred(
        Column(
            "tva_intracomm",
            String(50),
            info={
                'colanderalchemy': {
                    'title': u"TVA intracommunautaire"
                },
            },
            default='',
        ),
        group='edit',
    )

    comments = deferred(
        Column(
            "comments",
            Text,
            info={
                'colanderalchemy': {
                    'title': u"Commentaires",
                    'widget':
                    deform.widget.TextAreaWidget(css_class="col-md-10"),
                }
            },
        ),
        group='edit',
    )

    compte_cg = deferred(
        Column(
            String(125),
            info={
                'export': {
                    'exclude': True
                },
                'colanderalchemy': {
                    'title': u"Compte CG",
                },
            },
            default="",
        ),
        group="edit",
    )

    compte_tiers = deferred(
        Column(
            String(125),
            info={
                'export': {
                    'exclude': True
                },
                'colanderalchemy': {
                    'title': u"Compte tiers",
                }
            },
            default="",
        ),
        group="edit",
    )
    archived = Column(
        Boolean(),
        default=False,
        info={'colanderalchemy': forms.EXCLUDED},
    )

    company = relationship("Company",
                           primaryjoin="Company.id==Customer.company_id",
                           info={
                               'colanderalchemy': forms.EXCLUDED,
                               'export': {
                                   'exclude': True
                               },
                           })

    estimations = relationship(
        "Estimation",
        primaryjoin="Estimation.customer_id==Customer.id",
        info={
            'colanderalchemy': forms.EXCLUDED,
            'export': {
                'exclude': True
            },
        })

    invoices = relationship("Invoice",
                            primaryjoin="Invoice.customer_id==Customer.id",
                            info={
                                'colanderalchemy': forms.EXCLUDED,
                                'export': {
                                    'exclude': True
                                },
                            })

    cancelinvoices = relationship(
        "CancelInvoice",
        primaryjoin="CancelInvoice.customer_id==Customer.id",
        info={
            'colanderalchemy': forms.EXCLUDED,
            'export': {
                'exclude': True
            },
        })

    _autonomie_service = CustomerService

    def get_company_id(self):
        """
            :returns: the id of the company this customer belongs to
        """
        return self.company.id

    def todict(self):
        """
            :returns: a dict version of the customer object
        """
        projects = [project.todict() for project in self.projects]
        return dict(
            id=self.id,
            code=self.code,
            comments=self.comments,
            tva_intracomm=self.tva_intracomm,
            address=self.address,
            zip_code=self.zip_code,
            city=self.city,
            country=self.country,
            phone=self.phone,
            email=self.email,
            lastname=self.lastname,
            firstname=self.firstname,
            name=self.name,
            projects=projects,
            full_address=self.full_address,
            archived=self.archived,
            company_id=self.company_id,
        )

    def __json__(self, request):
        return self.todict()

    @property
    def full_address(self):
        """
            :returns: the customer address formatted in french format
        """
        return self._autonomie_service.get_address(self)

    def has_tasks(self):
        return self._autonomie_service.count_tasks(self) > 0

    def is_deletable(self):
        """
            Return True if this project could be deleted
        """
        return self.archived and not self.has_tasks()

    def is_company(self):
        return self.type_ == 'company'

    def get_label(self):
        return self._autonomie_service.get_label(self)

    @property
    def label(self):
        """
        Property used for exports (as a related_key parameter)
        """
        return self.get_label()

    def get_name(self):
        return self._autonomie_service.format_name(self)

    @classmethod
    def check_project_id(cls, customer_id, project_id):
        return cls._autonomie_service.check_project_id(customer_id, project_id)
示例#4
0
abandons de créance dans les notes de dépense",
    },
    "code_tva_ndf": {
        "title": u"Code TVA utilisé pour les décaissements",
        "description": u"Le code TVA utilisé pour l'export des décaissements"
    },
    "treasury_measure_ui": {
        "title":
        u"Indicateur à mettre en évidence",
        "description":
        u"Indicateur qui sera mis en évidence dans l'interface "
        u"entrepreneur",
        "widget":
        forms.get_radio(values=(
            ('1', u"Trésorerie du jour"),
            ("4", u"Trésorerie de référence"),
            ("8", u"Trésorerie future"),
            ("10", u"Résultat de l'entreprise"),
        ))
    }
}


def get_config_key_schemanode(key, ui_conf):
    """
    Returns a schema node to configure the config 'key'
    This key should appear in the dict here above CONFIGURATION_KEYS
    """
    return colander.SchemaNode(
        colander.String(),
        title=ui_conf.get('title', key),
        description=ui_conf.get('description'),