Odoo Manufacturing Picking - Show lots having quantity greater than zero 0 - odoo

I have added a lot quantity field in Manufacturing picking operations. It is reflecting the lot quantity perfectly with respect to location. Now the problem is I do not want to show the lots having no product i.e. 0 quantity. How do I achieve this?
Here is the screenshot where I want to make changes.
Here is the model code (stock_move_line.py):
class StockMoveLine(models.Model):
_name = "stock.move.line"
_description = "Product Moves (Stock Move Line)"
_rec_name = "product_id"
_order = "result_package_id desc, id"
lot_id = fields.Many2one('stock.production.lot', 'Lot/Serial Number123')
x_lot_qty = fields.Float(compute="fetch_lot_wrt_location",
name="Lot Quantity",
store=True,
readonly=True,
digits=(12,3))
#api.onchange('lot_id','location_id')
def fetch_lot_wrt_location(self):
self.x_lot_qty = 0.0
for row in self:
quants = self.env['stock.quant'].search([('lot_id.id','=',row.lot_id.id)])
for quant in quants:
if row.location_id.display_name == quant.location_id.display_name:
row.x_lot_qty = quant.quantity
Here are the views (stock_move_views.xml):
<field name="lot_id"
attrs="{'readonly': ['&', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}"
invisible="not context.get('show_lots_m2o')"
domain="[('product_id', '=', parent.product_id)]"
groups="stock.group_production_lot"
context="{'default_product_id': parent.product_id, 'active_picking_id': picking_id}"/>
<field name="x_lot_qty"
attrs="{'readonly': ['&', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}"
invisible="not context.get('show_lots_m2o')"
domain="[('product_id', '=', parent.product_id)]"
groups="stock.group_production_lot"
context="{'default_product_id': parent.product_id, 'active_picking_id': picking_id}"/>
I did applied filter via domain attribute but it is not working. How can I restrict the lot numbers with quantity 0.
UPDATE:
I tried following solution:
I created a new dynamic selection field and tried populating the lots which are not empty with respect to location, below is the code:
#api.onchange('location_id')
def _fetch_non_empty_lots(self):
lots = []
for row in self:
quants = self.env['stock.quant'].search([('location_id.id','=',row.location_id.id), ('product_id.id', '=', row.product_id.id), ('quantity', '>', 0)])
for quant in quants:
lots.append(quant)
return lots
x_lot_id = fields.Selection(selection="_fetch_non_empty_lots", name="Non Empty Lots")
But now when I select a new location, I get following error:
Odoo Server Error
Traceback (most recent call last):
File "C:\virtual_odoo12\Scripts\odoo\http.py", line 656, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "C:\virtual_odoo12\Scripts\odoo\http.py", line 314, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "C:\virtual_odoo12\Scripts\odoo\tools\pycompat.py", line 87, in reraise
raise value
File "C:\virtual_odoo12\Scripts\odoo\http.py", line 698, in dispatch
result = self._call_function(**self.params)
File "C:\virtual_odoo12\Scripts\odoo\http.py", line 346, in _call_function
return checked_call(self.db, *args, **kwargs)
File "C:\virtual_odoo12\Scripts\odoo\service\model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "C:\virtual_odoo12\Scripts\odoo\http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File "C:\virtual_odoo12\Scripts\odoo\http.py", line 941, in __call__
return self.method(*args, **kw)
File "C:\virtual_odoo12\Scripts\odoo\http.py", line 519, in response_wrap
response = f(*args, **kw)
File "c:\virtual_odoo12\scripts\addons\web\controllers\main.py", line 962, in call_kw
return self._call_kw(model, method, args, kwargs)
File "c:\virtual_odoo12\scripts\addons\web\controllers\main.py", line 954, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "C:\virtual_odoo12\Scripts\odoo\api.py", line 759, in call_kw
return _call_kw_multi(method, model, args, kwargs)
File "C:\virtual_odoo12\Scripts\odoo\api.py", line 746, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "C:\virtual_odoo12\Scripts\odoo\models.py", line 5524, in onchange
record._onchange_eval(name, field_onchange[name], result)
File "C:\virtual_odoo12\Scripts\odoo\models.py", line 5369, in _onchange_eval
process(method_res)
File "C:\virtual_odoo12\Scripts\odoo\models.py", line 5355, in process
if res.get('value'):
AttributeError: 'list' object has no attribute 'get'
UPDATE 2:
Instead of modifying the existing dropdown, I created a dynamic dropdown. When location is selected, the drop down is populated with lot numbers which have quantity greater than 0. However, I am facing a basic issue/error:
AttributeError: 'list' object has no attribute 'get'
Here is the model selection field and code to populate it:
#api.onchange('location_id')
def _fetch_non_empty_lots(self):
quants = self.env['stock.quant'].search([('location_id.id','=',self.location_id.id),
('product_id.id', '=', self.product_id.id),
('quantity', '>', 0)])
return {str(quant.lot_id.id) :str.title(quant.lot_id.display_name) for quant in quants}
## declare field
x_lot_id = fields.Selection(selection="_fetch_non_empty_lots", name="Non Empty Lots")
When the list is empty, there is no error. When there is non-empty lot then I am getting the eror. Ineed some assistance.

