예제 #1
0
class product_product(osv.osv):
    _inherit = 'product.template'
    _columns = {
        'life_time':
        fields.integer(
            'Product Life Time',
            help=
            'When a new a Serial Number is issued, this is the number of days before the goods may become dangerous and must not be consumed.'
        ),
        'use_time':
        fields.integer(
            'Product Use Time',
            help=
            'When a new a Serial Number is issued, this is the number of days before the goods starts deteriorating, without being dangerous yet.'
        ),
        'removal_time':
        fields.integer(
            'Product Removal Time',
            help=
            'When a new a Serial Number is issued, this is the number of days before the goods should be removed from the stock.'
        ),
        'alert_time':
        fields.integer(
            'Product Alert Time',
            help=
            'When a new a Serial Number is issued, this is the number of days before an alert should be notified.'
        ),
    }
예제 #2
0
파일: test_models.py 프로젝트: LiberTang0/5
class preview_model(orm.Model):
    _name = name('preview')

    _columns = {
        'name': fields.char('Name'),
        'somevalue': fields.integer('Some Value', required=True),
        'othervalue': fields.integer('Other Variable'),
    }
예제 #3
0
class MassMailingReport(osv.Model):
    _name = 'mail.statistics.report'
    _auto = False
    _description = 'Mass Mailing Statistics'

    _columns = {
        'scheduled_date':
        fields.datetime('Scheduled Date', readonly=True),
        'name':
        fields.char('Mass Mail', readonly=True),
        'campaign':
        fields.char('Mass Mail Campaign', readonly=True),
        'sent':
        fields.integer('Sent', readonly=True),
        'delivered':
        fields.integer('Delivered', readonly=True),
        'opened':
        fields.integer('Opened', readonly=True),
        'bounced':
        fields.integer('Bounced', readonly=True),
        'replied':
        fields.integer('Replied', readonly=True),
        'state':
        fields.selection(
            [('draft', 'Draft'), ('test', 'Tested'), ('done', 'Sent')],
            string='Status',
            readonly=True,
        ),
        'email_from':
        fields.char('From', readonly=True),
    }

    def init(self, cr):
        """Mass Mail Statistical Report: based on mail.mail.statistics that models the various
        statistics collected for each mailing, and mail.mass_mailing model that models the
        various mailing performed. """
        tools.drop_view_if_exists(cr, 'mail_statistics_report')
        cr.execute("""
            CREATE OR REPLACE VIEW mail_statistics_report AS (
                SELECT
                    min(ms.id) as id,
                    ms.scheduled as scheduled_date,
                    mm.name as name,
                    mc.name as campaign,
                    count(ms.bounced) as bounced,
                    count(ms.sent) as sent,
                    (count(ms.sent) - count(ms.bounced)) as delivered,
                    count(ms.opened) as opened,
                    count(ms.replied) as replied,
                    mm.state,
                    mm.email_from
                FROM
                    mail_mail_statistics as ms
                    left join mail_mass_mailing as mm ON (ms.mass_mailing_id=mm.id)
                    left join mail_mass_mailing_campaign as mc ON (ms.mass_mailing_campaign_id=mc.id)
                GROUP BY ms.scheduled, mm.name, mc.name, mm.state, mm.email_from
            )""")
예제 #4
0
파일: workflow.py 프로젝트: LiberTang0/5
class wkf_triggers(osv.osv):
    _table = "wkf_triggers"
    _name = "workflow.triggers"
    _log_access = False
    _columns = {
        'res_id':
        fields.integer('Resource ID', size=128),
        'model':
        fields.char('Object'),
        'instance_id':
        fields.many2one('workflow.instance',
                        'Destination Instance',
                        ondelete="cascade"),
        'workitem_id':
        fields.many2one('workflow.workitem',
                        'Workitem',
                        required=True,
                        ondelete="cascade"),
    }

    def _auto_init(self, cr, context=None):
        super(wkf_triggers, self)._auto_init(cr, context)
        cr.execute(
            'SELECT indexname FROM pg_indexes WHERE indexname = \'wkf_triggers_res_id_model_index\''
        )
        if not cr.fetchone():
            cr.execute(
                'CREATE INDEX wkf_triggers_res_id_model_index ON wkf_triggers (res_id, model)'
            )
