class res_partner(osv.osv): _inherit = "res.company" _columns = { 'geo_latitude': fields.float('维度', digits=(16, 5)), 'geo_longitude': fields.float('经度', digits=(16, 5)), 'date_localization': fields.date('更新日期'), } @api.model def tencent_map_img(self, zoom=15, width=298, height=298): params = { 'center': '%s,%s' % (str(self.geo_longitude), str(self.geo_latitude)), 'size': "%d*%d" % (width, height), 'markers': '%s,%s' % (str(self.geo_longitude), str(self.geo_latitude)), 'zoom': zoom, } return urlplus('http://st.map.qq.com/api', params) @api.model def tencent_map_link(self, zoom=10): params = { 'marker': 'coord:%s,%s;title:%s;addr:%s' % (str(self.geo_latitude), str( self.geo_longitude), self.name, self.name), } # marker=coord: return urlplus('http://apis.map.qq.com/uri/v1/marker', params)
class report_sales_by_user_pos(osv.osv): _name = "report.sales.by.user.pos" _description = "Sales by user" _auto = False _columns = { 'date_order': fields.date('Order Date', required=True, select=True), 'amount': fields.float('Total', readonly=True, select=True), 'qty': fields.float('Quantity', readonly=True, select=True), 'user_id': fields.many2one('res.users', 'User', readonly=True, select=True), } def init(self, cr): tools.drop_view_if_exists(cr, 'report_sales_by_user_pos') cr.execute(""" create or replace view report_sales_by_user_pos as ( select min(po.id) as id, to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::text as date_order, po.user_id as user_id, sum(pol.qty)as qty, sum((pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))) as amount from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id group by to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::text, po.user_id ) """)
class account_tax(osv.osv): """ Add fields used to define some brazilian taxes """ _inherit = 'account.tax' _columns = { 'tax_discount': fields.boolean('Discount this Tax in Prince', help="Mark it for (ICMS, PIS e etc.)."), 'base_reduction': fields.float('Redution', required=True, digits=0, help="Um percentual decimal em % entre 0-1."), 'amount_mva': fields.float('MVA Percent', required=True, digits=0, help="Um percentual decimal em % entre 0-1."), 'amount_type': fields.selection([('group', 'Group of Taxes'), ('fixed', 'Fixed'), ('percent', 'Percentage of Price'), ('division', 'Percentage of Price Tax Included')], string="Tax Computation", required=True) } _defaults = TAX_DEFAULTS
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 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 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 hr_contract_be(osv.osv): _inherit = 'hr.contract' _columns = { 'travel_reimbursement_amount': fields.float('Reimbursement of travel expenses', digits_compute=dp.get_precision('Payroll')), 'car_company_amount': fields.float('Company car employer', digits_compute=dp.get_precision('Payroll')), 'car_employee_deduction': fields.float('Company Car Deduction for Worker', digits_compute=dp.get_precision('Payroll')), 'misc_onss_deduction': fields.float('Miscellaneous exempt ONSS ', digits_compute=dp.get_precision('Payroll')), 'meal_voucher_amount': fields.float('Check Value Meal ', digits_compute=dp.get_precision('Payroll')), 'meal_voucher_employee_deduction': fields.float('Check Value Meal - by worker ', digits_compute=dp.get_precision('Payroll')), 'insurance_employee_deduction': fields.float('Insurance Group - by worker ', digits_compute=dp.get_precision('Payroll')), 'misc_advantage_amount': fields.float('Benefits of various nature ', digits_compute=dp.get_precision('Payroll')), 'additional_net_amount': fields.float('Net supplements', digits_compute=dp.get_precision('Payroll')), 'retained_net_amount': fields.float('Net retained ', digits_compute=dp.get_precision('Payroll')), }
class account_journal(osv.osv): _inherit = 'account.journal' _columns = { 'journal_user': fields.boolean('Active in Point of Sale', help="Check this box if this journal define a payment method that can be used in a point of sale."), 'amount_authorized_diff' : fields.float('Amount Authorized Difference', help="This field depicts the maximum difference allowed between the ending balance and the theoretical cash when closing a session, for non-POS managers. If this maximum is reached, the user will have an error message at the closing of his session saying that he needs to contact his manager."), }
class resource_resource(osv.osv): _name = "resource.resource" _description = "Resource Detail" _columns = { 'name': fields.char("Name", required=True), 'code': fields.char('Code', size=16, copy=False), 'active' : fields.boolean('Active', track_visibility='onchange', help="If the active field is set to False, it will allow you to hide the resource record without removing it."), 'company_id' : fields.many2one('res.company', 'Company'), 'resource_type': fields.selection([('user','Human'),('material','Material')], 'Resource Type', required=True), 'user_id' : fields.many2one('res.users', 'User', help='Related user name for the resource to manage its access.'), 'time_efficiency' : fields.float('Efficiency Factor', size=8, required=True, help="This field depict the efficiency of the resource to complete tasks. e.g resource put alone on a phase of 5 days with 5 tasks assigned to him, will show a load of 100% for this phase by default, but if we put a efficiency of 200%, then his load will only be 50%."), 'calendar_id' : fields.many2one("resource.calendar", "Working Time", help="Define the schedule of resource"), } _defaults = { 'resource_type' : 'user', 'time_efficiency' : 1, 'active' : True, 'company_id': lambda self, cr, uid, context: self.pool.get('res.company')._company_default_get(cr, uid, 'resource.resource', context=context) } def copy(self, cr, uid, id, default=None, context=None): if default is None: default = {} if not default.get('name', False): default.update(name=_('%s (copy)') % (self.browse(cr, uid, id, context=context).name)) return super(resource_resource, self).copy(cr, uid, id, default, context)
class pos_discount(osv.osv_memory): _name = 'pos.discount' _description = 'Add a Global Discount' _columns = { 'discount': fields.float('Discount (%)', required=True, digits=(16, 2)), } _defaults = { 'discount': 5, } def apply_discount(self, cr, uid, ids, context=None): """ To give the discount of product and check the. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return : nothing """ order_ref = self.pool.get('pos.order') order_line_ref = self.pool.get('pos.order.line') if context is None: context = {} this = self.browse(cr, uid, ids[0], context=context) record_id = context and context.get('active_id', False) if isinstance(record_id, (int, long)): record_id = [record_id] for order in order_ref.browse(cr, uid, record_id, context=context): order_line_ref.write(cr, uid, [x.id for x in order.lines], {'discount': this.discount}, context=context) return {}
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 test_converter(orm.Model): _name = 'web_editor.converter.test' # disable translation export for those brilliant field labels and values _translate = False _columns = { 'char': fields.char(), 'integer': fields.integer(), 'float': fields.float(), 'numeric': fields.float(digits=(16, 2)), 'many2one': fields.many2one('web_editor.converter.test.sub'), 'binary': fields.binary(), 'date': fields.date(), 'datetime': fields.datetime(), 'selection': fields.selection([ (1, "réponse A"), (2, "réponse B"), (3, "réponse C"), (4, "réponse D"), ]), 'selection_str': fields.selection( [ ('A', "Qu'il n'est pas arrivé à Toronto"), ('B', "Qu'il était supposé arriver à Toronto"), ('C', "Qu'est-ce qu'il fout ce maudit pancake, tabernacle ?"), ('D', "La réponse D"), ], string= u"Lorsqu'un pancake prend l'avion à destination de Toronto et " u"qu'il fait une escale technique à St Claude, on dit:"), 'html': fields.html(), 'text': fields.text(), }
class stock_move_consume(osv.osv_memory): _name = "stock.move.consume" _description = "Consume Products" _columns = { 'product_id': fields.many2one('product.product', 'Product', required=True, select=True), 'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True), 'product_uom': fields.many2one('product.uom', 'Product Unit of Measure', required=True), 'location_id': fields.many2one('stock.location', 'Location', required=True), 'restrict_lot_id': fields.many2one('stock.production.lot', 'Lot'), } #TOFIX: product_uom should not have different category of default UOM of product. Qty should be convert into UOM of original move line before going in consume and scrap def default_get(self, cr, uid, fields, context=None): if context is None: context = {} res = super(stock_move_consume, self).default_get(cr, uid, fields, context=context) move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context) if 'product_id' in fields: res.update({'product_id': move.product_id.id}) if 'product_uom' in fields: res.update({'product_uom': move.product_uom.id}) if 'product_qty' in fields: res.update({'product_qty': move.product_uom_qty}) if 'location_id' in fields: res.update({'location_id': move.location_id.id}) return res def do_move_consume(self, cr, uid, ids, context=None): if context is None: context = {} move_obj = self.pool.get('stock.move') uom_obj = self.pool.get('product.uom') production_obj = self.pool.get('mrp.production') move_ids = context['active_ids'] move = move_obj.browse(cr, uid, move_ids[0], context=context) production_id = move.raw_material_production_id.id production = production_obj.browse(cr, uid, production_id, context=context) precision = self.pool['decimal.precision'].precision_get(cr, uid, 'Product Unit of Measure') for data in self.browse(cr, uid, ids, context=context): qty = uom_obj._compute_qty(cr, uid, data['product_uom'].id, data.product_qty, data.product_id.uom_id.id) remaining_qty = move.product_qty - qty #check for product quantity is less than previously planned if float_compare(remaining_qty, 0, precision_digits=precision) >= 0: move_obj.action_consume(cr, uid, move_ids, qty, data.location_id.id, restrict_lot_id=data.restrict_lot_id.id, context=context) else: consumed_qty = min(move.product_qty, qty) new_moves = move_obj.action_consume(cr, uid, move_ids, consumed_qty, data.location_id.id, restrict_lot_id=data.restrict_lot_id.id, context=context) #consumed more in wizard than previously planned extra_more_qty = qty - consumed_qty #create new line for a remaining qty of the product extra_move_id = production_obj._make_consume_line_from_data(cr, uid, production, data.product_id, data.product_id.uom_id.id, extra_more_qty, context=context) move_obj.write(cr, uid, [extra_move_id], {'restrict_lot_id': data.restrict_lot_id.id}, context=context) move_obj.action_done(cr, uid, [extra_move_id], context=context) return {'type': 'ir.actions.act_window_close'}
class company(osv.osv): _inherit = 'res.company' _columns = { 'manufacturing_lead': fields.float('Manufacturing Lead Time', required=True, help="Security days for each manufacturing operation."), } _defaults = { 'manufacturing_lead': lambda *a: 1.0, }
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 resource_calendar_attendance(osv.osv): _name = "resource.calendar.attendance" _description = "Work Detail" _columns = { 'name' : fields.char("Name", required=True), 'dayofweek': fields.selection([('0','Monday'),('1','Tuesday'),('2','Wednesday'),('3','Thursday'),('4','Friday'),('5','Saturday'),('6','Sunday')], 'Day of Week', required=True, select=True), 'date_from' : fields.date('Starting Date'), 'date_to': fields.date('End Date'), 'hour_from' : fields.float('Work from', required=True, help="Start and End time of working.", select=True), 'hour_to' : fields.float("Work to", required=True), 'calendar_id' : fields.many2one("resource.calendar", "Resource's Calendar", required=True), } _order = 'dayofweek, hour_from' _defaults = { 'dayofweek' : '0' }
class company_geo(osv.TransientModel): _name = 'web_extended.map' _columns = { 'addr': fields.char('address'), 'company_id': fields.many2one('res.company'), 'geo_latitude': fields.float('Geo Latitude', digits=(16, 5), default=lambda self: self._get_location('geo_latitude')), 'geo_longitude': fields.float('Geo Longitude', digits=(16, 5), default=lambda self: self._get_location('geo_longitude')), 'date_localization': fields.date('Geo Localization Date', default=lambda self: datetime.datetime.now()), } @api.model def _get_location(self, field): company_id = self._context.get('active_id') if company_id: company = self.env['res.company'].search([('id', '=', company_id)]) if company: return company[field] @api.model def create(self, vals): vals['company_id'] = self._context['active_id'] return super(company_geo, self).create(vals) @api.one def apply(self): self.company_id.write({ "geo_latitude": self.geo_latitude, "geo_longitude": self.geo_longitude, "date_localization": datetime.datetime.now() })
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 mrp_repair_fee(osv.osv, ProductChangeMixin): _name = 'mrp.repair.fee' _description = 'Repair Fees Line' def _amount_line(self, cr, uid, ids, field_name, arg, context=None): """ Calculates amount. @param field_name: Name of field. @param arg: Argument @return: Dictionary of values. """ res = {} tax_obj = self.pool.get('account.tax') cur_obj = self.pool.get('res.currency') for line in self.browse(cr, uid, ids, context=context): if line.to_invoice: cur = line.repair_id.pricelist_id.currency_id taxes = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, cur.id, line.product_uom_qty, line.product_id.id, line.repair_id.partner_id.id) res[line.id] = taxes['total_included'] else: res[line.id] = 0 return res _columns = { 'repair_id': fields.many2one('mrp.repair', 'Repair Order Reference', required=True, ondelete='cascade', select=True), 'name': fields.char('Description', select=True, required=True), 'product_id': fields.many2one('product.product', 'Product'), 'product_uom_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True), 'price_unit': fields.float('Unit Price', required=True), 'product_uom': fields.many2one('product.uom', 'Product Unit of Measure', required=True), 'price_subtotal': fields.function(_amount_line, string='Subtotal', digits=0), 'tax_id': fields.many2many('account.tax', 'repair_fee_line_tax', 'repair_fee_line_id', 'tax_id', 'Taxes'), 'invoice_line_id': fields.many2one('account.invoice.line', 'Invoice Line', readonly=True, copy=False), 'to_invoice': fields.boolean('To Invoice'), 'invoiced': fields.boolean('Invoiced', readonly=True, copy=False), } _defaults = { 'to_invoice': lambda *a: True, }
class stock_landed_cost_lines(osv.osv): _name = 'stock.landed.cost.lines' _description = 'Stock Landed Cost Lines' def onchange_product_id(self, cr, uid, ids, product_id=False, context=None): result = {} if not product_id: return {'value': {'quantity': 0.0, 'price_unit': 0.0}} product = self.pool.get('product.product').browse(cr, uid, product_id, context=context) result['name'] = product.name result['split_method'] = product.split_method result['price_unit'] = product.standard_price result[ 'account_id'] = product.property_account_expense_id and product.property_account_expense_id.id or product.categ_id.property_account_expense_categ_id.id return {'value': result} _columns = { 'name': fields.char('Description'), 'cost_id': fields.many2one('stock.landed.cost', 'Landed Cost', required=True, ondelete='cascade'), 'product_id': fields.many2one('product.product', 'Product', required=True), 'price_unit': fields.float('Cost', required=True, digits_compute=dp.get_precision('Product Price')), 'split_method': fields.selection(product.SPLIT_METHOD, string='Split Method', required=True), 'account_id': fields.many2one('account.account', 'Account', domain=[('internal_type', '!=', 'view'), ('internal_type', '!=', 'closed'), ('deprecated', '=', False)]), }
class res_company(osv.osv): _inherit = 'res.company' _columns = { 'timesheet_range': fields.selection( [('day','Day'),('week','Week'),('month','Month')], 'Timesheet range', help="Periodicity on which you validate your timesheets."), 'timesheet_max_difference': fields.float('Timesheet allowed difference(Hours)', help="Allowed difference in hours between the sign in/out and the timesheet " \ "computation for one sheet. Set this to 0 if you do not want any control."), } _defaults = { 'timesheet_range': lambda *args: 'week', 'timesheet_max_difference': lambda *args: 0.0 }
class WebsiteTwitterTweet(osv.osv): _name = "website.twitter.tweet" _description = "Twitter Tweets" _columns = { 'website_id': fields.many2one('website', string="Website"), 'screen_name': fields.char("Screen Name"), 'tweet': fields.text('Tweets'), # Twitter IDs are 64-bit unsigned ints, so we need to store them in # unlimited precision NUMERIC columns, which can be done with a # float field. Used digits=(0,0) to indicate unlimited. # Using VARCHAR would work too but would have sorting problems. 'tweet_id': fields.float("Tweet ID", digits=(0, 0)), # Twitter }
class mrp_product_produce_line(osv.osv_memory): _name = "mrp.product.produce.line" _description = "Product Produce Consume lines" _columns = { 'product_id': fields.many2one('product.product', string='Product'), 'product_qty': fields.float( 'Quantity (in default UoM)', digits_compute=dp.get_precision('Product Unit of Measure')), 'lot_id': fields.many2one('stock.production.lot', string='Lot'), 'produce_id': fields.many2one('mrp.product.produce', string="Produce"), }
class stock_return_picking_line(osv.osv_memory): _name = "stock.return.picking.line" _rec_name = 'product_id' _columns = { 'product_id': fields.many2one('product.product', string="Product", required=True), 'quantity': fields.float( "Quantity", digits_compute=dp.get_precision('Product Unit of Measure'), required=True), 'wizard_id': fields.many2one('stock.return.picking', string="Wizard"), 'move_id': fields.many2one('stock.move', "Move"), }
class bid_line_qty(osv.osv_memory): _name = "bid.line.qty" _description = "Change Bid line quantity" _columns = { 'qty': fields.float( 'Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True), } def change_qty(self, cr, uid, ids, context=None): active_ids = context and context.get('active_ids', []) data = self.browse(cr, uid, ids, context=context)[0] self.pool.get('purchase.order.line').write( cr, uid, active_ids, {'quantity_tendered': data.qty}) return {'type': 'ir.actions.act_window_close'}
class oa_journal_report(osv.osv): _name = "oa.journal.report" _description = "OA Journal Statistics" _auto = False _rec_name = 'paidon' _columns = { 'create_date': fields.datetime('创建时间', readonly=True), 'invoice_type': fields.many2one('oa_journal.invoice.type', string="发票类型", readonly=True), 'total_debit': fields.float(digits=(12, 2), string="金额", readonly=True), 'mode_of_payment': fields.selection([('Cash', '现金'), ('Tenpay', '财付通支付'), ('Alipay', '支付宝支付'), ('Transfer', '网银转账'), ('Credit', '信用卡支付'), ('Wechat', '微信支付')], string="付款方式", readonly=True), 'payer_employee': fields.many2one("hr.employee", string="付款人", readonly=True), 'paidon': fields.datetime(string="付款时间", readonly=True), 'collar_employee': fields.many2one("hr.employee", "领用人", readonly=True), 'state': fields.selection([('draft', '草稿'), ('paid', '已付款'), ('received', '已收获'), ('expensed', '已报销'), ('closed', '关闭')], string="状态", readonly=True), 'ec_platform': fields.many2one("oa_journal.ecplatform", '电商平台', readonly=True) } _order = 'paidon desc' def init(self, cr): tools.drop_view_if_exists(cr, 'oa_journal_report') cr.execute(""" create or replace view oa_journal_report as ( select * from oa_journal ) """)
class report_mrp_inout(osv.osv): _name = "report.mrp.inout" _description = "Stock value variation" _auto = False _log_access = False _rec_name = 'date' _columns = { 'date': fields.char('Week', required=True), 'value': fields.float('Stock value', required=True, digits=(16, 2)), 'company_id': fields.many2one('res.company', 'Company', required=True), } def init(self, cr): cr.execute(""" create or replace view report_mrp_inout as ( select min(sm.id) as id, to_char(sm.date,'YYYY:IW') as date, sum(case when (sl.usage='internal') then sm.price_unit * sm.product_qty else 0.0 end - case when (sl2.usage='internal') then sm.price_unit * sm.product_qty else 0.0 end) as value, sm.company_id from stock_move sm left join product_product pp on (pp.id = sm.product_id) left join product_template pt on (pt.id = pp.product_tmpl_id) left join stock_location sl on ( sl.id = sm.location_id) left join stock_location sl2 on ( sl2.id = sm.location_dest_id) where sm.state = 'done' group by to_char(sm.date,'YYYY:IW'), sm.company_id )""")
class pos_config(osv.osv): _inherit = 'pos.config' _columns = { 'iface_discount': fields.boolean( 'Order Discounts', help='Allow the cashier to give discounts on the whole order.'), 'discount_pc': fields.float('Discount Percentage', help='The default discount percentage'), 'discount_product_id': fields.many2one('product.product', 'Discount Product', help='The product used to model the discount'), } _defaults = { 'iface_discount': True, 'discount_pc': 10, }
class mrp_subproduct(osv.osv): _name = 'mrp.subproduct' _description = 'Byproduct' _columns={ 'product_id': fields.many2one('product.product', 'Product', required=True), 'product_qty': fields.float('Product Qty', digits_compute=dp.get_precision('Product Unit of Measure'), required=True), 'product_uom': fields.many2one('product.uom', 'Product Unit of Measure', required=True), 'subproduct_type': fields.selection([('fixed','Fixed'),('variable','Variable')], 'Quantity Type', required=True, help="Define how the quantity of byproducts will be set on the production orders using this BoM.\ 'Fixed' depicts a situation where the quantity of created byproduct is always equal to the quantity set on the BoM, regardless of how many are created in the production order.\ By opposition, 'Variable' means that the quantity will be computed as\ '(quantity of byproduct set on the BoM / quantity of manufactured product set on the BoM * quantity of manufactured product in the production order.)'"), 'bom_id': fields.many2one('mrp.bom', 'BoM', ondelete='cascade'), } _defaults={ 'subproduct_type': 'variable', 'product_qty': lambda *a: 1.0, } def onchange_product_id(self, cr, uid, ids, product_id, context=None): """ Changes UoM if product_id changes. @param product_id: Changed product_id @return: Dictionary of changed values """ if product_id: prod = self.pool.get('product.product').browse(cr, uid, product_id, context=context) v = {'product_uom': prod.uom_id.id} return {'value': v} return {} def onchange_uom(self, cr, uid, ids, product_id, product_uom, context=None): res = {'value':{}} if not product_uom or not product_id: return res product = self.pool.get('product.product').browse(cr, uid, product_id, context=context) uom = self.pool.get('product.uom').browse(cr, uid, product_uom, context=context) if uom.category_id.id != product.uom_id.category_id.id: res['warning'] = {'title': _('Warning'), 'message': _('The Product Unit of Measure you chose has a different category than in the product form.')} res['value'].update({'product_uom': product.uom_id.id}) return res
class product_template(osv.osv): _inherit = "product.template" def _bom_orders_count(self, cr, uid, ids, field_name, arg, context=None): Bom = self.pool('mrp.bom') res = {} for product_tmpl_id in ids: nb = Bom.search_count(cr, uid, [('product_tmpl_id', '=', product_tmpl_id)], context=context) res[product_tmpl_id] = { 'bom_count': nb, } return res def _bom_orders_count_mo(self, cr, uid, ids, name, arg, context=None): res = {} for product_tmpl_id in self.browse(cr, uid, ids): res[product_tmpl_id.id] = sum([p.mo_count for p in product_tmpl_id.product_variant_ids]) return res _columns = { 'bom_ids': fields.one2many('mrp.bom', 'product_tmpl_id','Bill of Materials'), 'bom_count': fields.function(_bom_orders_count, string='# Bill of Material', type='integer', multi="_bom_order_count"), 'mo_count': fields.function(_bom_orders_count_mo, string='# Manufacturing Orders', type='integer'), 'produce_delay': fields.float('Manufacturing Lead Time', help="Average delay in days to produce this product. In the case of multi-level BOM, the manufacturing lead times of the components will be added."), } _defaults = { 'produce_delay': 1, } def action_view_mos(self, cr, uid, ids, context=None): products = self._get_products(cr, uid, ids, context=context) result = self._get_act_window_dict(cr, uid, 'mrp.act_product_mrp_production', context=context) if len(ids) == 1 and len(products) == 1: result['context'] = "{'default_product_id': " + str(products[0]) + ", 'search_default_product_id': " + str(products[0]) + "}" else: result['domain'] = "[('product_id','in',[" + ','.join(map(str, products)) + "])]" result['context'] = "{}" return result