Odoo defines a product quantity field in the stock production lot model, you can use that field in the domain to filter lots, and you need to set store to True to make it searchable. If you need to define a new field then use the same logic and define it in the lot model to use in the lot_id field domain.
You got that error because Odoo expects a dictionary and it got a list instead.
The method may return a dictionary for changing field domains and pop up a warning message, like in the old API.
In your two last examples, you set the selection attribute to a string but the selection attribute specifies the possible values for this field. It is given as either a list of pairs (value, string), or a model method, or a method name. You can find an example in website_customer module.
Edit: (return a domain from onchange method)
The method may return a dictionary for changing field domains and pop up a warning message, like in the old API::
return {
'domain': {'other_id': [('partner_id', '=', partner_id)]},
'warning': {'title': "Warning", 'message': "What is this?"},
}

I think it should be like that?
lot_id = fields.Many2one('stock.production.lot', 'Lot/Serial Number123'
domain="[('product_id', '=', parent.product_id),('product_qty', '>', 0)]" )

What I understand is you want to show only those lots which have
more than 0 products, in your lots drop down
You can try this in your XML
<field name="lot_id"
attrs="{'readonly': ['&', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}"
invisible="not context.get('show_lots_m2o')"
domain="[('product_qty', '>', 0)]" //View this
groups="stock.group_production_lot"
context="{'default_product_id': parent.product_id, 'active_picking_id': picking_id}"/>

add this on your stock.move.line model:
#api.onchange('parent.product_id')
def _onchange_product_id(self):
quants = self.env['stock.quant'].search([('product_id', '=', self.parent.product_id.id), ('quantity', '>', 0)])
return {
'domain': {
'lot_id': [
('id', 'in', quants.lot_id.ids)
],
},
}

Related

Odoo: ValueError("Expected singleton: %s" % self)