예제 #5
0
class hr_holidays_remaining_leaves_user(osv.osv):
    _name = "hr.holidays.remaining.leaves.user"
    _description = "Total holidays by type"
    _auto = False
    _columns = {
        'name': fields.char('Employee'),
        'no_of_leaves': fields.integer('Remaining leaves'),
        'user_id': fields.many2one('res.users', 'User'),
        'leave_type': fields.char('Leave Type'),
        }

    def init(self, cr):
        tools.drop_view_if_exists(cr, 'hr_holidays_remaining_leaves_user')
        cr.execute("""
            CREATE or REPLACE view hr_holidays_remaining_leaves_user as (
                 SELECT
                    min(hrs.id) as id,
                    rr.name as name,
                    sum(hrs.number_of_days) as no_of_leaves,
                    rr.user_id as user_id,
                    hhs.name as leave_type
                FROM
                    hr_holidays as hrs, hr_employee as hre,
                    resource_resource as rr,hr_holidays_status as hhs
                WHERE
                    hrs.employee_id = hre.id and
                    hre.resource_id =  rr.id and
                    hhs.id = hrs.holiday_status_id
                GROUP BY
                    rr.name,rr.user_id,hhs.name
            )
        """)
예제 #6
0
파일: workflow.py 프로젝트: LiberTang0/5
class wkf_transition(osv.osv):
    _table = "wkf_transition"
    _name = "workflow.transition"
    _rec_name = 'signal'
    _columns = {
        'trigger_model': fields.char('Trigger Object'),
        'trigger_expr_id': fields.char('Trigger Expression'),
        'sequence': fields.integer('Sequence'),
        'signal': fields.char('Signal (Button Name)',
                              help="When the operation of transition comes from a button pressed in the client form, "\
                              "signal tests the name of the pressed button. If signal is NULL, no button is necessary to validate this transition."),
        'group_id': fields.many2one('res.groups', 'Group Required',
                                   help="The group that a user must have to be authorized to validate this transition."),
        'condition': fields.char('Condition', required=True,
                                 help="Expression to be satisfied if we want the transition done."),
        'act_from': fields.many2one('workflow.activity', 'Source Activity', required=True, select=True, ondelete='cascade',
                                    help="Source activity. When this activity is over, the condition is tested to determine if we can start the ACT_TO activity."),
        'act_to': fields.many2one('workflow.activity', 'Destination Activity', required=True, select=True, ondelete='cascade',
                                  help="The destination activity."),
        'wkf_id': fields.related('act_from','wkf_id', type='many2one', relation='workflow', string='Workflow', select=True),
    }
    _defaults = {
        'condition': lambda *a: 'True',
        'sequence': 10,
    }

    _order = 'sequence,id'

    def name_get(self, cr, uid, ids, context=None):
        return [(line.id, (line.act_from.name) + '+' +
                 (line.act_to.name)) if line.signal == False else
                (line.id, line.signal)
                for line in self.browse(cr, uid, ids, context=context)]

    def name_search(self,
                    cr,
                    user,
                    name,
                    args=None,
                    operator='ilike',
                    context=None,
                    limit=100):
        if args is None:
            args = []
        if name:
            ids = self.search(cr,
                              user,
                              [
                                  '|', ('act_from', operator, name),
                                  ('act_to', operator, name)
                              ] + args,
                              limit=limit)
            return self.name_get(cr, user, ids, context=context)
        return super(wkf_transition, self).name_search(cr,
                                                       user,
                                                       name,
                                                       args=args,
                                                       operator=operator,
                                                       context=context,
                                                       limit=limit)
예제 #7
0
class ResPartner(osv.Model):
    _inherit = 'res.partner'

    _columns = {
        'id': fields.integer('Id', readonly=True),
        'create_date': fields.datetime('Create Date', readonly=True),
    }
