rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
RunCommand(['%s/cros_run_vm_update' % self.crosutilsbin, '--update_image_path=%s' % image_path, '--vm_image_path=%s' % self.vm_image_path, '--snapshot', vm_graphics_flag, '--persist', '--kvm_pid=%s' % _KVM_PID_FILE, stateful_change_flag, '--src_image=%s' % self.source_image, ], enter_chroot=False)
(code, stdout, stderr) = RunCommandCaptureOutput([ '%s/cros_run_vm_update' % self.crosutilsbin, '--update_image_path=%s' % image_path, '--vm_image_path=%s' % self.vm_image_path, '--snapshot', vm_graphics_flag, '--persist', '--kvm_pid=%s' % _KVM_PID_FILE, stateful_change_flag, '--src_image=%s' % self.source_image, ]) i...
def UpdateImage(self, image_path, stateful_change='old'): """Updates VM image with image_path.""" stateful_change_flag = self.GetStatefulChangeFlag(stateful_change) if self.source_image == base_image_path: self.source_image = self.vm_image_path
raise subprocess.CalledProcessError(retcode, command, output=stdout)
_Print(stdout) raise subprocess.CalledProcessError(retcode, command)
def _SimpleRunCommand(command): """Runs a shell command and returns stdout back to caller.""" _Print(' + %s' % command) proc_handle = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) stdout = proc_handle.communicate()[0] retcode = proc_handle.wait() if retcode != 0: raise subprocess.CalledProcessError(ret...
def _UprevFromRevisionList(buildroot, revision_list):
def _UprevFromRevisionList(buildroot, tracking_branch, revision_list):
def _UprevFromRevisionList(buildroot, revision_list): """Uprevs based on revision list.""" if not revision_list: Info('No packages found to uprev') return package_str = '' for package, revision in revision_list: package_str += package + ' ' package_str = package_str.strip() cwd = os.path.join(buildroot, 'src', 'scri...
'--tracking_branch="cros/master"',
'--tracking_branch="%s"' % tracking_branch,
def _UprevFromRevisionList(buildroot, revision_list): """Uprevs based on revision list.""" if not revision_list: Info('No packages found to uprev') return package_str = '' for package, revision in revision_list: package_str += package + ' ' package_str = package_str.strip() cwd = os.path.join(buildroot, 'src', 'scri...
def _UprevAllPackages(buildroot):
def _UprevAllPackages(buildroot, tracking_branch):
def _UprevAllPackages(buildroot): """Uprevs all packages that have been updated since last uprev.""" cwd = os.path.join(buildroot, 'src', 'scripts') RunCommand(['./cros_mark_as_stable', '--all', '--tracking_branch="cros/master"', 'commit'], cwd=cwd, enter_chroot=True)
'--tracking_branch="cros/master"', 'commit'],
'--tracking_branch="%s"' % tracking_branch, 'commit'],
def _UprevAllPackages(buildroot): """Uprevs all packages that have been updated since last uprev.""" cwd = os.path.join(buildroot, 'src', 'scripts') RunCommand(['./cros_mark_as_stable', '--all', '--tracking_branch="cros/master"', 'commit'], cwd=cwd, enter_chroot=True)
def _FullCheckout(buildroot, rw_checkout=True, retries=_DEFAULT_RETRIES):
def _FullCheckout(buildroot, tracking_branch, rw_checkout=True, retries=_DEFAULT_RETRIES, url='http://git.chromium.org/git/manifest'):
def _FullCheckout(buildroot, rw_checkout=True, retries=_DEFAULT_RETRIES): """Performs a full checkout and clobbers any previous checkouts.""" RunCommand(['sudo', 'rm', '-rf', buildroot]) MakeDir(buildroot, parents=True) RunCommand(['repo', 'init', '-u', 'http://git.chromium.org/git/manifest'], cwd=buildroot, input='\n\...
RunCommand(['repo', 'init', '-u', 'http://git.chromium.org/git/manifest'], cwd=buildroot, input='\n\ny\n')
branch = tracking_branch.split('/'); RunCommand(['repo', 'init', '-u', url, '-b', '%s' % branch[-1]], cwd=buildroot, input='\n\ny\n')
def _FullCheckout(buildroot, rw_checkout=True, retries=_DEFAULT_RETRIES): """Performs a full checkout and clobbers any previous checkouts.""" RunCommand(['sudo', 'rm', '-rf', buildroot]) MakeDir(buildroot, parents=True) RunCommand(['repo', 'init', '-u', 'http://git.chromium.org/git/manifest'], cwd=buildroot, input='\n\...
def _UprevPackages(buildroot, revisionfile, board):
def _UprevPackages(buildroot, tracking_branch, revisionfile, board):
def _UprevPackages(buildroot, revisionfile, board): """Uprevs a package based on given revisionfile. If revisionfile is set to None or does not resolve to an actual file, this function will uprev all packages. Keyword arguments: revisionfile -- string specifying a file that contains a list of revisions to uprev. """ ...
_UprevAllPackages(buildroot) def _UprevPush(buildroot):
_UprevAllPackages(buildroot, tracking_branch) def _UprevPush(buildroot, tracking_branch):
def _UprevPackages(buildroot, revisionfile, board): """Uprevs a package based on given revisionfile. If revisionfile is set to None or does not resolve to an actual file, this function will uprev all packages. Keyword arguments: revisionfile -- string specifying a file that contains a list of revisions to uprev. """ ...
'--tracking_branch="cros/master"',
'--tracking_branch="%s"' % tracking_branch,
def _UprevPush(buildroot): """Pushes uprev changes to the main line.""" cwd = os.path.join(buildroot, 'src', 'scripts') RunCommand(['./cros_mark_as_stable', '--srcroot=..', '--tracking_branch="cros/master"', '--push_options="--bypass-hooks -f"', 'push'], cwd=cwd)
_FullCheckout(buildroot)
_FullCheckout(buildroot, tracking_branch, url=options.url)
def main(): # Parse options usage = "usage: %prog [options] cbuildbot_config" parser = optparse.OptionParser(usage=usage) parser.add_option('-r', '--buildroot', help='root directory where build occurs', default=".") parser.add_option('-n', '--buildnumber', help='build number', type='int', default=0) parser.add_option('...
_UprevPackages(buildroot, revisionfile, board=buildconfig['board'])
_UprevPackages(buildroot, tracking_branch, revisionfile, board=buildconfig['board'])
def main(): # Parse options usage = "usage: %prog [options] cbuildbot_config" parser = optparse.OptionParser(usage=usage) parser.add_option('-r', '--buildroot', help='root directory where build occurs', default=".") parser.add_option('-n', '--buildnumber', help='build number', type='int', default=0) parser.add_option('...
_UprevPush(buildroot)
_UprevPush(buildroot, tracking_branch)
def main(): # Parse options usage = "usage: %prog [options] cbuildbot_config" parser = optparse.OptionParser(usage=usage) parser.add_option('-r', '--buildroot', help='root directory where build occurs', default=".") parser.add_option('-n', '--buildnumber', help='build number', type='int', default=0) parser.add_option('...
def _MarkChromeAsStable(buildroot, tracking_branch, chrome_rev):
def _MarkChromeAsStable(buildroot, tracking_branch, chrome_rev, board):
def _MarkChromeAsStable(buildroot, tracking_branch, chrome_rev): """Returns the portage atom for the revved chrome ebuild - see man emerge.""" cwd = os.path.join(buildroot, 'src', 'scripts') portage_atom_string = RunCommand(['bin/cros_mark_chrome_as_stable', '--tracking_branch=%s' % tracking_branch, chrome_rev], cwd=cw...
return portage_atom_string.split('=')[1]
chrome_atom = portage_atom_string.split('=')[1] RunCommand(['sudo', 'tee', CHROME_KEYWORDS_FILE % {'board': board}], input='=%s\n' % chrome_atom, enter_chroot=True, cwd=cwd) return chrome_atom
def _MarkChromeAsStable(buildroot, tracking_branch, chrome_rev): """Returns the portage atom for the revved chrome ebuild - see man emerge.""" cwd = os.path.join(buildroot, 'src', 'scripts') portage_atom_string = RunCommand(['bin/cros_mark_chrome_as_stable', '--tracking_branch=%s' % tracking_branch, chrome_rev], cwd=cw...
RunCommand(['ACCEPT_KEYWORDS="* ~*"', 'emerge-%s' % board,
RunCommand(['emerge-%s' % board,
def _BuildChrome(buildroot, board, chrome_atom_to_build): """Wrapper for emerge call to build Chrome.""" cwd = os.path.join(buildroot, 'src', 'scripts') RunCommand(['ACCEPT_KEYWORDS="* ~*"', 'emerge-%s' % board, '=%s' % chrome_atom_to_build], cwd=cwd, enter_chroot=True)
options.chrome_rev)
options.chrome_rev, board)
def main(): # Parse options usage = "usage: %prog [options] cbuildbot_config" parser = optparse.OptionParser(usage=usage) parser.add_option('-a', '--acl', default='private', help='ACL to set on GSD archives') parser.add_option('-r', '--buildroot', help='root directory where build occurs', default=".") parser.add_option...
_RunCommand('git rebase origin/master')
_RunCommand('git rebase %s' % gflags.FLAGS.tracking_branch)
def _PushChange(): """Pushes changes to the git repository. Pushes locals commits from calls to CommitChange to the remote git repository specified by os.pwd. Raises: OSError: Error occurred while pushing. """ # TODO(sosa) - Add logic for buildbot to check whether other slaves have # completed and push this change o...
elif re.match('.*?-.*?_.*', target):
elif re.match('.*?_.*', target):
def DetermineMakeConfFile(target): """Determine the make.conf file that needs to be updated for prebuilts. Args: target: String representation of the board. This includes host and board targets Returns A string path to a make.conf file to be updated. """ if _HOST_TARGET == target: # We are host. # Without more exampl...
self.UpdateImage(target_image_path)
try: self.UpdateImage(target_image_path) except: if self.use_delta_updates: Warning('Delta update failed, disabling delta updates and retrying.') self.use_delta_updates = False self.source_image = '' self.UpdateImage(target_image_path) else: raise
def testFullUpdateKeepStateful(self): """Tests if we can update normally.
"""Build image and modify mini omaha config.
"""Build factory packages and modify mini omaha config. Args: signed_image: signed image base_image: base image fw_updater: firmware updater folder: destination folder to write packages board: platform to build
def build_factory_packages(signed_image, base_image, fw_updater, folder, board): """Build image and modify mini omaha config. """ cmd = ('./make_factory_package.sh --release %s --factory %s' ' --firmware_updater %s --subfolder %s --board %s' % (signed_image, base_image, fw_updater, folder, board)) print 'Building facto...
' --firmware_updater %s --subfolder %s --board %s' % (signed_image, base_image, fw_updater, folder, board))
' --subfolder %s --board %s' % (signed_image, base_image, folder, board)) if fw_updater: cmd = '%s --firmware_updater %s' % (cmd, fw_updater) else: print ('No --firmware_updater specified. Not including firmware shellball.')
def build_factory_packages(signed_image, base_image, fw_updater, folder, board): """Build image and modify mini omaha config. """ cmd = ('./make_factory_package.sh --release %s --factory %s' ' --firmware_updater %s --subfolder %s --board %s' % (signed_image, base_image, fw_updater, folder, board)) print 'Building facto...
if not FLAGS.firmware_updater: exit('No --firmware_updater specified.')
if FLAGS.firmware_updater: assert_is_file(FLAGS.firmware_updater, 'Invalid or missing firmware updater.')
def main(argv): try: argv = FLAGS(argv) except gflags.FlagsError, e: print '%s\nUsage: %s ARGS\n%s' % (e, sys.argv[0], FLAGS) sys.exit(1) if not FLAGS.base_image: exit('No --base_image specified.') if not FLAGS.firmware_updater: exit('No --firmware_updater specified.') assert_is_file(FLAGS.base_image, 'Invalid or mis...
assert_is_file(FLAGS.firmware_updater, 'Invalid or missing firmware updater.')
def main(argv): try: argv = FLAGS(argv) except gflags.FlagsError, e: print '%s\nUsage: %s ARGS\n%s' % (e, sys.argv[0], FLAGS) sys.exit(1) if not FLAGS.base_image: exit('No --base_image specified.') if not FLAGS.firmware_updater: exit('No --firmware_updater specified.') assert_is_file(FLAGS.base_image, 'Invalid or mis...
def Setup(filehash, filesize):
def Setup(filehash, filesha256, filesize):
def Setup(filehash, filesize): PingUpdateResponse.file_hash = filehash PingUpdateResponse.file_size = filesize
self.file_hash, self.file_size))
self.file_hash, self.file_sha256, self.file_size))
def Reply(self, handler, send_content=True, post_data=None): """Return (using StringResponse) an XML reply to ForcedUpdate clients."""
chrome_version_re = re.compile('^[0-9]\..*')
chrome_version_re = re.compile('^[0-9]+\..*')
def _GetLatestRelease(branch=None): """Gets the latest release version from the buildspec_url for the branch. Args: branch: If set, gets the latest release for branch, otherwise latest release. Returns: Latest version string. """ buildspec_url = 'http://src.chromium.org/svn/releases' svn_ls = RunCommand(['svn', 'ls',...
if not ebuild.is_stable:
if '9999' in ebuild.version:
def FindChromeCandidates(overlay_dir): """Return a tuple of chrome's unstable ebuild and stable ebuilds. Args: overlay_dir: The path to chrome's portage overlay dir. Returns: Tuple [unstable_ebuild, stable_ebuilds]. Raises: Exception: if no unstable ebuild exists for Chrome. """ stable_ebuilds = [] unstable_ebuilds = ...
def testFullUpdateWipeStateful(self):
def NotestFullUpdateWipeStateful(self): """Tests if we can update after cleaning the stateful partition. This test checks that we can update successfully after wiping the stateful partition. """
def testFullUpdateWipeStateful(self): # Prepare and verify the base image has been prepared correctly. self.PrepareBase() self.VerifyImage()
AUTest.setUp(self)
def setUp(self): """Unit test overriden method. Is called before every test."""
RunCommand(['%s/image_to_vm.sh' % _SCRIPTS_DIR,
RunCommand(['%s/image_to_vm.sh' % self.crosutils,
def PrepareBase(self): """Creates an update-able VM based on base image."""
stateful_change_flag = '' if stateful_change: stateful_change_flag = '--stateful_flags=%s' % stateful_change RunCommand(['%s/cros_run_vm_update' % os.path.dirname(__file__),
stateful_change_flag = self.GetStatefulChangeFlag(stateful_change) RunCommand(['%s/cros_run_vm_update' % self.crosutilsbin,
def UpdateImage(self, image_path, stateful_change='old'): """Updates VM image with image_path."""
RunCommand(['%s/cros_run_vm_test' % os.path.dirname(__file__),
RunCommand(['%s/cros_run_vm_test' % self.crosutilsbin,
def VerifyImage(self): """Runs vm smoke suite to verify image."""
], error_ok=True, enter_chroot=False)
], error_ok=False, enter_chroot=False)
def VerifyImage(self): """Runs vm smoke suite to verify image."""
help='path to the target image')
help='path to the target image.')
def VerifyImage(self): """Runs vm smoke suite to verify image."""
help='board for the images')
help='board for the images.') parser.add_option('-p', '--type', default='vm', help='type of test to run: [vm, real]. Default: vm.') parser.add_option('-m', '--remote', help='Remote address for real test.')
def VerifyImage(self): """Runs vm smoke suite to verify image."""
unittest.main()
if options.type == 'vm': suite = unittest.TestLoader().loadTestsFromTestCase(VirtualAUTest) unittest.TextTestRunner(verbosity=2).run(suite) elif options.type == 'real': if not options.remote: parser.error('Real tests require a remote test machine.') else: remote = options.remote suite = unittest.TestLoader().loadTests...
def VerifyImage(self): """Runs vm smoke suite to verify image."""
def _GitCleanup(buildroot, board):
def _GitCleanup(buildroot, board, tracking_branch):
def _GitCleanup(buildroot, board): """Clean up git branch after previous uprev attempt.""" cwd = os.path.join(buildroot, 'src', 'scripts') if os.path.exists(cwd): RunCommand(['./cros_mark_as_stable', '--srcroot=..', '--board=%s' % board, '--tracking_branch="cros/master"', 'clean'], cwd=cwd, error_ok=True)
'--tracking_branch="cros/master"', 'clean'],
'--tracking_branch="%s"' % tracking_branch, 'clean'],
def _GitCleanup(buildroot, board): """Clean up git branch after previous uprev attempt.""" cwd = os.path.join(buildroot, 'src', 'scripts') if os.path.exists(cwd): RunCommand(['./cros_mark_as_stable', '--srcroot=..', '--board=%s' % board, '--tracking_branch="cros/master"', 'clean'], cwd=cwd, error_ok=True)
def _PreFlightRinse(buildroot, board):
def _PreFlightRinse(buildroot, board, tracking_branch):
def _PreFlightRinse(buildroot, board): """Cleans up any leftover state from previous runs.""" _GitCleanup(buildroot, board) _CleanUpMountPoints(buildroot) RunCommand(['sudo', 'killall', 'kvm'], error_ok=True)
_GitCleanup(buildroot, board)
_GitCleanup(buildroot, board, tracking_branch)
def _PreFlightRinse(buildroot, board): """Cleans up any leftover state from previous runs.""" _GitCleanup(buildroot, board) _CleanUpMountPoints(buildroot) RunCommand(['sudo', 'killall', 'kvm'], error_ok=True)
_PreFlightRinse(buildroot, buildconfig['board'])
_PreFlightRinse(buildroot, buildconfig['board'], tracking_branch)
def main(): # Parse options usage = "usage: %prog [options] cbuildbot_config" parser = optparse.OptionParser(usage=usage) parser.add_option('-r', '--buildroot', help='root directory where build occurs', default=".") parser.add_option('-n', '--buildnumber', help='build number', type='int', default=0) parser.add_option('...
merge_branch = _GitBranch(merge_branch_name)
merge_branch = GitBranch(merge_branch_name)
def PushChange(stable_branch, tracking_branch): """Pushes commits in the stable_branch to the remote git repository. Pushes locals commits from calls to CommitChange to the remote git repository specified by current working directory. Args: stable_branch: The local branch with commits we want to push. tracking_branch...
for path in paths: assert ':' not in path, 'Overlay must not contain colons: %s' % path if not os.path.isdir(path): Die('Missing overlay: %s' % path)
def _ResolveOverlays(buildroot, overlays): """Return the list of overlays to use for a given buildbot. Args: buildroot: The root directory where the build occurs. Must be an absolute path. overlays: A string describing which overlays you want. 'private': Just the private overlay. 'public': Just the public overlay. 'bo...
redirect_file.write('CROS_WORKON_COMMIT="%s"' % commit_id)
redirect_file.write('CROS_WORKON_COMMIT="%s"\n' % commit_id)
def RevEBuild(self, commit_id="", redirect_file=None): """Revs an ebuild given the git commit id.
cwd = os.path.join(buildroot, 'src', 'scripts')
cwd = os.path.join(buildroot, 'src', 'third_party', 'chromiumos-overlay', 'chromeos', 'config')
def _GetChromeOSVersion(buildroot): """Returns the tuple version of the Chrome OS version of the buildroot.""" cwd = os.path.join(buildroot, 'src', 'scripts') version_cmd = './chromeos_version.sh' output = RunCommand(version_cmd, cwd=cwd, redirect_stdout=True, redirect_stderr=True) version_re = re.compile('\s+CHROMEOS_...
cmd = 'python devserver.py'
cmd = 'python devserver.py --factory_config miniomaha.conf'
def start_devserver(): """Starts devserver.""" cmd = 'python devserver.py' print 'Running command: %s' % cmd devserver_process = KillableProcess(cmd, cwd=DEVSERVER_DIR) devserver_process.start(wait=False)
start_devserver()
if FLAGS.start_devserver: start_devserver()
def main(argv): try: argv = FLAGS(argv) except gflags.FlagsError, e: print '%s\nUsage: %s ARGS\n%s' % (e, sys.argv[0], FLAGS) sys.exit(1) if not FLAGS.base_image: exit('No --base_image specified.') if FLAGS.firmware_updater: assert_is_file(FLAGS.firmware_updater, 'Invalid or missing firmware updater.') assert_is_fil...
def execute( self, application, *options ):
def execute( self, application, *options, **kwargs ):
def execute( self, application, *options ): """Execute a dialplan application with given options
"|".join([
delimiter.join([
def execute( self, application, *options ): """Execute a dialplan application with given options
"""Send a null operation to the server
"""Send a null operation to the server. Any message sent will be printed to the CLI.
def noop( self, message=None ): """Send a null operation to the server
command = '''GET DATA "%s" %s %s'''%(filename, timeout, maxDigits)
command = '''GET DATA "%s" %s'''%(filename, timeout) if maxDigits is not None: command = ' '.join([command, str(maxDigits)])
def getData( self, filename, timeout=2.000, maxDigits=None ): """Playback file, collecting up to maxDigits or waiting up to timeout
return self.sendDeferred( message ).addCallback( self.errorUnlessResponse, expected = 'Pong', )
if self.amiVersion == "1.0": return self.sendDeferred(message).addCallback( self.errorUnlessResponse, expected = 'Pong', ) else: return self.sendDeferred(message).addCallback( self.errorUnlessResponse )
def ping( self ): """Check to see if the manager is alive...""" message = {'action':'ping'} return self.sendDeferred( message ).addCallback( self.errorUnlessResponse, expected = 'Pong', )
return self.sendCommand( command ).addCallback( self.checkFailure, ).addCallback( self.onStreamingComplete, skipMS=skipMS )
return self.sendCommand( command ).addCallback( self.checkFailure )
def controlStreamFile( self, filename, escapeDigits, skipMS=0, ffChar='*', rewChar='#', pauseChar=None,
if move.purchase_line_id and move.picking_id.pricelist_id.currency_id: reference_amount, reference_currency_id = move.purchase_line_id.price_unit, move.picking_id.pricelist_id.currency_id.id
if move.sale_line_id and move.picking_id.pricelist_id.currency_id: reference_amount, reference_currency_id = move.sale_line_id.price_unit, move.picking_id.pricelist_id.currency_id.id
def _get_reference_accounting_values_for_valuation(self, cr, uid, move, context=None): """ Overrides the default stock valuation to take into account the currency that was specified on the sale order in case the valuation data was not directly specified during picking confirmation. """ reference_amount, reference_curre...
context={} for m in move_obj.browse(cr, uid, context.get('active_ids', [])): if m.state in ('done', 'cancel'):
context = {} for move in move_obj.browse(cr, uid, context.get('active_ids', [])): if move.state in ('done', 'cancel'):
def view_init(self, cr, uid, fields_list, context=None): res = super(stock_partial_move, self).view_init(cr, uid, fields_list, context=context) move_obj = self.pool.get('stock.move') if not context: context={} for m in move_obj.browse(cr, uid, context.get('active_ids', [])): if m.state in ('done', 'cancel'): raise osv....
if 'move%s_product_id'%(m.id) not in self._columns: self._columns['move%s_product_id'%(m.id)] = fields.many2one('product.product',string="Product") if 'move%s_product_qty'%(m.id) not in self._columns: self._columns['move%s_product_qty'%(m.id)] = fields.float("Quantity") if 'move%s_product_uom'%(m.id) not in self._colum...
def __get_active_stock_moves(self, cr, uid, context=None): move_obj = self.pool.get('stock.move') if not context: context = {} res = [] for move in move_obj.browse(cr, uid, context.get('active_ids', [])): if move.state in ('done', 'cancel'): continue res.append(self.__create_partial_move_memory(move)) print res
def view_init(self, cr, uid, fields_list, context=None): res = super(stock_partial_move, self).view_init(cr, uid, fields_list, context=context) move_obj = self.pool.get('stock.move') if not context: context={} for m in move_obj.browse(cr, uid, context.get('active_ids', [])): if m.state in ('done', 'cancel'): raise osv....
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False): print context
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): height = 2 * 25;
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False): print context message = { 'title' : '_(Deliver Products)', 'info' : '_(Delivery Information)', 'button' : '_Deliver' } if context: if context.get('product_receive', False): message = { 'title' : '_(Receive Pro...
'title' : '_(Deliver Products)', 'info' : '_(Delivery Information)', 'button' : '_Deliver'
'title' : _('Deliver Products'), 'info' : _('Delivery Information'), 'button' : _('Deliver'),
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False): print context message = { 'title' : '_(Deliver Products)', 'info' : '_(Delivery Information)', 'button' : '_Deliver' } if context: if context.get('product_receive', False): message = { 'title' : '_(Receive Pro...
'title' : '_(Receive Products)', 'info' : '_(Receive Information)', 'button' : '_Receive'
'title' : _('Receive Products'), 'info' : _('Receive Information'), 'button' : _('Receive'),
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False): print context message = { 'title' : '_(Deliver Products)', 'info' : '_(Delivery Information)', 'button' : '_Deliver' } if context: if context.get('product_receive', False): message = { 'title' : '_(Receive Pro...
result = super(stock_partial_move, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu) move_obj = self.pool.get('stock.move') move_ids = context.get('active_ids', False) move_ids = move_obj.search(cr, uid, [('id','in',move_ids)]) _moves_arch_lst = """<form string="%(title)s"> <separator colspan...
result = super(stock_partial_move, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False): print context message = { 'title' : '_(Deliver Products)', 'info' : '_(Delivery Information)', 'button' : '_Deliver' } if context: if context.get('product_receive', False): message = { 'title' : '_(Receive Pro...
if move_ids and view_type in ['form']: for m in move_obj.browse(cr, uid, move_ids, context): if m.state in ('done', 'cancel'): continue _moves_fields.update({ 'move%s_product_id'%(m.id) : { 'string': _('Product'), 'type' : 'many2one', 'relation': 'product.product', 'required' : True, 'readonly' : True, }, 'move%s_prod...
_moves_fields.update({'product_moves' : { 'relation': 'stock.move.memory', 'type' : 'one2many', 'string' : 'Product Moves', } }) _moves_arch_lst = """ <form string="%(title)s"> <separator colspan="4" string="%(info)s"/> <field name="date" colspan="2"/> <separator colspan="4" string="Move Detail"/> <field name="product...
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False): print context message = { 'title' : '_(Deliver Products)', 'info' : '_(Delivery Information)', 'button' : '_Deliver' } if context: if context.get('product_receive', False): message = { 'title' : '_(Receive Pro...
<separator string="" colspan="4" /> <label string="" colspan="2"/> <group col="2" colspan="2"> <button icon='gtk-cancel' special="cancel" string="_Cancel" /> <button name="do_partial" string="%(button)s" colspan="1" type="object" icon="gtk-apply" /> </group> </form>""" % message
</form> """ % message
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False): print context message = { 'title' : '_(Deliver Products)', 'info' : '_(Delivery Information)', 'button' : '_Deliver' } if context: if context.get('product_receive', False): message = { 'title' : '_(Receive Pro...
def default_get(self, cr, uid, fields, context=None): """ To get default values for the object. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param fields: List of fields for which we want default values @param context: A standard dictionary @return: A dic...
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False): print context message = { 'title' : '_(Deliver Products)', 'info' : '_(Delivery Information)', 'button' : '_Deliver' } if context: if context.get('product_receive', False): message = { 'title' : '_(Receive Pro...
for m in move_obj.browse(cr, uid, move_ids): if m.state in ('done', 'cancel'):
p_moves = {} for product_move in partial.product_moves: p_moves[product_move.move_id.id] = product_move moves_ids_final = [] for move in move_obj.browse(cr, uid, move_ids): if move.state in ('done', 'cancel'):
def do_partial(self, cr, uid, ids, context): """ Makes partial moves and pickings done. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param fields: List of fields for which we want default values @param context: A standard dictionary @return: A dictionary ...
partial_datas['move%s'%(m.id)] = { 'product_id' : getattr(partial, 'move%s_product_id'%(m.id)).id, 'product_qty' : getattr(partial, 'move%s_product_qty'%(m.id)), 'product_uom' : getattr(partial, 'move%s_product_uom'%(m.id)).id, 'prodlot_id' : getattr(partial, 'move%s_prodlot_id'%(m.id)).id
if not p_moves.get(move.id, False): continue partial_datas['move%s' % (move.id)] = { 'product_id' : p_moves[move.id].product_id.id, 'product_qty' : p_moves[move.id].quantity, 'product_uom' : p_moves[move.id].product_uom.id, 'prodlot_id' : p_moves[move.id].prodlot_id.id,
def do_partial(self, cr, uid, ids, context): """ Makes partial moves and pickings done. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param fields: List of fields for which we want default values @param context: A standard dictionary @return: A dictionary ...
if (m.picking_id.type == 'in') and (m.product_id.cost_method == 'average'): partial_datas['move%s'%(m.id)].update({ 'product_price' : getattr(partial, 'move%s_product_price'%(m.id)), 'product_currency': getattr(partial, 'move%s_product_currency'%(m.id)).id
moves_ids_final.append(move.id) if (move.picking_id.type == 'in') and (move.product_id.cost_method == 'average'): partial_datas['move%s' % (move.id)].update({ 'product_price' : p_moves[move.id].cost, 'product_currency': p_moves[move.id].currency.id,
def do_partial(self, cr, uid, ids, context): """ Makes partial moves and pickings done. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param fields: List of fields for which we want default values @param context: A standard dictionary @return: A dictionary ...
move_obj.do_partial(cr, uid, move_ids, partial_datas, context=context)
move_obj.do_partial(cr, uid, moves_ids_final, partial_datas, context=context)
def do_partial(self, cr, uid, ids, context): """ Makes partial moves and pickings done. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param fields: List of fields for which we want default values @param context: A standard dictionary @return: A dictionary ...
stock_partial_move_memory()
def do_partial(self, cr, uid, ids, context): """ Makes partial moves and pickings done. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param fields: List of fields for which we want default values @param context: A standard dictionary @return: A dictionary ...
to_update = self.product_id_change_unit_price_inv(cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context=context)
to_update = self.product_id_change_unit_price_inv(cr, uid, tax_id, price_unit or res.standard_price, qty, address_invoice_id, product, partner_id, context=context)
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, context=None): if context is None: context = {} if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partn...
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'resource.resource', c)
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'resource.resource', context=c)
def interval_get(self, cr, uid, id, dt_from, hours, resource=False, byday=True): resource_cal_leaves = self.pool.get('resource.calendar.leaves') dt_leave = [] if not id: return [(dt_from,dt_from + mx.DateTime.RelativeDateTime(hours=int(hours)*3))] resource_leave_ids = resource_cal_leaves.search(cr, uid, [('calendar_id'...
cr.execute('Update crm_meeting set caldav_alarm_id=%s where id=%s' % (alarm_id, meeting.id))
cr.execute('Update crm_meeting set caldav_alarm_id=%s \ where id=%s' % (alarm_id, meeting.id))
def do_alarm_create(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0]
cr.execute('Update crm_meeting set caldav_alarm_id=NULL where id=%s' % (meeting.id))
cr.execute('Update crm_meeting set caldav_alarm_id=NULL, \ alarm_id=NULL where id=%s' % (meeting.id))
def do_alarm_unlink(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] for meeting in self.browse(cr, uid, ids): alarm_ids = alarm_obj.search(cr, uid, [('model_id','=',model_id), ('res_id'...
return adr and res_partner_address.read(self.cr, self.uid, [adr]) or False
return adr and res_partner_address.read(self.cr, self.uid, [adr]) or [{}]
def _adr_get(self, partner, type): res_partner = pooler.get_pool(self.cr.dbname).get('res.partner') res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address') adr = res_partner.address_get(self.cr, self.uid, [partner.id], [type])[type] return adr and res_partner_address.read(self.cr, self.uid, [ad...
if uom.factor: res[uom.id] = round(1 / uom.factor, 6) else: res[uom.id] = 0.0
res[uom.id] = self._compute_factor_inv(uom.factor)
def _factor_inv(self, cursor, user, ids, name, arg, context): res = {} for uom in self.browse(cursor, user, ids, context=context): if uom.factor: res[uom.id] = round(1 / uom.factor, 6) else: res[uom.id] = 0.0 return res
if value: self.write(cursor, user, id, { 'factor': round(1/value, 6), }, context=context) else: self.write(cursor, user, id, { 'factor': 0.0, }, context=context) return True
return self.write(cursor, user, id, {'factor': self._compute_factor_inv(value)}, context=context) def create(self, cr, uid, data, context={}): if 'factor_inv' in data: if data['factor_inv'] <> 1: data['factor'] = self._compute_factor_inv(data['factor_inv']) del(data['factor_inv']) return super(product_uom, self).creat...
def _factor_inv_write(self, cursor, user, id, name, value, arg, context): if value: self.write(cursor, user, id, { 'factor': round(1/value, 6), }, context=context) else: self.write(cursor, user, id, { 'factor': 0.0, }, context=context) return True
('reference','Reference UoM for this category (ratio=1)'),
('reference','Reference UoM for this category'),
def _factor_inv_write(self, cursor, user, id, name, value, arg, context): if value: self.write(cursor, user, id, { 'factor': round(1/value, 6), }, context=context) else: self.write(cursor, user, id, { 'factor': 0.0, }, context=context) return True
'factor': 1.0, 'factor_inv': 1.0,
def _factor_inv_write(self, cursor, user, id, name, value, arg, context): if value: self.write(cursor, user, id, { 'factor': round(1/value, 6), }, context=context) else: self.write(cursor, user, id, { 'factor': 0.0, }, context=context) return True
'account_id': account,
'account_id': result.get('account_id', statement.journal_id.default_credit_account_id.id),
def populate_statement(self, cr, uid, ids, context=None): line_obj = self.pool.get('payment.line') statement_obj = self.pool.get('account.bank.statement') statement_line_obj = self.pool.get('account.bank.statement.line') currency_obj = self.pool.get('res.currency') voucher_obj = self.pool.get('account.voucher') voucher...
context.update({'move_line_ids': [line.move_line_id.id]}) result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), currency_id= statement.currency.id, ttype='payment', context=context)
def populate_statement(self, cr, uid, ids, context=None): line_obj = self.pool.get('payment.line') statement_obj = self.pool.get('account.bank.statement') statement_line_obj = self.pool.get('account.bank.statement.line') currency_obj = self.pool.get('res.currency') voucher_obj = self.pool.get('account.voucher') voucher...
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
'company_id': _default_company,
def _default_company(self, cr, uid, context={}): """ To get default company for the object" @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of bank statement ids @param context: A standard dictionary for contex...
inv_amount_company_currency=invoice.move_id.amount
inv_amount_company_currency = 0.0 for aml in invoice.move_id.line_id: if aml.account_id.id == invoice.account_id.id or aml.account_id.type in ('receivable', 'payable'): inv_amount_company_currency += aml.debit inv_amount_company_currency -= aml.credit inv_amount_company_currency = abs(inv_amount_company_currency)
def _wo_check(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context) journal = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context) cur_obj = pool.get('res.currency') # Here we need that: # The invoice to...
'member_ids': fields.one2many('hr.employee', 'department_id', 'Members'),
'member_ids': fields.one2many('hr.employee', 'department_id', 'Members', readonly=True),
def _check_department_id(self, cr, uid, ids, context=None): for emp in self.browse(cr, uid, ids, context=context): if emp.department_id.manager_id and emp.id == emp.department_id.manager_id.id: return False return True
"SELECT id, name FROM mrp_workcenter " \ "WHERE id=ANY(%s)" \ "ORDER BY mrp_workcenter.id" ,(ids,))
"SELECT mw.id, rs.name FROM mrp_workcenter mw, resource_resource rs " \ "WHERE mw.id=ANY(%s) and mw.resource_id=rs.id " \ "ORDER BY mw.id" ,(ids,))
def create(self, cr, uid, ids, datas, context={}): assert len(ids), 'You should provide some ids!' colors = choice_colors(len(ids)) cr.execute( "SELECT MAX(mrp_production.date_planned) AS stop,MIN(mrp_production.date_planned) AS start "\ "FROM mrp_workcenter, mrp_production, mrp_production_workcenter_line "\ "WHERE mrp...
mrp_workcenter.name AS name, mrp_workcenter.id AS id \ FROM mrp_production_workcenter_line, mrp_production, mrp_workcenter \
resource_resource.name AS name, mrp_workcenter.id AS id \ FROM mrp_production_workcenter_line, mrp_production, mrp_workcenter, resource_resource \
def create(self, cr, uid, ids, datas, context={}): assert len(ids), 'You should provide some ids!' colors = choice_colors(len(ids)) cr.execute( "SELECT MAX(mrp_production.date_planned) AS stop,MIN(mrp_production.date_planned) AS start "\ "FROM mrp_workcenter, mrp_production, mrp_production_workcenter_line "\ "WHERE mrp...
GROUP BY mrp_production_workcenter_line.workcenter_id, mrp_workcenter.name, mrp_workcenter.id \
GROUP BY mrp_production_workcenter_line.workcenter_id, resource_resource.name, mrp_workcenter.id \
def create(self, cr, uid, ids, datas, context={}): assert len(ids), 'You should provide some ids!' colors = choice_colors(len(ids)) cr.execute( "SELECT MAX(mrp_production.date_planned) AS stop,MIN(mrp_production.date_planned) AS start "\ "FROM mrp_workcenter, mrp_production, mrp_production_workcenter_line "\ "WHERE mrp...
elif action.trg_state_to: ok = False
def do_check(self, cr, uid, action, obj, context={}): """ check Action @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """
if part.property_payment_term and part.property_payment_term.line_ids: payterm = part.property_payment_term.line_ids[0] res = self.pool.get('account.payment.term').compute(cr, uid, payterm.id, 100, date)
if part.property_payment_term: res = self.pool.get('account.payment.term').compute(cr, uid, part.property_payment_term.id, 100, date)
def onchange_partner_id(self, cr, uid, ids, move_id, partner_id, account_id=None, debit=0, credit=0, date=False, journal=False): val = {} val['date_maturity'] = False
country1 = ''
country = ''
def execute(self, cr, uid, ids, context=None): company_id = self.pool.get('base.setup.company').search(cr, uid, []) company_data = self.pool.get('base.setup.company').read(cr, uid, company_id) company_data = company_data and company_data[0] or False country1 = '' if company_data and company_data.get('country_id', False...
def get_data(self, form):
def get_data(self, data):
def get_data(self, form): cr, uid = self.cr, self.uid db_pool = pooler.get_pool(self.cr.dbname)
ctx['fiscalyear'] = form['fiscalyear']
ctx['fiscalyear'] = data['form']['fiscalyear_id']
def get_data(self, form): cr, uid = self.cr, self.uid db_pool = pooler.get_pool(self.cr.dbname)
if form['filter']=='filter_period' : ctx['periods'] = form['periods'] elif form['filter']== 'filter_date': ctx['date_from'] = form['date_from'] ctx['date_to'] = form['date_to']
if data['form']['filter']=='filter_period' : ctx['periods'] = data['periods'] elif data['form']['filter']== 'filter_date': ctx['date_from'] = data['date_from'] ctx['date_to'] = data['date_to']
def get_data(self, form): cr, uid = self.cr, self.uid db_pool = pooler.get_pool(self.cr.dbname)
account_id = [form['Account_list']]
account_id =data['form']['chart_account_id']
def get_data(self, form): cr, uid = self.cr, self.uid db_pool = pooler.get_pool(self.cr.dbname)
if form['display_account'] == 'bal_mouvement':
if data['form']['display_account'] == 'bal_mouvement':
def get_data(self, form): cr, uid = self.cr, self.uid db_pool = pooler.get_pool(self.cr.dbname)
elif form['display_account'] == 'bal_solde':
elif data['form']['display_account'] == 'bal_solde':
def get_data(self, form): cr, uid = self.cr, self.uid db_pool = pooler.get_pool(self.cr.dbname)
FROM account_move_line AS line \
FROM account_move_line AS line, \ account_move AS move \
def _sum(self, cr, uid, ids, name, args, context,where ='', where_params=()): parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if context.get('based_on', 'invoices') == 'payments': cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \ FROM account_move_line AS line, \ account_move AS mov...
def _sum_year(self, cr, uid, ids, name, args, context):
def _sum_year(self, cr, uid, ids, name, args, context=None): if context is None: context = {} move_state = ('posted', ) if 'state' in context and context['state'] == 'all': move_state = ('draft', 'posted', )
def _sum_year(self, cr, uid, ids, name, args, context): if 'fiscalyear_id' in context and context['fiscalyear_id']: fiscalyear_id = context['fiscalyear_id'] else: fiscalyear_id = self.pool.get('account.fiscalyear').find(cr, uid, exception=False) where = '' where_params = () if fiscalyear_id: pids = map(lambda x: str(x....
where = ' and period_id IN %s' where_params = (tuple(pids),)
where = ' AND line.period_id IN %s AND move.state IN %s ' where_params = (tuple(pids), move_state)
def _sum_year(self, cr, uid, ids, name, args, context): if 'fiscalyear_id' in context and context['fiscalyear_id']: fiscalyear_id = context['fiscalyear_id'] else: fiscalyear_id = self.pool.get('account.fiscalyear').find(cr, uid, exception=False) where = '' where_params = () if fiscalyear_id: pids = map(lambda x: str(x....
where=' and line.period_id=%s', where_params=(period_id,))
where=' AND line.period_id=%s AND move.state IN %s', where_params=(period_id, move_state))
def _sum_period(self, cr, uid, ids, name, args, context): if 'period_id' in context and context['period_id']: period_id = context['period_id'] else: period_id = self.pool.get('account.period').find(cr, uid) if not len(period_id): return dict.fromkeys(ids, 0.0) period_id = period_id[0] return self._sum(cr, uid, ids, nam...