I'm modifying Odoo OpenEduCat exam module to fit the need of my institution. For that, I have tailored the code as shown below. However,when I click on generate button, odoo raises expected singleton error. Generating button
Error details
--Python code--
from openerp import models, fields, api
class OpResultTemplate(models.Model):
_name = 'op.result.template'
_description = 'Result Template'
_rec_name = 'name'
exam_session_id = fields.Many2one(
'op.exam.session', 'Exam Session', related='line_ids.exam_session_id', required=False)
name = fields.Char("Name", size=254, required=True)
result_date = fields.Date(
'Result Date', required=True, default=fields.Date.today())
line_ids = fields.One2many(
'op.result.template.line', 'result_id', 'Session Lines')
####this is for semester
inter1_ids = fields.One2many(
'op.internal1', 'result_id', 'Internal 01')
inter2_ids = fields.One2many(
'op.internal2', 'result_id', 'Internal 02')
model_ids = fields.One2many(
'op.model', 'result_id', 'Model')
final_ids = fields.One2many(
'op.final', 'result_id', 'Semester')
state = fields.Selection(
[('normal', 'Normal'), ('semester', 'Semester')],
string='State', required=True, default='normal')
# pass_status_ids = fields.Many2many('op.pass.status', string='Pass Status')
#api.one
def generate_result(self):
data = self.read(['state'])[0]
if data['state'] == 'normal' :
####Write information in to Marksheet Register the place where result generate to.
marksheet_reg_id = self.env['op.marksheet.register'].create({
'name': 'Mark Sheet for %s' % self.line_ids.exam_session_id.name,
'exam_session_id': self.line_ids.exam_session_id.id,
'generated_date': fields.Date.today(),
'generated_by': self.env.uid,
'status': 'draft',
'course_id': self.line_ids.exam_session_id.course_id.name,
'batch_id': self.line_ids.exam_session_id.batch_id.name,
'exam_type': self.line_ids.exam_session_id.exam_type.name,
'semester_id': self.line_ids.exam_session_id.semester_id.name,
})
student_list = []####Define array to store
for exam_session in self.line_ids:####line_ids is table that located in Result generator which allow to choose exam session
total_exam = 0.0#global var
for exam in exam_session.exam_session_id:####exam_session.exam_lines is the table that list the exam or subject located in Result generator->Exam session
total_exam += exam.exam_ids.total_marks
for attd in exam.exam_ids.attendees_line:####exam.exam_id.attendees_line location that contant student name and mark in each subject
result_dict = {####this loop is to write information to result line
'exam_id': exam.exam_ids.id,
'exam_tmpl_id': exam.exam_ids.id,
'marks': attd.marks,####IMPORTANCE mark that student get in each subject THIS IS WHERE TO APPLY PERCENTAGES
'status': attd.marks >= exam.exam_ids.min_marks and####IMPORTANCE take the mark and decide pass or fail base on passing mark in each subject
'pass' or 'fail',
'per': (100 * attd.marks) / exam.exam_ids.total_marks,####NOT IMPORTANCE this can be delete, this take the mark student get and find the percentage of the subject student get in each subject
'student_id': attd.student_id.id,####student name
'total_marks': exam.exam_ids.total_marks,####the total mark of each subject that have been enter when created subject for exam
}
--Error details--
Odoo Server Error
Traceback (most recent call last):
File "/home/v4d/odoo/openerp/http.py", line 650, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/v4d/odoo/openerp/http.py", line 687, in dispatch
result = self._call_function(**self.params)
File "/home/v4d/odoo/openerp/http.py", line 323, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/v4d/odoo/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/home/v4d/odoo/openerp/http.py", line 316, in checked_call
result = self.endpoint(*a, **kw)
File "/home/v4d/odoo/openerp/http.py", line 966, in call
return self.method(*args, **kw)
File "/home/v4d/odoo/openerp/http.py", line 516, in response_wrap
response = f(*args, **kw)
File "/home/v4d/odoo/addons/web/controllers/main.py", line 899, in call_button
action = self._call_kw(model, method, args, {})
File "/home/v4d/odoo/addons/web/controllers/main.py", line 887, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/home/v4d/odoo/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/v4d/odoo/openerp/api.py", line 421, in old_api
result = new_api(recs, *args, **kwargs)
File "/home/v4d/odoo/openerp/api.py", line 425, in new_api
result = [method(rec, *args, **kwargs) for rec in self]
File "/home/v4d/odoo/addons/openeducat_exam/models/result_template.py", line 71, in generate_result
total_exam += exam.exam_ids.total_marks
File "/home/v4d/odoo/openerp/fields.py", line 821, in get
record.ensure_one()
File "/home/v4d/odoo/openerp/models.py", line 5432, in ensure_one
raise ValueError("Expected singleton: %s" % self)
ValueError: Expected singleton: op.exam(44, 45, 46)
I have tried other solutions that could be found on the Internet, but it didn't seem to work. Please kindly help me to deal with this.Thank in advance.
Here is the issue in your code,
####IMPORTANCE take the mark and decide pass or fail base on passing mark in each subject
'status': attd.marks >= exam.exam_ids.min_marks and 'pass' or 'fail',
exam.exam_ids it will return list of browsable objects (recordset list) and you are trying to access min_marks properties, so here it gets confused min_marks property from which object. So it raise an error.
So either you need to specify single object by specifying exam.exam_ids[0] (only single object will return) or you need to search proper records from the one2many model and then you can access to the min_marks field.
Properties are separately created for all objects (OOP rule). Static
properties will be accessible via class.