예제 #8
0
파일: models.py 프로젝트: ecoreos/hz
class One2ManyChild(orm.Model):
    _name = 'export.one2many.child'
    # FIXME: orm.py:1161, fix to name_get on m2o field
    _rec_name = 'value'

    _columns = {
        'parent_id': fields.many2one('export.one2many'),
        'str': fields.char('unknown', size=None),
        'value': fields.integer(),
    }

    def name_get(self, cr, uid, ids, context=None):
        return [(record.id, "%s:%s" % (self._name, record.value))
                for record in self.browse(cr, uid, ids, context=context)]

    def name_search(self,
                    cr,
                    user,
                    name='',
                    args=None,
                    operator='ilike',
                    context=None,
                    limit=100):
        if isinstance(name, basestring) and name.split(':')[0] == self._name:
            ids = self.search(cr, user,
                              [['value', operator,
                                int(name.split(':')[1])]])
            return self.name_get(cr, user, ids, context=context)
        else:
            return []
예제 #9
0
파일: auth_oauth.py 프로젝트: LiberTang0/5
class auth_oauth_provider(osv.osv):
    """Class defining the configuration values of an OAuth2 provider"""

    _name = 'auth.oauth.provider'
    _description = 'OAuth2 provider'
    _order = 'name'

    _columns = {
        'name':
        fields.char('Provider name',
                    required=True),  # Name of the OAuth2 entity, Google, etc
        'client_id': fields.char('Client ID'),  # Our identifier
        'auth_endpoint':
        fields.char('Authentication URL',
                    required=True),  # OAuth provider URL to authenticate users
        'scope': fields.char('Scope'),  # OAUth user data desired to access
        'validation_endpoint':
        fields.char('Validation URL',
                    required=True),  # OAuth provider URL to validate tokens
        'data_endpoint': fields.char('Data URL'),
        'enabled': fields.boolean('Allowed'),
        'css_class': fields.char('CSS class'),
        'body': fields.char('Body', required=True),
        'sequence': fields.integer(),
    }
    _defaults = {
        'enabled': False,
        'css_class': "zocial",
    }
예제 #10
0
파일: ir_logging.py 프로젝트: LiberTang0/5
class ir_logging(osv.Model):
    _name = 'ir.logging'
    _order = 'id DESC'

    EXCEPTIONS_TYPE = [('client', 'Client'), ('server', 'Server')]

    _columns = {
        'create_date':
        fields.datetime('Create Date', readonly=True),
        'create_uid':
        fields.integer('Uid',
                       readonly=True),  # Integer not m2o is intentionnal
        'name':
        fields.char('Name', required=True),
        'type':
        fields.selection(EXCEPTIONS_TYPE,
                         string='Type',
                         required=True,
                         select=True),
        'dbname':
        fields.char('Database Name', select=True),
        'level':
        fields.char('Level', select=True),
        'message':
        fields.text('Message', required=True),
        'path':
        fields.char('Path', required=True),
        'func':
        fields.char('Function', required=True),
        'line':
        fields.char('Line', required=True),
    }
예제 #11
0
파일: models.py 프로젝트: ecoreos/hz
    class NewModel(orm.Model):
        _name = 'export.%s' % name
        _columns = {
            'const': fields.integer(),
            'value': field,
        }
        _defaults = {
            'const': 4,
        }

        def name_get(self, cr, uid, ids, context=None):
            return [(record.id, "%s:%s" % (self._name, record.value))
                    for record in self.browse(cr, uid, ids, context=context)]

        def name_search(self,
                        cr,
                        user,
                        name='',
                        args=None,
                        operator='ilike',
                        context=None,
                        limit=100):
            if isinstance(name,
                          basestring) and name.split(':')[0] == self._name:
                ids = self.search(
                    cr, user, [['value', operator,
                                int(name.split(':')[1])]])
                return self.name_get(cr, user, ids, context=context)
            else:
                return []
