예제 #1
0
class res_partner(models.Model):
    _inherit = "res.partner"
    _columns = {
        'schedule':
        fields.one2many('res.partner.working.time', 'partner_id',
                        'Working Time'),
    }
예제 #2
0
class HrEmployee(model.Model):
    """Inherit hr_employee to add date_start and to add yours childrens
    """
    _inherit = "hr.employee"

    _columns = {
        'date_start': fields.date('Date Start'),
        'children_ids': fields.one2many('hr.children', 'employee_id',
                                        'Childrens')
    }
예제 #3
0
class ped(models.Model):
    _name = 'pedido.compra'

    name = fields.Char(string="Detalle", required=True)

    pedido_id = fields.one2many('detalle.compra',
                                'detalle_compra_id',
                                compute="_info_compra")

    @api.one
    def _info_compra(self):
        self.pedido_id = len(self.pedido_id)
예제 #4
0
class Souche(models.Model):
    _name = 'souchier.souche'
    
    name = fields.Char(string="Souche", required=True, index=True)
    description = fields.Text(string="Description")
    _sql_constraints = [('name', 'unique(name)',
                         "Le nom de la souche doit etre unique")]
    client = fields.many2one(comodel_name='res.users', string="Client",
                             required=True, ondelete='restrict')
    emplacement = fields.many2one(comodel_name='souchier.emplacement',
                                  string="Emplacement master",
                                  ondelete="restrict",
                                  required=True)

    emplacements_WS = fields.one2many(comodel_name='souchier.emplacement',
                                       string="Emplacements working seeds",
                                       ondelete='restrict',
                                      inverse_name='occupe_par',
                                       required=False)
    date_reception = fields.Date(required=True)
    
                        
예제 #5
0
class aulas():
    _name = 'aulas.aula'

    nombre = fields.Char(string='nombre')
    ciclo = fields.one2many('ciclos.ciclo')
    ordenadores = fields.Many2One('ordenadores.ordenador', 'aula')