Error can't adapt type 'some.model.'

I have error when try to receive data from column.
Model is:
class int_filial_phone(models.Model):
_name = 'pr_filials.int_filial_phone'
name = fields.Char(string="Partner-number") #, compute='_get_name_field')
number = fields.Char(string="Phone")
active = fields.Boolean(string="Active")
filial_addr_ids = fields.One2many('pr_filials.filial_addr', 'int_filial_phone_id', string='Address')
filial_id = fields.Many2one('res.company', string='Filial')
advert_phone_ids = fields.One2many('pr_filials.advert_phone', 'int_filial_phone_id', 'Advert phone')
_sql_constraints = [
('number_unique',
'UNIQUE(number)',
"The parameter number must be unique"),
]
Methods:
def find_client_in_filial_phone(self, phone, table):
cr, uid, context, registry = request.cr, request.uid, request.context, request.registry
result = None
table = request.env[table]
phone = self.format_symbol_phone(phone)
_logger.error('find_client_in_filial_phone phone: %r ', phone )
ids = table.sudo().search([['number', '=', phone],], limit=1)
if(len(ids)>0):
result = table.sudo().browse(ids)[0]
_logger.error('find_client_in_filial_phone result: %r ', result )
return result
I try to receive record id:
int_phone = self.find_client_in_filial_phone(data[3], 'pr_filials.int_filial_phone')
int_phone_id = int(int_phone.id)
All work fine
When i try to receive another field of record:
_logger.error("PHONE NAME: %r", int_phone[0].name)
I receive error:
Traceback (most recent call last): File
"/home/skif/odoo/openerp/http.py", line 648, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception) File "/home/skif/odoo/openerp/http.py", line 685, in dispatch
result = self._call_function(**self.params) File "/home/skif/odoo/openerp/http.py", line 321, in _call_function
return checked_call(self.db, *args, **kwargs) File "/home/skif/odoo/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs) File "/home/skif/odoo/openerp/http.py", line 314, in checked_call
result = self.endpoint(*a, **kw) File "/home/skif/odoo/openerp/http.py", line 964, in call
return self.method(*args, **kw) File "/home/skif/odoo/openerp/http.py", line 514, in response_wrap
response = f(*args, **kw) File "/home/skif/odoo/openerp/my-addons/pr_finance/controllers/controllers.py",
line 151, in upload_file
_logger.error("PHONE INT : %r", int_phone[0].name) File "/home/skif/odoo/openerp/fields.py", line 830, in get
self.determine_value(record) File "/home/skif/odoo/openerp/fields.py", line 930, in determine_value
record._prefetch_field(self) File "/home/skif/odoo/openerp/api.py", line 248, in wrapper
return new_api(self, *args, **kwargs) File "/home/skif/odoo/openerp/models.py", line 3308, in _prefetch_field
result = records.read([f.name for f in fs], load='_classic_write') File "/home/skif/odoo/openerp/api.py", line 248, in wrapper
return new_api(self, *args, **kwargs) File "/home/skif/odoo/openerp/models.py", line 3238, in read
self._read_from_database(stored, inherited) File "/home/skif/odoo/openerp/api.py", line 248, in wrapper
return new_api(self, *args, **kwargs) File "/home/skif/odoo/openerp/models.py", line 3376, in _read_from_database
cr.execute(query_str, params) File "/home/skif/odoo/openerp/sql_db.py", line 141, in wrapper
return f(self, *args, **kwargs) File "/home/skif/odoo/openerp/sql_db.py", line 220, in execute
res = self._obj.execute(query, params) File "/home/skif/.local/lib/python2.7/site-packages/psycopg2/extensions.py",
line 129, in getquoted
pobjs = [adapt(o) for o in self._seq] ProgrammingError: can't adapt type 'pr_filials.int_filial_phone'
How I can receive data from record? Why i received id but cannot received data from other fields of record?
In the new version of the api, when you used the method "search", the value return is a recordSet.
Example:
Old api version
record_ids = self.pool.get('model.name').search([('name', '=', 'Jon doe')])
# The value of record_ids is like [1,2,3,4]
records = self.pool.get('model.name').browse(records_ids)
# The value of records is like model.name(1,2,3,4)
In the new version of api
records = self.env['model.name'].search([('name', '=', 'Jondoe')])
# The vale of records is like model.name(1,2,3,4)
In your code you try to browse with recordSet.
def find_client_in_filial_phone(self, phone, table):
...
ids = table.sudo().search([['number', '=', phone],], limit=1)
# Here ids is a recordSet
if(len(ids)>0):
result = table.sudo().browse(ids)[0]
_logger.error('find_client_in_filial_phone result: %r ', result )
return result
You must do like this.
def find_client_in_filial_phone(self, phone, table):
cr, uid, context, registry = request.cr, request.uid, request.context, request.registry
table = request.env[table]
phone = self.format_symbol_phone(phone)
_logger.error('find_client_in_filial_phone phone: %r ', phone )
result = table.sudo().search([['number', '=', phone],], limit=1)
_logger.error('find_client_in_filial_phone result: %r ', result )
return result
If your search doesn't find value, an empty recordSet is return.