예제 #12
0
파일: test_models.py 프로젝트: LiberTang0/5
class o2m_child(orm.Model):
    _name = name('o2m.child')

    _columns = {
        'parent_id': fields.many2one(name('o2m')),
        'value': fields.integer()
    }
예제 #13
0
class product_price_list(osv.osv_memory):
    _name = 'product.price_list'
    _description = 'Price List'

    _columns = {
        'price_list':
        fields.many2one('product.pricelist', 'PriceList', required=True),
        'qty1':
        fields.integer('Quantity-1'),
        'qty2':
        fields.integer('Quantity-2'),
        'qty3':
        fields.integer('Quantity-3'),
        'qty4':
        fields.integer('Quantity-4'),
        'qty5':
        fields.integer('Quantity-5'),
    }
    _defaults = {
        'qty1': 1,
        'qty2': 5,
        'qty3': 10,
        'qty4': 0,
        'qty5': 0,
    }

    def print_report(self, cr, uid, ids, context=None):
        """
        To get the date and print the report
        @return : return report
        """
        if context is None:
            context = {}
        datas = {'ids': context.get('active_ids', [])}
        res = self.read(cr,
                        uid,
                        ids,
                        ['price_list', 'qty1', 'qty2', 'qty3', 'qty4', 'qty5'],
                        context=context)
        res = res and res[0] or {}
        res['price_list'] = res['price_list'][0]
        datas['form'] = res
        return self.pool['report'].get_action(cr,
                                              uid, [],
                                              'product.report_pricelist',
                                              data=datas,
                                              context=context)
예제 #14
0
class res_partner_activation(osv.osv):
    _name = 'res.partner.activation'
    _order = 'sequence'

    _columns = {
        'sequence': fields.integer('Sequence'),
        'name': fields.char('Name', required=True),
    }
예제 #15
0
파일: test_models.py 프로젝트: LiberTang0/5
class m2o_required_related(orm.Model):
    _name = name('m2o.required.related')

    _columns = {
        'value': fields.integer()
    }
    _defaults = {
        'value': 42
    }
예제 #16
0
파일: models.py 프로젝트: ecoreos/hz
class OnlyOne(orm.Model):
    _name = 'export.unique'

    _columns = {
        'value': fields.integer(),
    }
    _sql_constraints = [
        ('value_unique', 'unique (value)', "The value must be unique"),
    ]
예제 #17
0
class res_partner_grade(osv.osv):
    _order = 'sequence'
    _name = 'res.partner.grade'
    _columns = {
        'sequence':
        fields.integer('Sequence'),
        'active':
        fields.boolean('Active'),
        'name':
        fields.char('Level Name'),
        'partner_weight':
        fields.integer(
            'Level Weight',
            help=
            "Gives the probability to assign a lead to this partner. (0 means no assignation.)"
        ),
    }
    _defaults = {'active': lambda *args: 1, 'partner_weight': 1}
예제 #18
0
파일: models.py 프로젝트: ecoreos/hz
class SelectionWithDefault(orm.Model):
    _name = 'export.selection.withdefault'
    _columns = {
        'const': fields.integer(),
        'value': fields.selection([(1, "Foo"), (2, "Bar")]),
    }
    _defaults = {
        'const': 4,
        'value': 2,
    }
예제 #19
0
파일: note.py 프로젝트: LiberTang0/5
class note_tag(osv.osv):
    _name = "note.tag"
    _description = "Note Tag"
    _columns = {
        'name': fields.char('Tag Name', required=True),
        'color': fields.integer('Color Index'),
    }
    _sql_constraints = [
        ('name_uniq', 'unique (name)', "Tag name already exists !"),
    ]
예제 #20
0
파일: models.py 프로젝트: ecoreos/hz
class One2ManyMultiple(orm.Model):
    _name = 'export.one2many.multiple'
    _columns = {
        'parent_id': fields.many2one('export.one2many.recursive'),
        'const': fields.integer(),
        'child1': fields.one2many('export.one2many.child.1', 'parent_id'),
        'child2': fields.one2many('export.one2many.child.2', 'parent_id'),
    }
    _defaults = {
        'const': 36,
    }