예제 #6
0
    def get_oeillets(self):
        result = {}
        for line in self:
            try:
                result[line.id] = (line.largeur +
                                   line.longueur) * 2 / line.oeillets
            except:
                result[line.id] = 0
        return result

        name = fields.Char('Designation',
                           size=64,
                           required=False,
                           readonly=False)
        date = fields.Date('Date')
        partner_id = fields.Many2one('res.partner', 'Client', required=False)
        imprime = fields.Char('Nom d"Imprime',
                              size=64,
                              required=True,
                              readonly=False)
        product_id = fields.Many2one('product.product',
                                     'Produit',
                                     required=False,
                                     states={'draft': [('readonly', False)]})
        product_categorie = fields.Many2one('product_tmpl_id.categ_id',
                                            store=False)
        #'product_id': fields.Many2many('product.product', id1='att_id', id2='prod_id', string='Variants', readonly=True),
        child_ids = fields.One2many('offset.printshop',
                                    'parent_id',
                                    'Produits fils',
                                    required=False,
                                    states={'draft': [('readonly', False)]})
        parent_id = fields.Many2one('offset.printshop',
                                    'Parent',
                                    required=False,
                                    select=1,
                                    states={'draft': [('readonly', False)]}),
        parent_is = fields.Boolean(
            'Article compose',
            help='Cocher si larticle est compose de plueisuers articles')
        product_tmpl_id = fields.Many2one(
            'product.template',
            'Produit template',
            required=False,
            states={'draft': [('readonly', False)]})
        largeur = fields.Float('Largeur en m', required=True)
        longueur = fields.Float('Longueur en m', required=True)
        largeur_raclage_rigide = fields.Float('Largeur a racler en m',
                                              required=False)
        longueur_raclage_rigide = fields.Float('Longueur ea racler m',
                                               required=False)
        quantite_raclage_rigide = fields.Float('Quantite raclage rigide',
                                               required=False)

        fond_perdu = fields.Float('Fond Perdu en m',
                                  states={'done': [('readonly', True)]})
        quantite = fields.Float('Quantite', required=False)
        #'marge' : fields.Float('Marge', required=True   ),
        remise_id = fields.Many2one('printshop2.remise',
                                    'remise',
                                    required=False,
                                    states={'draft': [('readonly', False)]})

        machine_id = fields.Many2one('printshop.machine',
                                     'Machine',
                                     required=True)
        nbr_pose = fields.Float('Poses',
                                help='nbr pose produit dans le support',
                                readonly=True)
        support_id = fields.Many2one('printshop.support',
                                     'Support',
                                     required=True),
        support_line_id = fields.Many2one('support_id.line',
                                          'Produit Support',
                                          required=False)
        nbr_ml = fields.Float('Ml',
                              help='nbr metre linaire produit dans le support',
                              readonly=True)
        nbr_m2 = fields.Float('M²',
                              help='nbr m² produit dans le support',
                              readonly=True)
        rigide_id = fields.Many2one('printshop.rigide',
                                    'Rigide',
                                    required=False)
        qty_feuilles = fields.Float(
            'Nombre de feuilles',
            readonly=True,
        ),
        oeillet_id = fields.Many2one('product.product',
                                     'Oeillet',
                                     required=False)
        oeillets = fields.Float('oeillets par m')
        nbr_oeillets_produit = fields.function(get_oeillets,
                                               method=True,
                                               type='Float',
                                               string='Oeillets par produit',
                                               store=False),
        couture_id = fields.Many2one('product.product',
                                     'Couture',
                                     required=False)
        couture = fields.Float('ml de couture', readonly=True)
        qte_couture = fields.Float('Qte Couture', readonly=True)
        baguette_id = fields.Many2one('product.product',
                                      'Baguette',
                                      required=False)
        baguettes = fields.Float('Nbr Baguettes')
        qte_baguettes = fields.Float('Qte Baguettes', readonly=True)
        raclage_id = fields.Many2one('product.product',
                                     'Raclage',
                                     required=False)
        qte_raclage = fields.Float('Qte Raclage', readonly=True)
        description = fields.Text('Description')
        bom_id = fields.Many2one('mrp.bom', 'Nomenclature')
        line_ids = fields.one2many('xl.printshop.line',
                                   'printshop_id',
                                   'Calculs',
                                   required=False,
                                   states={'draft': [('readonly', False)]})
        line_id = fields.Many2one('xl.printshop.line',
                                  'Ligne optimale',
                                  required=False,
                                  states={'draft': [('readonly', False)]})
        rigide_line_ids = fields.one2many('xl.printshop.rigide.line',
                                          'printshop_id',
                                          'Nombre de feuilles',
                                          required=False)
        rigide_line_id = fields.Many2one('xl.printshop.rigide.line',
                                         'Nombre de feuilles optimal',
                                         required=False)
        other_product_line_id = fields.one2many('other.product.line',
                                                'other_product_id',
                                                'Autres matieres',
                                                required=False)
        cout_total_matieres = fields.function(get_cout_total_matieres,
                                              method=True,
                                              type='Float',
                                              string='cout Total Matieres',
                                              store=False)
        user_id = fields.Many2one('res.users',
                                  'Createur',
                                  required=True,
                                  readonly=True)
        subproduct_ids = fields.One2many('xl.printshop.subproduct',
                                         'printshop_id',
                                         'Les sous produits',
                                         required=False)
        cout_total = fields.function(get_cout_total,
                                     method=True,
                                     type='Float',
                                     string='cout total',
                                     store=False),
        prix_vente_unitaire = fields.function(
            get_prix_vente_unitaire,
            method=True,
            type='Float',
            string='Prix de vente unitaire',
            store=False
        ),  #  = 'cout_de_reviens' + ('cout_de_reviens' *('marge'/100)) / 'quantite'
        state = fields.Selection([
            ('draft', 'Draft'),
            ('done', 'Done'),
        ],
                                 'State',
                                 select=True,
                                 readonly=True)