AttributeError: 'bool' object has no attribute 'strftime'

I am inheriting 'account.partner.ledger' module. When we select the customer we will be able to print the report of the customer's ledger. In the partner ledger menu I want to make 'include Initial Balances' checkbox checked by default if the filter is by date/period.I tried to override the method by my custom module but I am unable to solve the error which I am getting.
Code,
#api.multi
def onchange_filter(self,filter='filter_no', fiscalyear_id=False):
res = super(account_partner_ledger, self).onchange_filter(filter=filter, fiscalyear_id=fiscalyear_id)
if filter in ['filter_no', 'unreconciled']:
if filter == 'unreconciled':
res['value'].update({'fiscalyear_id': False})
res['value'].update({'initial_balance': False, 'period_from': False, 'period_to': False, 'date_from': False ,'date_to': False})
if filter in ['filter_date','filter_period']:
res['value'].update({'initial_balance': True, 'period_from': True, 'period_to': True, 'date_from': True ,'date_to': True})
return res
Error,
Traceback (most recent call last):
File "C:\Users\zendynamix\odooGit\odoo8\openerp\http.py", line 544, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "C:\Users\zendynamix\odooGit\odoo8\openerp\http.py", line 581, in dispatch
result = self._call_function(**self.params)
File "C:\Users\zendynamix\odooGit\odoo8\openerp\http.py", line 317, in _call_function
return checked_call(self.db, *args, **kwargs)
File "C:\Users\zendynamix\odooGit\odoo8\openerp\service\model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "C:\Users\zendynamix\odooGit\odoo8\openerp\http.py", line 314, in checked_call
return self.endpoint(*a, **kw)
File "C:\Users\zendynamix\odooGit\odoo8\openerp\http.py", line 810, in __call__
return self.method(*args, **kw)
File "C:\Users\zendynamix\odooGit\odoo8\openerp\http.py", line 410, in response_wrap
response = f(*args, **kw)
File "C:\Users\zendynamix\odooGit\odoo8\addons\web\controllers\main.py", line 944, in call_kw
return self._call_kw(model, method, args, kwargs)
File "C:\Users\zendynamix\odooGit\odoo8\addons\web\controllers\main.py", line 936, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "C:\Users\zendynamix\odooGit\odoo8\openerp\api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "C:\Users\zendynamix\odooGit\odoo8\openerp\api.py", line 399, in old_api
result = method(recs, *args, **kwargs)
File "C:\Users\zendynamix\odooGit\odoo8\openerp\models.py", line 5985, in onchange
record._onchange_eval(name, field_onchange[name], result)
File "C:\Users\zendynamix\odooGit\odoo8\openerp\models.py", line 5883, in _onchange_eval
self.update(self._convert_to_cache(method_res['value'], validate=False))
File "C:\Users\zendynamix\odooGit\odoo8\openerp\models.py", line 5391, in _convert_to_cache
for name, value in values.iteritems()
File "C:\Users\zendynamix\odooGit\odoo8\openerp\models.py", line 5392, in <dictcomp>
if name in fields
File "C:\Users\zendynamix\odooGit\odoo8\openerp\fields.py", line 1250, in convert_to_cache
return self.to_string(value)
File "C:\Users\zendynamix\odooGit\odoo8\openerp\fields.py", line 1240, in to_string
return value.strftime(DATE_FORMAT) if value else False
AttributeError: 'bool' object has no attribute 'strftime'
You have to look at the underlying code sometimes to understand what's going on, you're getting errors because Odoo is trying to convert a boolean object back to a string representation of a time (it expects a python date object)
You can fire up a terminal and reproduce your error:
>>> True.strftime
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'bool' object has no attribute 'strftime'
>>>
This is the to_string method from odoo
#staticmethod
def to_string(value):
""" Convert a :class:`date` value into the format expected by the ORM. """
return value.strftime(DATE_FORMAT) if value else False
The test condition if value test's to see if value evaluates to False, testing from the terminal
>>> x = ''
>>> if x: print('Yeah')
...
>>>
>>> x = True
>>> if x: print('Yeah')
...
Yeah
>>> x = False
>>> if x: print('Yeah')
...
>>>
>>>
from the output, we can draw a conclusion that an empty string or False evaluates to False while a True value will evaluate to True, so instead of setting the date values to True, set all of them to empty strings.
#api.multi
def onchange_filter(self,filter='filter_no', fiscalyear_id=False):
res = super(account_partner_ledger, self).onchange_filter(filter=filter, fiscalyear_id=fiscalyear_id)
if filter in ['filter_no', 'unreconciled']:
if filter == 'unreconciled':
res['value'].update({'fiscalyear_id': False})
res['value'].update({'initial_balance': False, 'period_from': False, 'period_to': False, 'date_from': False ,'date_to': False})
if filter in ['filter_date','filter_period']:
res['value'].update({'initial_balance': 'True', 'period_from': '', 'period_to': '', 'date_from': '', 'date_to': ''})
return res
When you look at your code you'll see:
'date_from': True ,'date_to': True
This causes your error.
You should set those fields to a date not to a Boolean.
The value False is valid, since you should be able to not fill in a date.
Try using strptime instead of strftime and see if it solves the problem.
You can use strptime as follows for example:-
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
my_date = datetime.strptime(self.date_column, DEFAULT_SERVER_DATETIME_FORMAT)