예제 #21
0
class res_request_link(osv.osv):
    _name = 'res.request.link'
    _columns = {
        'name': fields.char('Name', required=True, translate=True),
        'object': fields.char('Object', required=True),
        'priority': fields.integer('Priority'),
    }
    _defaults = {
        'priority': 5,
    }
    _order = 'priority'
예제 #22
0
파일: workflow.py 프로젝트: LiberTang0/5
class wkf_instance(osv.osv):
    _table = "wkf_instance"
    _name = "workflow.instance"
    _rec_name = 'res_type'
    _log_access = False
    _columns = {
        'uid':
        fields.integer('User'),  # FIXME no constraint??
        'wkf_id':
        fields.many2one('workflow',
                        'Workflow',
                        ondelete='cascade',
                        select=True),
        'res_id':
        fields.integer('Resource ID'),
        'res_type':
        fields.char('Resource Object'),
        'state':
        fields.char('Status'),
        'transition_ids':
        fields.many2many('workflow.transition', 'wkf_witm_trans', 'inst_id',
                         'trans_id'),
    }

    def _auto_init(self, cr, context=None):
        super(wkf_instance, self)._auto_init(cr, context)
        cr.execute(
            'SELECT indexname FROM pg_indexes WHERE indexname = \'wkf_instance_res_type_res_id_state_index\''
        )
        if not cr.fetchone():
            cr.execute(
                'CREATE INDEX wkf_instance_res_type_res_id_state_index ON wkf_instance (res_type, res_id, state)'
            )
        cr.execute(
            'SELECT indexname FROM pg_indexes WHERE indexname = \'wkf_instance_res_id_wkf_id_index\''
        )
        if not cr.fetchone():
            cr.execute(
                'CREATE INDEX wkf_instance_res_id_wkf_id_index ON wkf_instance (res_id, wkf_id)'
            )
예제 #23
0
class MergePartnerLine(osv.TransientModel):
    _name = 'base.partner.merge.line'

    _columns = {
        'wizard_id':
        fields.many2one('base.partner.merge.automatic.wizard', 'Wizard'),
        'min_id':
        fields.integer('MinID'),
        'aggr_ids':
        fields.char('Ids', required=True),
    }

    _order = 'min_id asc'
예제 #24
0
class MassMailingTag(osv.Model):
    """Model of categories of mass mailing, i.e. marketing, newsletter, ... """
    _name = 'mail.mass_mailing.tag'
    _description = 'Mass Mailing Tag'
    _order = 'name'

    _columns = {
        'name': fields.char('Name', required=True),
        'color': fields.integer('Color Index'),
    }
    _sql_constraints = [
        ('name_uniq', 'unique (name)', "Tag name already exists !"),
    ]
예제 #25
0
class module_category(osv.osv):
    _name = "ir.module.category"
    _description = "Application"

    def _module_nbr(self, cr, uid, ids, prop, unknow_none, context):
        cr.execute(
            'SELECT category_id, COUNT(*) \
                      FROM ir_module_module \
                     WHERE category_id IN %(ids)s \
                        OR category_id IN (SELECT id \
                                             FROM ir_module_category \
                                            WHERE parent_id IN %(ids)s) \
                     GROUP BY category_id', {'ids': tuple(ids)})
        result = dict(cr.fetchall())
        for id in ids:
            cr.execute('select id from ir_module_category where parent_id=%s',
                       (id, ))
            result[id] = sum([result.get(c, 0) for (c, ) in cr.fetchall()],
                             result.get(id, 0))
        return result

    _columns = {
        'name':
        fields.char("Name", required=True, translate=True, select=True),
        'parent_id':
        fields.many2one('ir.module.category',
                        'Parent Application',
                        select=True),
        'child_ids':
        fields.one2many('ir.module.category', 'parent_id',
                        'Child Applications'),
        'module_nr':
        fields.function(_module_nbr, string='Number of Apps', type='integer'),
        'module_ids':
        fields.one2many('ir.module.module', 'category_id', 'Modules'),
        'description':
        fields.text("Description", translate=True),
        'sequence':
        fields.integer('Sequence'),
        'visible':
        fields.boolean('Visible'),
        'xml_id':
        fields.function(osv.osv.get_external_id,
                        type='char',
                        string="External ID"),
    }
    _order = 'name'

    _defaults = {
        'visible': 1,
    }