예제 #7
0
class F360Alerta(models.Model):
    _name = "x_360fin.alerta"
    _inherit = ['mail.thread']
    _description = "360fin.alerta"
    _order = "priority desc,date_deadline,id desc"

    def _default_probability(self):
        stage_id = self._default_stage_id()
        if stage_id:
            return self.env['x_360fin.alerta.stage'].browse(
                stage_id).probability
        return 10

    def _default_stage_id(self):
        return self._stage_find(domain=[('fold', '=', False)]).id

    create_date = fields.datetime(string="Created on", store=True, copy=True)
    create_uid = fields.Many2one(string="Created by",
                                 store=True,
                                 copy=True,
                                 comodel_name='res.users')
    display_name = fields.Char(string="Display", readonly=True, size=0)
    id = fields.Integer(string="ID", readonly=True, store=True, copy=True)
    write_date = fields.datetime(string="Last Updated on",
                                 store=True,
                                 copy=True)
    write_uid = fields.Many2one(string="Last Updated by",
                                store=True,
                                copy=True,
                                comodel_name='res.users')

    active = fields.Boolean(string="Active", store=True, copy=True)
    name = fields.Char(string="Alerta",
                       required=True,
                       index=True,
                       readonly=True,
                       store=True,
                       copy=True,
                       size=0)
    date_action_last = fields.Datetime(string="Last Action",
                                       readonly=True,
                                       store=True,
                                       copy=True)
    kanban_state = fields.Selection([('grey', 'Pendiente'),
                                     ('red', 'Bloqueado'),
                                     ('green', 'Validado'),
                                     ('blue', 'Reportado')],
                                    string="Activity State",
                                    readonly=True)
    description = fields.Text(string="Notes", store=True, copy=True)
    priority = fields.Selection(
        f360_alerta_stage.AVAILABLE_PRIORITIES,
        string="Priority",
        store=True,
        index=True,
        copy=True,
        default=f360_alerta_stage.AVAILABLE_PRIORITIES[0][0])
    date_closed = fields.Datetime(string="Closed Date",
                                  readonly=True,
                                  store=True)
    stage_id = fields.Many2one(string="Stage",
                               track_visibility="onchange",
                               store=True,
                               copy=True,
                               index=True,
                               group_expand="_read_group_stage_ids",
                               default=lambda self: self._default_stage_id(),
                               comodel_name="x_360fin.alerta.stage")
    user_id = fields.Many2one(string="Compliance Officer",
                              index=True,
                              track_visibility="onchange",
                              comodel_name="res.users",
                              default=lambda self: self.env.user)
    date_open = fields.Datetime(string="Assigned",
                                readonly=True,
                                store=True,
                                copy=True,
                                default=fields.Datetime.now)
    day_open = fields.Float(string="Days to Assign", readonly=True, store=True)
    day_close = fields.Float(string="Days to Close", readonly=True, store=True)
    date_last_stage_update = fields.Datetime(string="Last Stage Update",
                                             store=True,
                                             index=True,
                                             copy=True,
                                             default=fields.Datetime.now)
    date_conversion = fields.Datetime(string="Conversion Date",
                                      readonly=True,
                                      store=True,
                                      copy=True)

    # Only used for type opportunity
    date_deadline = fields.Date(
        string="Expected Closing",
        store=True,
        copy=True,
        help="Estimate of the date on which the alert will be late.")
    color = fields.Integer(string="Color Index",
                           store=True,
                           copy=True,
                           default=0)

    # Alerts
    alert_id = fields.Many2one(string="Alerta id",
                               readonly=True,
                               store=True,
                               copy=True,
                               comodel_name="x_360fin.alerta.catalogo",
                               help="Alerta id")
    employee_id = fields.Many2one(string="Employee id",
                                  readonly=True,
                                  store=True,
                                  copy=True,
                                  help="Employee id",
                                  comodel_name="hr.employee")
    partner_id = fields.Many2one(string="Partner id",
                                 readonly=True,
                                 store=True,
                                 copy=True,
                                 help="Partner id",
                                 comodel_name="res.partner")
    company_id = fields.Many2one(string="Company id",
                                 readonly=True,
                                 store=True,
                                 copy=True,
                                 help="Company id",
                                 comodel_name="res.company")
    invoice_id = fields.Many2one(string="Invoice id",
                                 readonly=True,
                                 store=True,
                                 copy=True,
                                 help="Invoice id",
                                 comodel_name="account.invoice")
    payment_id = fields.Many2one(string="Payment id",
                                 readonly=True,
                                 store=True,
                                 copy=True,
                                 help="Payment id",
                                 comodel_name="account.payment")
    user_det_id = fields.Many2one(string="User Detect",
                                  track_visibility="onchange",
                                  readonly=True,
                                  store=True,
                                  copy=True,
                                  index=True,
                                  comodel_name="res.user")
    message = fields.Text(string="Message of Alert",
                          readonly=True,
                          store=True,
                          copy=True,
                          help="Enter here the message of the alert")
    message_ids = fields.one2many(string="Messages ids",
                                  store=True,
                                  comodel_name="mail.message",
                                  relation_field="res_id")
    message_channel_ids = fields.Many2one(string="Followers (Channels)",
                                          readonly=True,
                                          comodel_name="mail.channel")
    message_follower_ids = fields.one2many(string="Followers",
                                           store=True,
                                           comodel_name="mail.followers",
                                           relation_field="res_id")
    message_last_post = fields.datetime(
        string="Last Message Date",
        store=True,
        copy=True,
        help="Date of the last message posted on the record")
    message_needaction = fields.Boolean(
        string="Action Needed",
        readonly=True,
        help="If checked, new messages require your attention.If checked,")
    message_needaction_counter = fields.Integer(
        string="Number of actions",
        readonly=True,
        help="Number of messages which requires an action")
    message_partner_ids = fields.Many2many(string="Follower (Partners)",
                                           readonly=True,
                                           comodel_name="res.partner")
    message_unread = fields.Boolean(
        string="Unread Messages",
        readonly=True,
        help="If checked new messages require your attention")
    message_is_follower = fields.Boolean(string="Is Follower", readonly=True)
    message_is_needaction = fields.Boolean(string="Followers (Partners)",
                                           readonly=True)
    message_is_needaction_counter = fields.Integer(string="Number of actions",
                                                   readonly=True)
    message_is_partner_ids = fields.Many2many(string="Follower (Partners)",
                                              readonly=True)
    analysis = fields.Text(string="Analysis of Alert",
                           store=True,
                           copy=True,
                           help="Enter the analysis of the alert")
    message_unread_counter = fields.Integer(string="Unread Messages counter",
                                            readonly=True,
                                            help="Number of unread messages")
    state = fields.Selection([('1', 'Pendiente'), ('2', 'Validado'),
                              ('3', 'Bloqueado'), ('4', 'Reportado')],
                             string="State",
                             store=True,
                             copy=True)

    @api.model
    def _read_group_stage_ids(self, stages, domain, order):
        # retrieve team_id from the context and write the domain
        # - ('id', 'in', stages.ids): add columns that should be present
        # - OR ('fold', '=', False): add default columns that are not folded

        # search_domain = [('id', 'in', stages.ids)]

        # perform search
        # stage_ids = stages._search(search_domain, order=order, access_rights_uid=SUPERUSER_ID)
        stage_ids = self.env['x_360fin.alerta.stage'].search([])
        return stage_ids
        #return stages.browse(stage_ids)

    @api.multi
    def _compute_kanban_state(self):
        today = date.today()
        for alerta in self:
            kanban_state = 'grey'
            if alerta.date_deadline:
                alerta_date = fields.Date.from_string(alerta.date_deadline)
                if alerta_date >= today:
                    kanban_state = 'green'
                else:
                    kanban_state = 'red'
            alerta.kanban_state = kanban_state

    @api.depends('date_open')
    def _compute_day_open(self):
        """ Compute difference between create date and open date """
        for alerta in self.filtered(lambda l: l.date_open):
            date_create = fields.Datetime.from_string(alerta.create_date)
            date_open = fields.Datetime.from_string(alerta.date_open)
            alerta.day_open = abs((date_open - date_create).days)

    @api.depends('date_closed')
    def _compute_day_close(self):
        """ Compute difference between current date and log date """
        for alerta in self.filtered(lambda l: l.date_closed):
            date_create = fields.Datetime.from_string(alerta.create_date)
            date_close = fields.Datetime.from_string(alerta.date_closed)
            alerta.day_close = abs((date_close - date_create).days)

    @api.model
    def _onchange_stage_id_values(self, stage_id):
        """ returns the new values when stage_id has changed """
        if not stage_id:
            return {}
        stage = self.env['x_360fin.alerta.stage'].browse(stage_id)
        return {}

    @api.onchange('stage_id')
    def _onchange_stage_id(self):
        values = self._onchange_stage_id_values(self.stage_id.id)
        self.update(values)

    def _onchange_partner_id_values(self, partner_id):
        """ returns the new values when partner_id has changed """

        return {}

    @api.model
    def _onchange_user_values(self, user_id):
        """ returns new values when user_id has changed """
        return {}

    @api.onchange('user_id')
    def _onchange_user_id(self):
        """ When changing the user, also set a team_id or restrict team id to the ones user_id is member of. """
        values = self._onchange_user_values(self.user_id.id)
        self.update(values)

    @api.multi
    def action_set_active(self):
        return self.write({'active': True})

    @api.multi
    def action_set_unactive(self):
        return self.write({'active': False})

    def _stage_find(self, domain=None, order='sequence'):
        """ Determine the stage of the current lead with its teams, the given domain and the given team_id
            :param domain : base search domain for stage
            :returns 360fin.alerta.stage recordset
        """
        # AND with the domain in parameter
        # if domain:
        #    search_domain += list(domain)
        # perform search, return the first found
        return self.env['x_360fin.alerta.stage'].search([], limit=1)