odoo-9

How overwrite default function of a field in odoo new api

不问归期 提交于 2019-12-07 22:30:00
问题 I have a field that call a function to get default value (in module project_forecast): def default_user_id(self): return self.env.user if ("default_user_id" not in self.env.context) else self.env.context["default_user_id"] user_id = fields.Many2one('res.users', string="User", required=True, default=default_user_id) I create another module to inherit it and change default value of field user_id but it's not working without any error in log, how can I resolve this ? def default_user_id(self):

Show successfully message after close wizard in odoo v9

孤街醉人 提交于 2019-12-07 15:17:23
问题 What is best solution for display successfully message after close wizard in odoo 9? Any small popup in right corner? 回答1: It's not a proper answer to your question but i have faced the same problem, the problem was that i have to display "successfully submitted" message when user click on submit button on a wizard. and i have done this as my solution i have done this i have created one class for the wizard from odoo import api, fields, models, _ class CustomPopMessage(models.TransientModel):

Why are some items not translated in Odoo?

你。 提交于 2019-12-06 22:16:14
问题 I have a problem with translations in Project module. Some menu items are not translated. What could be the problem? Here project_view.xml <!-- Top menu item --> <menuitem name="Project" id="base.menu_main_pm" groups="group_project_manager,group_project_user" icon="fa-calendar" web_icon="project,static/description/icon.png" sequence="50"/> Here ru.po #. module: project #: model:ir.model,name:project.model_project_project #: model:ir.model.fields,field_description:project.field_project_task

Odoo javascript onclick event

旧城冷巷雨未停 提交于 2019-12-06 15:30:44
Is it possible create my own button and this button click call javascript function? Like simple onclick javascript method? If the answer is yes, how can I do that? I want to use "Add an item" button or create my own button that calls the same function like I click on "Add an item" button. First Create button where ever you want to create with some modifications. <button string="Click" custom="click"/> Then create one JS file that will contain following code. odoo.define('YOUR_MODULE.FILENAME', function (require) { "use strict"; var form_widget = require('web.form_widgets'); var core = require(

Odoo - Cannot loop through model records

空扰寡人 提交于 2019-12-06 15:28:02
I want to call a method every time my module gets installed or updated. Inside that method I want to loop through model records, but I'm only getting different errors. This documentation looks pretty straightforward: https://www.odoo.com/documentation/9.0/reference/orm.html But it doesn't work for me. I'm getting this error: ParseError: "'account.tax' object has no attribute '_ids'" while parsing This is how I call the method: <openerp> <data> <function model="account.tax" name="_my_method" /> </data> </openerp> I took this from the first answer here: https://www.odoo.com/forum/help-1/question

How to override method of BaseModel (openerp/models.py) in odoo v9?

拈花ヽ惹草 提交于 2019-12-06 14:16:06
I want to override a function called 'user_has_groups' in the class from the file openerp/models.py (line no 1365) I tried the code from this post and this question from openerp.models import BaseModel def my_user_has_groups(self, cr, uid, groups, context=None): #my code BaseModel.user_has_groups = my_user_has_groups But it results the following error. TypeError: my_user_has_groups() takes at least 4 arguments (2 given) and also i tried this line BaseModel.user_has_groups = lambda cr, uid, groups, context: my_user_has_groups(cr, uid, groups, context) It results the following error

how to get available quantity of Lot number

筅森魡賤 提交于 2019-12-06 09:29:16
问题 how to get available quantity of Lot number in multiple warehouse suppose i have 3 warehouse A,B and C, Lot number LOT0001 i want sum of total currently availabel quantity of LOT0001 in all three location. 回答1: In odoo you can pass filters in context. ex: context= {'lot_id':'','owner_id':'','package_id':'','warehouse':'','force_company':'','location':''} product.with_context(context).qty_available In odoo base module system will automatically calculate quantity based on context. If you not

Get number of sheet excel in python

不想你离开。 提交于 2019-12-06 08:10:20
问题 How get number of sheet in below python example? file = self.excel_file.decode('base64') excel_fileobj = TemporaryFile('wb+') excel_fileobj.write(file) excel_fileobj.seek(0) workbook = openpyxl.load_workbook(excel_fileobj, data_only=True) sheet_number= ??? sheet = workbook[workbook.get_sheet_names()[0]] for row in sheet.rows: print(row[1].value) sheet_number=???? Any solutin? 回答1: workbook.worksheets contains a list of worksheet objects. To get the number of worksheets: sheet_number = len

How overwrite default function of a field in odoo new api

眉间皱痕 提交于 2019-12-06 06:21:28
I have a field that call a function to get default value (in module project_forecast): def default_user_id(self): return self.env.user if ("default_user_id" not in self.env.context) else self.env.context["default_user_id"] user_id = fields.Many2one('res.users', string="User", required=True, default=default_user_id) I create another module to inherit it and change default value of field user_id but it's not working without any error in log, how can I resolve this ? def default_user_id(self): return False You're linking a method directly on field definition. So overriding the method isn't enough

Sum times odoo 9

烂漫一生 提交于 2019-12-06 03:55:52
When use compute in tree view sum is not visible. When use onChange sum is visible any solution how fix it. I need compute after insert data from .csv automaticly populate time_total fields. Example: Source: class my_data(models.Model): _name = "my.data" _description = "My Data" user = fields.Char(string = 'User') date = fields.Date(string = 'Date') start_time = fields.Datetime(string='Start', placeholder="Start", default="2016-01-01 00:00:00.624139") finish_time = fields.Datetime(string='Finish', placeholder="Finish", default="2016-01-01 00:00:00.624139") total_time = fields.Float(string=