예제 #26
0
class base_gengo_translations(osv.osv_memory):
    GENGO_KEY = "Gengo.UUID"
    GROUPS = ['base.group_system']

    _name = 'base.gengo.translations'
    _columns = {
        'sync_type': fields.selection([('send', 'Send New Terms'),
                                       ('receive', 'Receive Translation'),
                                       ('both', 'Both')], "Sync Type", required=True),
        'lang_id': fields.many2one('res.lang', 'Language', required=True),
        'sync_limit': fields.integer("No. of terms to sync"),
    }
    _defaults = {
        'sync_type': 'both',
        'sync_limit': 20
    }

    def init(self, cr):
        icp = self.pool['ir.config_parameter']
        if not icp.get_param(cr, SUPERUSER_ID, self.GENGO_KEY, default=None):
            icp.set_param(cr, SUPERUSER_ID, self.GENGO_KEY, str(uuid.uuid4()), groups=self.GROUPS)

    def get_gengo_key(self, cr):
        icp = self.pool['ir.config_parameter']
        return icp.get_param(cr, SUPERUSER_ID, self.GENGO_KEY, default="Undefined")

    def gengo_authentication(self, cr, uid, context=None):
        '''
        This method tries to open a connection with Gengo. For that, it uses the Public and Private
        keys that are linked to the company (given by Gengo on subscription). It returns a tuple with
         * as first element: a boolean depicting if the authentication was a success or not
         * as second element: the connection, if it was a success, or the error message returned by
            Gengo when the connection failed.
            This error message can either be displayed in the server logs (if the authentication was called
            by the cron) or in a dialog box (if requested by the user), thus it's important to return it
            translated.
        '''
        user = self.pool.get('res.users').browse(cr, 1, uid, context=context)
        if not user.company_id.gengo_public_key or not user.company_id.gengo_private_key:
            return (False, _("Gengo `Public Key` or `Private Key` are missing. Enter your Gengo authentication parameters under `Settings > Companies > Gengo Parameters`."))
        try:
            gengo = Gengo(
                public_key=user.company_id.gengo_public_key.encode('ascii'),
                private_key=user.company_id.gengo_private_key.encode('ascii'),
                sandbox=user.company_id.gengo_sandbox,
            )
            gengo.getAccountStats()
            return (True, gengo)
        except Exception, e:
            _logger.exception('Gengo connection failed')
            return (False, _("Gengo connection failed with this message:\n``%s``") % e)
예제 #27
0
class MassMailingStage(osv.Model):
    """Stage for mass mailing campaigns. """
    _name = 'mail.mass_mailing.stage'
    _description = 'Mass Mailing Campaign Stage'
    _order = 'sequence'

    _columns = {
        'name': fields.char('Name', required=True, translate=True),
        'sequence': fields.integer('Sequence'),
    }

    _defaults = {
        'sequence': 0,
    }
예제 #28
0
파일: models.py 프로젝트: ecoreos/hz
class One2ManyChildMultiple(orm.Model):
    _name = 'export.one2many.multiple.child'
    # FIXME: orm.py:1161, fix to name_get on m2o field
    _rec_name = 'value'

    _columns = {
        'parent_id': fields.many2one('export.one2many.multiple'),
        'str': fields.char('unknown', size=None),
        'value': fields.integer(),
    }

    def name_get(self, cr, uid, ids, context=None):
        return [(record.id, "%s:%s" % (self._name, record.value))
                for record in self.browse(cr, uid, ids, context=context)]
