Server IP : 127.0.0.2 / Your IP : 3.147.77.120 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /opt/odoo/addons/mrp/models/ |
Upload File : |
# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import api, fields, models class StockScrap(models.Model): _inherit = 'stock.scrap' production_id = fields.Many2one( 'mrp.production', 'Manufacturing Order', states={'done': [('readonly', True)]}) workorder_id = fields.Many2one( 'mrp.workorder', 'Work Order', states={'done': [('readonly', True)]}, help='Not to restrict or prefer quants, but informative.') @api.onchange('workorder_id') def _onchange_workorder_id(self): if self.workorder_id: self.location_id = self.workorder_id.production_id.location_src_id.id @api.onchange('production_id') def _onchange_production_id(self): if self.production_id: self.location_id = self.production_id.move_raw_ids.filtered(lambda x: x.state not in ('done', 'cancel')) and self.production_id.location_src_id.id or self.production_id.location_dest_id.id, def _get_preferred_domain(self): if self.production_id: if self.product_id in self.production_id.move_raw_ids.mapped('product_id'): preferred_domain = [('reservation_id', 'in', self.production_id.move_raw_ids.ids)] preferred_domain2 = [('reservation_id', '=', False)] preferred_domain3 = ['&', ('reservation_id', 'not in', self.production_id.move_raw_ids.ids), ('reservation_id', '!=', False)] return [preferred_domain, preferred_domain2, preferred_domain3] elif self.product_id in self.production_id.move_finished_ids.mapped('product_id'): preferred_domain = [('history_ids', 'in', self.production_id.move_finished_ids.ids)] preferred_domain2 = [('history_ids', 'not in', self.production_id.move_finished_ids.ids)] return [preferred_domain, preferred_domain2] return super(StockScrap, self)._get_preferred_domain() def _prepare_move_values(self): vals = super(StockScrap, self)._prepare_move_values() if self.production_id: vals['origin'] = vals['origin'] or self.production_id.name if self.product_id in self.production_id.move_finished_ids.mapped('product_id'): vals.update({'production_id': self.production_id.id}) else: vals.update({'raw_material_production_id': self.production_id.id}) return vals def _get_origin_moves(self): return super(StockScrap, self)._get_origin_moves() or self.production_id and self.production_id.move_raw_ids.filtered(lambda x: x.product_id == self.product_id)