class TwitterClient(osv.osv): _inherit = "website" _columns = { 'twitter_api_key': fields.char('Twitter API key', help="Twitter API Key"), 'twitter_api_secret': fields.char('Twitter API secret', help="Twitter API Secret"), 'twitter_screen_name': fields.char('Get favorites from this screen name'), } def _request(self, website, url, params=None): """Send an authenticated request to the Twitter API.""" access_token = self._get_access_token(website) if params: params = werkzeug.url_encode(params) url = url + '?' + params try: request = Request(url) request.add_header('Authorization', 'Bearer %s' % access_token) return json.load(urlopen(request, timeout=URLOPEN_TIMEOUT)) except HTTPError, e: _logger.debug( "Twitter API request failed with code: %r, msg: %r, content: %r", e.code, e.msg, e.fp.read()) raise
class report_intrastat_code(osv.osv): _name = "report.intrastat.code" _description = "Intrastat code" _translate = False _columns = { 'name': fields.char('Intrastat Code'), 'description': fields.char('Description'), }
class hr_contract(osv.osv): _inherit = 'hr.contract' _columns = { 'qualif': fields.char('Qualification'), 'niveau': fields.char('Niveau'), 'coef': fields.char('Coefficient'), }
class product_removal_strategy(osv.osv): _name = 'product.removal' _description = 'Removal Strategy' _columns = { 'name': fields.char('Name', required=True), 'method': fields.char("Method", required=True, help="FIFO, LIFO..."), }
class oauth_provider_entity_extend(osv.Model): _name = 'oauth_provider_entity_extend' _columns = { 'res_user_id':fields.many2one('res.users','user_id'), 'oauth_provider_id': fields.many2one('auth.oauth.provider', 'OAuth Provider'), 'oauth_uid': fields.char('OAuth User ID', help="Oauth Provider user_id", copy=False), 'oauth_access_token': fields.char('OAuth Access Token', readonly=True, copy=False), }
class HeaderImage(osv.osv): """Logo allows you to define multiple logo per company""" _name = "ir.header_img" _columns = { 'company_id' : fields.many2one('res.company', 'Company'), 'img' : fields.binary('Image', attachment=True), 'name' : fields.char('Name', required =True, help="Name of Image"), 'type' : fields.char('Type', required =True, help="Image type(png,gif,jpeg)") }
class crm_team(osv.Model): _name = "crm.team" _inherit = ['mail.thread', 'ir.needaction_mixin'] _description = "Sales Team" _order = "name" _period_number = 5 def _get_default_team_id(self, cr, uid, context=None, user_id=None): if context is None: context = {} if user_id is None: user_id = uid team_id = context.get('default_team_id') if not team_id: team_ids = self.search(cr, uid, [ '|', ('user_id', '=', user_id), ('member_ids', 'in', user_id) ], limit=1, context=context) team_id = team_ids[0] if team_ids else False if not team_id: team_id = self.pool['ir.model.data'].xmlid_to_res_id( cr, uid, 'sales_team.team_sales_department') return team_id _columns = { 'name': fields.char('Sales Team', size=64, required=True, translate=True), 'code': fields.char('Code', size=8), 'active': fields.boolean('Active', help="If the active field is set to "\ "false, it will allow you to hide the sales team without removing it."), 'company_id': fields.many2one('res.company', 'Company'), 'user_id': fields.many2one('res.users', 'Team Leader'), 'member_ids': fields.one2many('res.users', 'sale_team_id', 'Team Members'), 'reply_to': fields.char('Reply-To', size=64, help="The email address put in the 'Reply-To' of all emails sent by YuanCloud about cases in this sales team"), 'working_hours': fields.float('Working Hours', digits=(16, 2)), 'color': fields.integer('Color Index'), } _defaults = { 'active': 1, 'company_id': lambda self, cr, uid, context: self.pool.get('res.company'). _company_default_get(cr, uid, 'crm.team', context=context), } _sql_constraints = [('code_uniq', 'unique (code)', 'The code of the sales team must be unique !')] def create(self, cr, uid, values, context=None): if context is None: context = {} context['mail_create_nosubscribe'] = True return super(crm_team, self).create(cr, uid, values, context=context)
class report_document_user(osv.osv): _name = "report.document.user" _description = "Files details by Users" _auto = False _columns = { 'name': fields.char('Year', size=64, readonly=True), 'month': fields.selection([('01', 'January'), ('02', 'February'), ('03', 'March'), ('04', 'April'), ('05', 'May'), ('06', 'June'), ('07', 'July'), ('08', 'August'), ('09', 'September'), ('10', 'October'), ('11', 'November'), ('12', 'December')], 'Month', readonly=True), 'user_id': fields.many2one('res.users', 'Owner', readonly=True), 'user': fields.related('user_id', 'name', type='char', size=64, readonly=True), 'directory': fields.char('Directory', size=64, readonly=True), 'datas_fname': fields.char('File Name', size=64, readonly=True), 'create_date': fields.datetime('Date Created', readonly=True), 'change_date': fields.datetime('Modified Date', readonly=True), 'file_size': fields.integer('File Size', readonly=True), 'nbr': fields.integer('# of Files', readonly=True), 'type': fields.char('Directory Type', size=64, readonly=True), } def init(self, cr): tools.drop_view_if_exists(cr, 'report_document_user') cr.execute(""" CREATE OR REPLACE VIEW report_document_user as ( SELECT min(f.id) as id, to_char(f.create_date, 'YYYY') as name, to_char(f.create_date, 'MM') as month, f.user_id as user_id, count(*) as nbr, d.name as directory, f.datas_fname as datas_fname, f.create_date as create_date, f.file_size as file_size, min(d.type) as type, f.write_date as change_date FROM ir_attachment f left join document_directory d on (f.parent_id=d.id and d.name<>'') group by to_char(f.create_date, 'YYYY'), to_char(f.create_date, 'MM'),d.name,f.parent_id,d.type,f.create_date,f.user_id,f.file_size,d.type,f.write_date,f.datas_fname ) """)
class res_company(osv.osv): _inherit = 'res.company' _columns = { 'plafond_secu': fields.float('Plafond de la Securite Sociale', digits_compute=dp.get_precision('Payroll')), 'nombre_employes': fields.integer('Nombre d\'employes'), 'cotisation_prevoyance': fields.float('Cotisation Patronale Prevoyance', digits_compute=dp.get_precision('Payroll')), 'org_ss': fields.char('Organisme de securite sociale'), 'conv_coll': fields.char('Convention collective'), }
class MassMailingList(osv.Model): """Model of a contact list. """ _name = 'mail.mass_mailing.list' _order = 'name' _description = 'Mailing List' def _get_contact_nbr(self, cr, uid, ids, name, arg, context=None): result = dict.fromkeys(ids, 0) Contacts = self.pool.get('mail.mass_mailing.contact') for group in Contacts.read_group(cr, uid, [('list_id', 'in', ids), ('opt_out', '!=', True)], ['list_id'], ['list_id'], context=context): result[group['list_id'][0]] = group['list_id_count'] return result _columns = { 'name': fields.char('Mailing List', required=True), 'active': fields.boolean('Active'), 'create_date': fields.datetime('Creation Date'), 'contact_nbr': fields.function( _get_contact_nbr, type='integer', string='Number of Contacts', ), 'popup_content': fields.html("Website Popup Content", translate=True, required=True, sanitize=False), 'popup_redirect_url': fields.char("Website Popup Redirect URL"), } def _get_default_popup_content(self, cr, uid, context=None): return """<div class="modal-header text-center"> <h3 class="modal-title mt8">YuanCloud Presents</h3> </div> <div class="o_popup_message"> <font>7</font> <strong>Business Hacks</strong> <span> to<br/>boost your marketing</span> </div> <p class="o_message_paragraph">Join our Marketing newsletter and get <strong>this white paper instantly</strong></p>""" _defaults = { 'active': True, 'popup_content': _get_default_popup_content, 'popup_redirect_url': '/', }
class account_chart_template(osv.osv): _inherit = 'account.chart.template' _columns = { 'name': fields.char('Name', required=True, translate=True), 'spoken_languages': fields.char( 'Spoken Languages', help= "State here the languages for which the translations of templates could be loaded at the time of installation of this localization module and copied in the final object when generating them from templates. You must provide the language codes separated by ';'" ), } _order = 'name'
class mrp_operations_operation_code(osv.osv): _name = "mrp_operations.operation.code" _columns = { 'name': fields.char('Operation Name', required=True), 'code': fields.char('Code', size=16, required=True), 'start_stop': fields.selection([('start', 'Start'), ('pause', 'Pause'), ('resume', 'Resume'), ('cancel', 'Cancelled'), ('done', 'Done')], 'Status', required=True), }
class res_users(osv.osv): _inherit = 'res.users' _columns = { 'pos_security_pin': fields.char( 'Security PIN', size=32, help= 'A Security PIN used to protect sensible functionality in the Point of Sale' ), 'pos_config': fields.many2one('pos.config', 'Default Point of Sale', domain=[('state', '=', 'active')]), } def _check_pin(self, cr, uid, ids, context=None): for user in self.browse(cr, uid, ids, context=context): if user.pos_security_pin and not user.pos_security_pin.isdigit(): return False return True _constraints = [ (_check_pin, "Security PIN can only contain digits", ['pos_security_pin']), ]
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 []
class product_putaway_strategy(osv.osv): _name = 'product.putaway' _description = 'Put Away Strategy' def _get_putaway_options(self, cr, uid, context=None): return [('fixed', 'Fixed Location')] _columns = { 'name': fields.char('Name', required=True), 'method': fields.selection(_get_putaway_options, "Method", required=True), 'fixed_location_ids': fields.one2many( 'stock.fixed.putaway.strat', 'putaway_id', 'Fixed Locations Per Product Category', help= "When the method is fixed, this location will be used to store the products", copy=True), } _defaults = { 'method': 'fixed', } def putaway_apply(self, cr, uid, putaway_strat, product, context=None): if putaway_strat.method == 'fixed': for strat in putaway_strat.fixed_location_ids: categ = product.categ_id while categ: if strat.category_id.id == categ.id: return strat.fixed_location_id.id categ = categ.parent_id
class task(osv.osv): _name = "project.task" _inherit = ["project.task", 'pad.common'] _columns = { 'description_pad': fields.char('Pad URL', pad_content_field='description') }
class resource_calendar_leaves(osv.osv): _name = "resource.calendar.leaves" _description = "Leave Detail" _columns = { 'name' : fields.char("Name"), 'company_id' : fields.related('calendar_id','company_id',type='many2one',relation='res.company',string="Company", store=True, readonly=True), 'calendar_id' : fields.many2one("resource.calendar", "Working Time"), 'date_from' : fields.datetime('Start Date', required=True), 'date_to' : fields.datetime('End Date', required=True), 'resource_id' : fields.many2one("resource.resource", "Resource", help="If empty, this is a generic holiday for the company. If a resource is set, the holiday/leave is only for this resource"), } def check_dates(self, cr, uid, ids, context=None): for leave in self.browse(cr, uid, ids, context=context): if leave.date_from and leave.date_to and leave.date_from > leave.date_to: return False return True _constraints = [ (check_dates, 'Error! leave start-date must be lower then leave end-date.', ['date_from', 'date_to']) ] def onchange_resource(self, cr, uid, ids, resource, context=None): result = {} if resource: resource_pool = self.pool.get('resource.resource') result['calendar_id'] = resource_pool.browse(cr, uid, resource, context=context).calendar_id.id return {'value': result} return {'value': {'calendar_id': []}}
class TestFunctionNoInfiniteRecursion(osv.Model): _name = 'test_old_api.function_noinfiniterecursion' def _compute_f1(self, cr, uid, ids, fname, arg, context=None): res = {} for tf in self.browse(cr, uid, ids, context=context): res[tf.id] = 'create' in tf.f0 and 'create' or 'write' cntobj = self.pool['test_old_api.function_counter'] cnt_id = self.pool['ir.model.data'].xmlid_to_res_id( cr, uid, 'test_new_api.c1') cntobj.write(cr, uid, cnt_id, {'access': datetime.datetime.now()}, context=context) return res _columns = { 'f0': fields.char('Char Field'), 'f1': fields.function(_compute_f1, type='char', string='Function Field', store=True), }
class report_workcenter_load(osv.osv): _name = "report.workcenter.load" _description = "Work Center Load" _auto = False _log_access = False _columns = { 'name': fields.char('Week', required=True), 'workcenter_id': fields.many2one('mrp.workcenter', 'Work Center', required=True), 'cycle': fields.float('Number of Cycles'), 'hour': fields.float('Number of Hours'), } def init(self, cr): cr.execute(""" create or replace view report_workcenter_load as ( SELECT min(wl.id) as id, to_char(p.date_planned,'YYYY:mm:dd') as name, SUM(wl.hour) AS hour, SUM(wl.cycle) AS cycle, wl.workcenter_id as workcenter_id FROM mrp_production_workcenter_line wl LEFT JOIN mrp_production p ON p.id = wl.production_id GROUP BY wl.workcenter_id, to_char(p.date_planned,'YYYY:mm:dd') )""")
class utm_source(osv.Model): _name = "utm.source" _description = "Source" _rec_name = "name" _columns = { 'name': fields.char('Source Name', required=True, translate=True), }
class res_partner_tags(osv.Model): _description = 'Partner Tags - These tags can be used on website to find customers by sector, or ... ' _name = 'res.partner.tag' _inherit = 'website.published.mixin' def get_selection_class(self, cr, uid, context=None): classname = ['default', 'primary', 'success', 'warning', 'danger'] return [(x, str.title(x)) for x in classname] _columns = { 'name': fields.char('Category Name', required=True, translate=True), 'partner_ids': fields.many2many('res.partner', 'res_partner_res_partner_tag_rel', id1='tag_id', id2='partner_id', string='Partners'), 'classname': fields.selection(get_selection_class, 'Class', help="Bootstrap class to customize the color", required=True), 'active': fields.boolean('Active'), } _defaults = { 'active': True, 'website_published': True, 'classname': 'default', }
class res_partner(osv.osv): _name = "res.partner" _inherit = "res.partner" _columns = { 'nrc': fields.char('NRC', help='Registration number at the Registry of Commerce'), } def _auto_init(self, cr, context=None): result = super(res_partner, self)._auto_init(cr, context=context) # Remove constrains for vat, nrc on "commercial entities" because is not mandatory by legislation # Even that VAT numbers are unique, the NRC field is not unique, and there are certain entities that # doesn't have a NRC number plus the formatting was changed few times, so we cannot have a base rule for # checking if available and emmited by the Ministry of Finance, only online on their website. cr.execute(""" DROP INDEX IF EXISTS res_partner_vat_uniq_for_companies; DROP INDEX IF EXISTS res_partner_nrc_uniq_for_companies; """) return result def _commercial_fields(self, cr, uid, context=None): return super(res_partner, self)._commercial_fields( cr, uid, context=context) + ['nrc']
class base_config_settings(osv.TransientModel): _inherit = "base.config.settings" _columns = { 'google_drive_authorization_code': fields.char('Authorization Code'), 'google_drive_uri': fields.char( 'URI', readonly=True, help="The URL to generate the authorization code from Google"), } _defaults = { 'google_drive_uri': lambda s, cr, uid, c: s.pool['google.service']._get_google_token_uri( cr, uid, 'drive', scope=s.pool['google.drive.config'].get_google_scope(), context=c), 'google_drive_authorization_code': lambda s, cr, uid, c: s.pool['ir.config_parameter'].get_param( cr, SUPERUSER_ID, 'google_drive_authorization_code', context=c), } def set_google_authorization_code(self, cr, uid, ids, context=None): ir_config_param = self.pool['ir.config_parameter'] config = self.browse(cr, uid, ids[0], context) auth_code = config.google_drive_authorization_code if auth_code and auth_code != ir_config_param.get_param( cr, uid, 'google_drive_authorization_code', context=context): refresh_token = self.pool['google.service'].generate_refresh_token( cr, uid, 'drive', config.google_drive_authorization_code, context=context) ir_config_param.set_param(cr, uid, 'google_drive_authorization_code', auth_code, groups=['base.group_system']) ir_config_param.set_param(cr, uid, 'google_drive_refresh_token', refresh_token, groups=['base.group_system'])
class report_transaction_pos(osv.osv): _name = "report.transaction.pos" _description = "transaction for the pos" _auto = False _columns = { 'date_create': fields.char('Date', size=16, readonly=True), 'journal_id': fields.many2one('account.journal', 'Sales Journal', readonly=True), 'jl_id': fields.many2one('account.journal', 'Cash Journals', readonly=True), 'user_id': fields.many2one('res.users', 'User', readonly=True), 'no_trans': fields.float('Number of Transaction', readonly=True), 'amount': fields.float('Amount', readonly=True), 'invoice_id': fields.float('Nbr Invoice', readonly=True), 'invoice_am': fields.float('Invoice Amount', readonly=True), 'product_nb': fields.float('Product Nb.', readonly=True), 'disc': fields.float('Disc.', readonly=True), } def init(self, cr): tools.drop_view_if_exists(cr, 'report_transaction_pos') cr.execute(""" create or replace view report_transaction_pos as ( select min(absl.id) as id, count(absl.id) as no_trans, sum(absl.amount) as amount, sum((100.0-line.discount) * line.price_unit * line.qty / 100.0) as disc, to_char(date_trunc('day',absl.create_date),'YYYY-MM-DD')::text as date_create, po.user_id as user_id, po.sale_journal as journal_id, abs.journal_id as jl_id, count(po.invoice_id) as invoice_id, count(p.id) as product_nb from account_bank_statement_line as absl, account_bank_statement as abs, product_product as p, pos_order_line as line, pos_order as po where absl.pos_statement_id = po.id and line.order_id=po.id and line.product_id=p.id and absl.statement_id=abs.id group by po.user_id,po.sale_journal, abs.journal_id, to_char(date_trunc('day',absl.create_date),'YYYY-MM-DD')::text ) """)
class pay_sale_order(orm.TransientModel): _name = 'pay.sale.order' _description = 'Wizard to generate a payment from the sale order' _columns = { 'journal_id': fields.many2one('account.journal', 'Journal'), 'amount': fields.float('Amount', digits_compute=dp.get_precision('Sale Price')), 'date': fields.datetime('Payment Date'), 'description': fields.char('Description', size=64), } def _get_journal_id(self, cr, uid, context=None): if context is None: context = {} if context.get('active_id'): sale_obj = self.pool.get('sale.order') order = sale_obj.browse(cr, uid, context['active_id'], context=context) if order.payment_method_id: return order.payment_method_id.journal_id.id return False def _get_amount(self, cr, uid, context=None): if context is None: context = {} if context.get('active_id'): sale_obj = self.pool.get('sale.order') order = sale_obj.browse(cr, uid, context['active_id'], context=context) return order.residual return False _defaults = { 'journal_id': _get_journal_id, 'amount': _get_amount, 'date': fields.datetime.now, } def pay_sale_order(self, cr, uid, ids, context=None): """ Pay the sale order """ wizard = self.browse(cr, uid, ids[0], context=context) sale_obj = self.pool.get('sale.order') sale_obj.add_payment(cr, uid, context['active_id'], wizard.journal_id.id, wizard.amount, wizard.date, description=wizard.description, context=context) return {'type': 'ir.actions.act_window_close'} def pay_sale_order_and_confirm(self, cr, uid, ids, context=None): """ Pay the sale order """ self.pay_sale_order(cr, uid, ids, context=context) sale_obj = self.pool.get('sale.order') return sale_obj.action_button_confirm(cr, uid, [context['active_id']], context=context)
class account_fiscal_position_template(osv.osv): _inherit = 'account.fiscal.position.template' _columns = { 'name': fields.char('Fiscal Position Template', required=True, translate=True), 'note': fields.text('Notes', translate=True), }
class utm_campaign(osv.Model): # OLD crm.case.resource.type _name = "utm.campaign" _description = "Campaign" _rec_name = "name" _columns = { 'name': fields.char('Campaign Name', required=True, translate=True), }
class DocumentationStage(osv.Model): _name = 'forum.documentation.stage' _description = 'Post Stage' _order = 'sequence' _columns = { 'sequence': fields.integer('Sequence'), 'name': fields.char('Stage Name', required=True, translate=True), }
class HeaderHTML(osv.osv): """HTML Header allows you to define HTML CSS and Page format""" _name = "ir.header_webkit" _columns = { 'company_id' : fields.many2one('res.company', 'Company'), 'html' : fields.text('webkit header', help="Set Webkit Report Header"), 'footer_html' : fields.text('webkit footer', help="Set Webkit Report Footer."), 'css' : fields.text('Header CSS'), 'name' : fields.char('Name', required=True), 'margin_top' : fields.float('Top Margin (mm)'), 'margin_bottom' : fields.float('Bottom Margin (mm)'), 'margin_left' : fields.float('Left Margin (mm)'), 'margin_right' : fields.float('Right Margin (mm)'), 'orientation' : fields.selection( [('Landscape','Landscape'),('Portrait', 'Portrait')], 'Orientation', ), 'format': fields.selection( [ ('A0' ,'A0 5 841 x 1189 mm'), ('A1' ,'A1 6 594 x 841 mm'), ('A2' ,'A2 7 420 x 594 mm'), ('A3' ,'A3 8 297 x 420 mm'), ('A4' ,'A4 0 210 x 297 mm, 8.26 x 11.69 inches'), ('A5' ,'A5 9 148 x 210 mm'), ('A6' ,'A6 10 105 x 148 mm'), ('A7' ,'A7 11 74 x 105 mm'), ('A8' ,'A8 12 52 x 74 mm'), ('A9' ,'A9 13 37 x 52 mm'), ('B0' ,'B0 14 1000 x 1414 mm'), ('B1' ,'B1 15 707 x 1000 mm'), ('B2' ,'B2 17 500 x 707 mm'), ('B3' ,'B3 18 353 x 500 mm'), ('B4' ,'B4 19 250 x 353 mm'), ('B5' ,'B5 1 176 x 250 mm, 6.93 x 9.84 inches'), ('B6' ,'B6 20 125 x 176 mm'), ('B7' ,'B7 21 88 x 125 mm'), ('B8' ,'B8 22 62 x 88 mm'), ('B9' ,'B9 23 33 x 62 mm'), ('B10',':B10 16 31 x 44 mm'), ('C5E','C5E 24 163 x 229 mm'), ('Comm10E','Comm10E 25 105 x 241 mm, U.S. Common 10 Envelope'), ('DLE', 'DLE 26 110 x 220 mm'), ('Executive','Executive 4 7.5 x 10 inches, 190.5 x 254 mm'), ('Folio','Folio 27 210 x 330 mm'), ('Ledger', 'Ledger 28 431.8 x 279.4 mm'), ('Legal', 'Legal 3 8.5 x 14 inches, 215.9 x 355.6 mm'), ('Letter','Letter 2 8.5 x 11 inches, 215.9 x 279.4 mm'), ('Tabloid', 'Tabloid 29 279.4 x 431.8 mm'), ], 'Paper size', required=True, help="Select Proper Paper size" ) }
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 !"), ]