예제 #29
0
파일: res_country.py 프로젝트: LiberTang0/5
class Country(osv.osv):
    _name = 'res.country'
    _description = 'Country'
    _columns = {
        'name': fields.char('Country Name',
                            help='The full name of the country.', required=True, translate=True),
        'code': fields.char('Country Code', size=2,
                            help='The ISO country code in two chars.\n'
                            'You can use this field for quick search.'),
        'address_format': fields.text('Address Format', help="""You can state here the usual format to use for the \
addresses belonging to this country.\n\nYou can use the python-style string patern with all the field of the address \
(for example, use '%(street)s' to display the field 'street') plus
            \n%(state_name)s: the name of the state
            \n%(state_code)s: the code of the state
            \n%(country_name)s: the name of the country
            \n%(country_code)s: the code of the country"""),
        'currency_id': fields.many2one('res.currency', 'Currency'),
        'image': fields.binary("Image", attachment=True),
        'phone_code': fields.integer('Country Calling Code'),
        'country_group_ids': fields.many2many('res.country.group', 'res_country_res_country_group_rel', 'res_country_id', 'res_country_group_id', string='Country Groups'),
        'state_ids': fields.one2many('res.country.state', 'country_id', string='States'),
    }
    _sql_constraints = [
        ('name_uniq', 'unique (name)',
            'The name of the country must be unique !'),
        ('code_uniq', 'unique (code)',
            'The code of the country must be unique !')
    ]
    _defaults = {
        'address_format': "%(street)s\n%(street2)s\n%(city)s %(state_code)s %(zip)s\n%(country_name)s",
    }
    _order = 'name'

    name_search = location_name_search

    def create(self, cursor, user, vals, context=None):
        if vals.get('code'):
            vals['code'] = vals['code'].upper()
        return super(Country, self).create(cursor, user, vals, context=context)

    def write(self, cursor, user, ids, vals, context=None):
        if vals.get('code'):
            vals['code'] = vals['code'].upper()
        return super(Country, self).write(cursor, user, ids, vals, context=context)

    def get_address_fields(self, cr, uid, ids, context=None):
        res = {}
        for country in self.browse(cr, uid, ids, context=context):
            res[country.id] = re.findall('\((.+?)\)', country.address_format)
        return res
예제 #30
0
class hr_contract_type(osv.osv):
    _name = 'hr.contract.type'
    _description = 'Contract Type'
    _order = 'sequence, id'

    _columns = {
        'name':
        fields.char('Contract Type', required=True),
        'sequence':
        fields.integer(
            'Sequence',
            help="Gives the sequence when displaying a list of Contract."),
    }
    defaults = {'sequence': 10}
예제 #31
0
from ecore.osv import orm, fields

def selection_fn(obj, cr, uid, context=None):
    return list(enumerate(["Corge", "Grault", "Wheee", "Moog"]))

def function_fn(model, cr, uid, ids, field_name, arg, context):
    return dict((id, 3) for id in ids)

def function_fn_write(model, cr, uid, id, field_name, field_value, fnct_inv_arg, context):
    """ just so CreatorCase.export can be used
    """
    pass

models = [
    ('boolean', fields.boolean()),
    ('integer', fields.integer()),
    ('float', fields.float()),
    ('decimal', fields.float(digits=(16, 3))),
    ('string.bounded', fields.char('unknown', size=16)),
    ('string.required', fields.char('unknown', size=None, required=True)),
    ('string', fields.char('unknown', size=None)),
    ('date', fields.date()),
    ('datetime', fields.datetime()),
    ('text', fields.text()),
    ('selection', fields.selection([(1, "Foo"), (2, "Bar"), (3, "Qux"), (4, '')])),
    # here use size=-1 to store the values as integers instead of strings
    ('selection.function', fields.selection(selection_fn, size=-1)),
    # just relate to an integer
    ('many2one', fields.many2one('export.integer')),
    ('one2many', fields.one2many('export.one2many.child', 'parent_id')),
    ('many2many', fields.many2many('export.many2many.other')),