Creating module via web-interface

I followed the following steps to create a module named "x_test" :
1. Settings -->Technical --> Database Structure --> Models --> Create
Model Description : Test
Model :x_test
2. Add Fields
Name: x_sample
Field Label: sample
Field Type: boolean
3. Save
4. Click on Create a Menu
5. Select appropriate menu and click on "CREATE MENU"
6. Click on the menu provided and try to provide values for my custom module
7. When I "SAVE" my record, I am getting the following error:
Traceback (most recent call last):
File "/var/app/openerp/server/openerp/netsvc.py", line 292, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/var/app/openerp/server/openerp/service/web_services.py", line 626, in dispatch
res = fn(db, uid, *params)
File "/var/app/openerp/server/openerp/osv/osv.py", line 188, in execute_kw
return self.execute(db, uid, obj, method, *args, **kw or {})
File "/var/app/openerp/server/openerp/osv/osv.py", line 131, in wrapper
return f(self, dbname, *args, **kwargs)
File "/var/app/openerp/server/openerp/osv/osv.py", line 197, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/var/app/openerp/server/openerp/osv/osv.py", line 185, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/var/app/openerp/server/openerp/osv/orm.py", line 4434, in create
cr.execute('insert into "'+self._table+'" (id'+upd0+") values ("+str(id_new)+upd1+')', tuple(upd2))
File "/var/app/openerp/server/openerp/sql_db.py", line 161, in wrapper
return f(self, *args, **kwargs)
File "/var/app/openerp/server/openerp/sql_db.py", line 228, in execute
res = self._obj.execute(query, params)
ProgrammingError: column "x_sample" of relation "x_test" does not exist
LINE 1: insert into "x_test" (id,"x_sample",create_uid,create_date,wri...
Is there any mistake in my regards of creating a module via Web Interface
I had the same issue, go into the database and within the table x_test create the field you added in the model.
Now as far as I am concerned, it should create the fields for you. But I have had to create the fields manually.

How to create a many2one field in OpenERP 7

There are no docs for OpenERP 7 for this: I am trying to create a field with many2one relation from the webclient. I did the following:
1st step created a model and assigned some fields to it
2nd I created a field and mapped the model from the field and when I append that field in view I have been getting this error
Client Traceback (most recent call last):
File "/opt/openerp/web/addons/web/http.py", line 195, in dispatch
response["result"] = method(self, **self.params)
File "/opt/openerp/web/addons/web/controllers/main.py", line 1085, in call_kw
return self._call_kw(req, model, method, args, kwargs)
File "/opt/openerp/web/addons/web/controllers/main.py", line 1077, in _call_kw
return getattr(req.session.model(model), method)(*args, **kwargs)
File "/opt/openerp/web/addons/web/session.py", line 40, in proxy
result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw)
File "/opt/openerp/web/addons/web/session.py", line 28, in proxy_method
result = self.session.send(self.service_name, method, *args)
File "/opt/openerp/web/addons/web/session.py", line 101, in send
raise xmlrpclib.Fault(openerp.tools.exception_to_unicode(e), formatted_info)
Server Traceback (most recent call last):
File "/opt/openerp/web/addons/web/session.py", line 87, in send
return openerp.netsvc.dispatch_rpc(service_name, method, args)
File "/opt/openerp/server/openerp/netsvc.py", line 361, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/opt/openerp/server/openerp/service/web_services.py", line 601, in dispatch
res = fn(db, uid, *params)
File "/opt/openerp/server/openerp/osv/osv.py", line 167, in execute_kw
return self.execute(db, uid, obj, method, *args, **kw or {})
File "/opt/openerp/server/openerp/osv/osv.py", line 121, in wrapper
return f(self, dbname, *args, **kwargs)
File "/opt/openerp/server/openerp/osv/osv.py", line 176, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/opt/openerp/server/openerp/osv/osv.py", line 164, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/opt/openerp/server/openerp/osv/orm.py", line 2389, in name_search
return self._name_search(cr, user, name, args, operator, context, limit)
File "/opt/openerp/server/openerp/osv/orm.py", line 2420, in _name_search
ids = self._search(cr, user, args, limit=limit, context=context, access_rights_uid=access_rights_uid)
File "/opt/openerp/server/openerp/osv/orm.py", line 4773, in _search
query = self._where_calc(cr, user, args, context=context)
File "/opt/openerp/server/openerp/osv/orm.py", line 4622, in _where_calc
e = expression.expression(cr, user, domain, self, context)
File "/opt/openerp/server/openerp/osv/expression.py", line 371, in __init__
self.parse(cr, uid, distribute_not(normalize(exp)), table, context)
File "/opt/openerp/server/openerp/osv/expression.py", line 468, in parse
raise ValueError("Invalid field %r in domain expression %r" % (left, exp))
ValueError: Invalid field 'x_totalexp' in domain expression ['&', '&', ('x_totalexp', '=', 0), ['id', 'not in', []], ('name', 'ilike', 's')]
Is this a bug or i am doing it wrong
Its working now. I also faced the same problem but after "bzr pull", problem get solved.
Just update your 7.0 addons, web & server.