I have this wizard button, which saves fields as records on a table:
@api.multi
def save_data(self, vals):
vals = {
self.name : 'name',
self.date_production : 'date_production',
self.type_prod : 'type_prod',
self.product_id : 'product_id',
self.qty_available : 'qty_available',
self.print_order2 : 'print_order2',
self.name_block : 'name_block',
}
self.env['bsi.production.order'].create(vals)
This is a step by step wizard, these are the original fields on my model:
class bsi_production_order(models.Model):
_name = 'bsi.production.order'
_inherit = ['mail.thread','text.paper','book.binding', 'book.block','book.edge','book.edition','book.size','cut.off','end.paper','job.rate','paper.master','printing.code', 'mrp.worksheet.contract', 'work.order.isbn.code', 'product.template']
@api.model
def create(self, vals):
if vals.get('name', 'New') == 'New':
vals['name'] = self.env['ir.sequence'].next_by_code('bsi.production.order') or '/'
return super(bsi_production_order, self).create(vals)
name = fields.Char('Reference', required=True, index=True, copy=False, readonly='True', default='New')
date_production = fields.Date(string="Production Date")
type_prod = fields.Selection([
('budgeted','Budgeted'),
('nonbudgeted','Non Budgeted'),
('direct','Direct Order'),
], string='Type of Order', index=True,
track_visibility='onchange', copy=False,
help=" ")
product_id = fields.Many2one('product.template', string="Product")
qty_available = fields.Float(string="Qty Available", related="product_id.qty_available")
production_qty = fields.Float(string="Qty to produce")
print_order2 = fields.Many2one('bsi.print.order', string="Print Order")
book_block = fields.Many2one('book.block', )
name_block = fields.Selection(string="Code", related="book_block.name_block", store=True)
When I try to save the records from the wizard it says:
ValueError
Mixing apples and oranges: bsi.print.order() < False
Any ideas?
EDIT
This is definitely something related to Many2one
and/or One2many
fields, I've got another error like this with another field, which is a Many2one
type of field.
There is also something curious that might have something to do with it, and is the fact that when I save a bsi.production.order
in the traditional form way, not by wizard, the Many2one related
fields are shown, but when I save the new record, they just got empty somehow, it's like it doesn't save them for some reason, I've added the store=True
flag to them, but still the same behaviour.
Second Edit
Full stack trace:
2017-08-26 22:42:46,786 1688 ERROR bsi_def openerp.http: Exception during JSON request handling.
Traceback (most recent call last):
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 546, in _handle_exception
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 583, in dispatch
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 319, in _call_function
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\service\model.py", line 118, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 316, in checked_call
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 812, in __call__
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 412, in response_wrap
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\web\controllers\main.py", line 948, in call_button
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 399, in old_api
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\mrp_worksheet_contract\models\models.py", line 780, in save_data
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 266, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\mrp_worksheet_contract\models\models.py", line 476, in create
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 266, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\mrp_worksheet_contract\models\models.py", line 15, in create
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 266, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 508, in new_api
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\product\product.py", line 742, in create
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 372, in old_api
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\mrp_work_order_isbn\models\models.py", line 28, in create
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 266, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 508, in new_api
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\mail\mail_thread.py", line 381, in create
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\api.py", line 372, in old_api
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\models.py", line 4101, in create
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\models.py", line 5608, in __lt__
except_orm: ('ValueError', 'Mixing apples and oranges: bsi.print.order() < False')